Loading...
Loading...
Compare original and translation side by side
Related Skills:
- USE FIRST for Kavak-specific patterns, kbroker, STS, GitLab CI, Docker templateskavak-documentation - USE PROACTIVELY for new features and bug fixes (Red-Green-Refactor)test-driven-development- Check
or.claude/CLAUDE.mdfor project-specific conventions.cursor/rules/*MCP: Usetool to query Kavak internal documentation before implementing.kavak-platform/plati_query
相关技能:
- 优先使用 用于Kavak特定模式、kbroker、STS、GitLab CI、Docker模板kavak-documentation - 主动使用 用于新功能开发和Bug修复(红-绿-重构)test-driven-development- 查看
或.claude/CLAUDE.md获取项目特定规范.cursor/rules/*MCP:在实现前使用工具查询Kavak内部文档。kavak-platform/plati_query
undefinedundefined
**The goal:** Find ANY existing code that does something similar to what your task needs.
**目标:** 找到任何与你的任务需求类似的现有代码。| Question | If YES... |
|---|---|
| Does this do exactly what I need? | Call it directly - inject as dependency |
| Does this do 70%+ of what I need? | Extend it - add method/parameter |
| Does this share 50%+ logic with what I need? | Extract shared helper first |
| Is this only 30% similar? | OK to create new, but document why |
| 问题 | 如果是YES... |
|---|---|
| 它是否完全符合我的需求? | 直接调用 - 作为依赖注入 |
| 它是否满足我70%以上的需求? | 扩展它 - 添加方法/参数 |
| 它是否与我的需求有50%以上的逻辑重合? | 先提取共享辅助函数 |
| 相似度仅为30%? | 可以创建新代码,但需记录原因 |
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ REUSE ANALYSIS ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Task: [brief description of what you need to implement] ┃
┃ ┃
┃ Keywords searched: ┃
┃ - Verbs: [actual verbs you searched] ┃
┃ - Nouns: [actual domain terms you searched] ┃
┃ ┃
┃ Existing code found: ┃
┃ 1. [file:line] - [function name] - [what it does] ┃
┃ 2. [file:line] - [function name] - [what it does] ┃
┃ ┃
┃ Similarity assessment: ┃
┃ - [file1]: [X]% similar because [reason] ┃
┃ ┃
┃ Decision: [REUSE | EXTEND | EXTRACT | NEW] ┃
┃ Rationale: [1-2 sentences why] ┃
┃ Action: [specific action - e.g., "inject existing service"] ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ 复用分析 ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ 任务: [你需要实现的内容简要描述] ┃
┃ ┃
┃ 搜索的关键词: ┃
┃ - 动词: [你实际搜索的动词] ┃
┃ - 名词: [你实际搜索的领域术语] ┃
┃ ┃
┃ 找到的现有代码: ┃
┃ 1. [文件:行号] - [函数名] - [功能描述] ┃
┃ 2. [文件:行号] - [函数名] - [功能描述] ┃
┃ ┃
┃ 相似度评估: ┃
┃ - [文件1]: [X]% 相似,原因是 [具体理由] ┃
┃ ┃
┃ 决策: [复用 | 扩展 | 提取 | 新建] ┃
┃ 理由: [1-2句话说明原因] ┃
┃ 行动: [具体操作 - 例如:"注入现有服务"] ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛| Similarity | Action | Example |
|---|---|---|
| >70% | REUSE directly | Inject existing service as dependency, call its method |
| 50-70% | EXTRACT shared helper | Create helper function, refactor existing + use in new |
| 30-50% | Consider interface | Create interface both can implement |
| <30% | OK to create new | Document why existing code doesn't fit |
| 相似度 | 操作 | 示例 |
|---|---|---|
| >70% | 直接复用 | 将现有服务作为依赖注入,调用其方法 |
| 50-70% | 提取共享辅助函数 | 创建辅助函数,重构现有代码并在新代码中使用 |
| 30-50% | 考虑接口 | 创建两者都可实现的接口 |
| <30% | 可以创建新代码 | 记录现有代码不适用的原因 |
references/architecture.mdreferences/dry-detection.md// ❌ BAD: Obvious comment
const age = user.age; // Get user age
// ✅ GOOD: Explains WHY
// Add 1 day buffer for timezone edge cases in billing cycle
const billingDate = addDays(cycleEnd, 1);references/code-quality.mdreferences/architecture.mdreferences/dry-detection.md// ❌ 错误:注释冗余
const age = user.age; // 获取用户年龄
// ✅ 正确:解释原因
// 为计费周期的时区边缘情况添加1天缓冲
const billingDate = addDays(cycleEnd, 1);references/code-quality.mdExisting project has flat structure? → Keep flat structure
Existing project has no interfaces? → Don't add interfaces everywhere
Existing project uses callbacks? → Use callbacks (unless migrating)现有项目是扁平结构?→ 保持扁平结构
现有项目没有使用接口?→ 不要到处添加接口
现有项目使用回调?→ 使用回调(除非正在迁移)| Language | Test | Lint |
|---|---|---|
| Node/TS | | |
| Go | | |
| 语言 | 测试命令 | 代码检查命令 |
|---|---|---|
| Node/TS | | |
| Go | | |
| Need | Choose |
|---|---|
| TypeScript API | NestJS |
| High concurrency | Go + Chi |
| Go database | pgx/v5 + sqlc |
| Node database | Drizzle (new), keep existing |
| Go Redis | rueidis (new), keep existing |
| Go job queue | River (PostgreSQL-backed) |
| Node job queue | pg-boss (PostgreSQL-backed) |
| Events (Kavak) | kbroker (Kafka-by-REST) |
| Rate limiting | pg-boss throttle / River snooze |
| Testing | Vitest (new Node), Jest (existing) |
| Tracing | OpenTelemetry + dd-trace |
Note: Use kbroker for events between services. Use pg-boss (Node) or River (Go) for job queues.
| 需求 | 选择 |
|---|---|
| TypeScript API | NestJS |
| 高并发场景 | Go + Chi |
| Go 数据库 | pgx/v5 + sqlc |
| Node 数据库 | Drizzle(新项目),沿用现有方案 |
| Go Redis | rueidis(新项目),沿用现有方案 |
| Go 任务队列 | River(基于PostgreSQL) |
| Node 任务队列 | pg-boss(基于PostgreSQL) |
| 事件(Kavak) | kbroker(Kafka-by-REST) |
| 限流 | pg-boss throttle / River snooze |
| 测试 | Vitest(新Node项目),Jest(现有项目) |
| 链路追踪 | OpenTelemetry + dd-trace |
注意: 服务间事件使用kbroker。任务队列使用pg-boss(Node)或River(Go)。
Useskill for Red-Green-Refactor cycletest-driven-development
test-driven-developmentreferences/api-design.mdreferences/go/http-handlers.mdreferences/node/frameworks.mdreferences/go/database.mdreferences/node/database.mdreferences/authentication.mdreferences/code-quality.md使用技能 进行红-绿-重构循环test-driven-development
test-driven-developmentreferences/api-design.mdreferences/go/http-handlers.mdreferences/node/frameworks.mdreferences/go/database.mdreferences/node/database.mdreferences/authentication.mdreferences/code-quality.mdCRITICAL: When task says "do X like Y" or "add similar to existing"
| Approach | Result |
|---|---|
| ❌ WRONG | Create new file (50-100+ lines) that duplicates existing logic |
| ✅ RIGHT | Inject existing service, call its method (5-10 lines) |
重要提示:当任务要求"像实现Y一样实现X"或"添加与现有功能类似的功能"时
| 方法 | 结果 |
|---|---|
| ❌ 错误 | 创建新文件(50-100+行),重复现有逻辑 |
| ✅ 正确 | 注入现有服务,调用其方法(5-10行) |
references/debugging.mdreferences/performance.mdreferences/go/redis-queues.mdreferences/node/database.mdreferences/debugging.mdreferences/performance.mdreferences/go/redis-queues.mdreferences/node/database.mdreferences/devops/docker.mdreferences/devops/ci-cd.mdreferences/devops/docker.mdreferences/devops/ci-cd.mdreferences/debugging.mdreferences/debugging.mdreferences/debugging.mdreferences/debugging.mdreferences/debugging.mdreferences/debugging.md| Reference | When to Use |
|---|---|
| Go | |
| Set up Chi routes, handlers, middleware |
| Implement pgx/v5, sqlc queries |
| Apply error handling, validation, testing |
| Add rueidis caching, River job queue |
| Node.js | |
| Set up NestJS, Express, Fastify |
| Implement Drizzle, Prisma, caching |
| Apply validation, errors, testing |
| DevOps | |
| Write Dockerfiles, compose, health checks, DataDog metrics |
| Configure GitLab CI pipelines |
| Cross-Cutting | |
| Clean Architecture (4-layer), microservices, events |
| SOLID, DRY, YAGNI, KISS, design patterns |
| MANDATORY - DRY detection, code reuse patterns |
| Design REST endpoints, versioning |
| Implement OAuth 2.1, JWT, RBAC |
| Apply OWASP Top 10, input validation |
| Optimize caching, queries, pooling |
| Write unit, integration, E2E tests |
| Debug with logs, profilers, tracing |
| 参考文档 | 使用场景 |
|---|---|
| Go | |
| 设置Chi路由、处理器、中间件 |
| 实现pgx/v5、sqlc查询 |
| 应用错误处理、验证、测试 |
| 添加rueidis缓存、River任务队列 |
| Node.js | |
| 设置NestJS、Express、Fastify |
| 实现Drizzle、Prisma、缓存 |
| 应用验证、错误处理、测试 |
| DevOps | |
| 编写Dockerfile、compose、健康检查、DataDog指标 |
| 配置GitLab CI流水线 |
| 跨领域 | |
| Clean Architecture(4层架构)、微服务、事件 |
| SOLID、DRY、YAGNI、KISS、设计模式 |
| 强制要求 - DRY原则检测、代码复用模式 |
| 设计REST端点、版本控制 |
| 实现OAuth 2.1、JWT、RBAC |
| 应用OWASP Top 10、输入验证 |
| 优化缓存、查询、连接池 |
| 编写单元测试、集成测试、E2E测试 |
| 使用日志、性能分析器、链路追踪进行调试 |
| Reference | When to Use |
|---|---|
| Publish/subscribe events between services |
| Job queues, rate limiting with River/pg-boss |
| Authenticate between services (STS) |
| Set up kavak-it/ci-jobs v3 pipelines |
| Build with docker-debian base |
| Configure |
| Use kvklog, kvkmetric SDKs |
| 参考文档 | 使用场景 |
|---|---|
| 服务间发布/订阅事件 |
| 任务队列、限流 使用River/pg-boss |
| 服务间认证(STS) |
| 设置kavak-it/ci-jobs v3流水线 |
| 使用docker-debian基础镜像构建 |
| 配置 |
| 使用kvklog、kvkmetric SDKs |