帮助开发者按业务领域为代码命名,提升可读性与协作一致性。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "Domain-Focused Naming" 技能: 1. 下载 https://raw.githubusercontent.com/obra/clank/main/skills/coding/naming-by-domain/SKILL.md 2. 保存为 ~/.claude/skills/naming-by-domain/SKILL.md 3. 装好后重载技能,告诉我可以用了
请检查下面这段订单系统代码中的类名、函数名和变量名,按业务领域重新命名,避免使用实现细节、技术缩写或历史遗留名称,并说明每个重命名的理由: [粘贴代码]
一份按订单业务语义优化后的命名建议清单,附带逐项说明。
我们团队在支付、退款和结算相关代码中命名不统一。请基于领域驱动命名原则,整理一份简明命名规范,包含推荐模式、避免事项和示例对照表。
一份适合团队落地的命名规范,帮助统一领域术语与代码表达。
请审查这组 API 的接口名、字段名和参数名,判断它们是否体现业务含义而不是技术实现;如果不合适,请给出更贴近领域的替代名称: [粘贴 API 定义]
一份 API 命名审查结果,指出问题并提供更贴近业务语义的替代方案。
Names documenting implementation or history create confusion. "NewUserAPI" doesn't tell what it does. "ZodValidator" exposes internals.
Core principle: Names tell what code does in the domain, not how it's built or what it replaced.
Violating the letter of this rule is violating the spirit of naming.
Use for:
Use ESPECIALLY when:
Names expose WHAT, not HOW.
<Bad> ```typescript class ZodValidator { } // Exposes Zod library class MCPToolWrapper { } // Exposes MCP protocol class JSONConfigParser { } // Exposes JSON format ``` </Bad> <Good> ```typescript class Validator { } // What it does class RemoteTool { } // What it represents class ConfigReader { } // What it does ``` </Good>Code exists in present. Don't reference past or transitions.
<Bad> ```typescript class NewAPI { } // When does it stop being "new"? class LegacyHandler { } // Calls it legacy but it's running class ImprovedParser { } // Improved from what? class UnifiedService { } // What was unified? class EnhancedValidator { } // Enhanced how? ``` </Bad> <Good> ```typescript class API { } // What it is now class Handler { } // What it does now class Parser { } // What it does now class Service { } // What it is now class Validator { } // What it does now ``` </Good> <Bad> ```typescript class ToolFactory { } // "Factory" adds nothing class ServiceBuilder { } // "Builder" adds nothing class ManagerSingleton { } // "Singleton" adds nothing ``` </Bad> <Good> ```typescript class Tool { } // Clear without pattern class Service { } // Clear without pattern class Registry { } // Clear without pattern </Good> <Bad> ```typescript // During refactoring class NewAuthService { } // References the change class ImprovedValidator { } // References improvement class UnifiedAPIClient { } // References unification ``` </Bad> <Good> ```typescript // During refactoring class AuthService { } // What it is class Validator { } // What it does class APIClient { } // What it is ``` </Good>Patterns are implementation details. Most don't help understanding.
// OK when pattern IS the purpose class EventEmitter { } // Observer pattern IS what it does class CommandQueue { } // Queue pattern IS what it does
</Good>
### Names Tell Domain Stories
Good names form sentences about business logic.
<Good>
```typescript
// Reads like domain language
user.authenticate()
order.calculateTotal()
payment.process()
// Not
user.executeAuthenticationStrategy()
order.runTotalCalculationAlgorithm()
payment.invokeProcessingWorkflow()
| Bad Pattern | Why Bad | Good Alternative |
|---|---|---|
ZodValidator | Exposes implementation | Validator |
MCPToolWrapper | Exposes protocol | RemoteTool |
NewUserAPI | Temporal reference | UserAPI |
ImprovedParser | References history | Parser |
ToolFactory | Pattern name noise | Tool or createTool() |
AbstractToolInterface | Redundant qualifiers | Tool |
executeToolWithValidation() | Implementation in name | execute() |
Rule: Never document old behavior or the change in names.
…
帮助你为变量选择清晰准确、易维护的命名,提升代码可读性。
通过三阶段审查与改进,逐步优化代码与产品命名质量