single-responsibility
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese单一职责原则
Single Responsibility Principle
每个文件、函数、模块应该只负责一个明确的功能或职责。
Each file, function, and module should only be responsible for one clear function or responsibility.
⚠️ 核心强制要求
⚠️ Core Mandatory Requirements
1. 文件级别
1. File Level
- 文件的主要功能可以用一句话描述
- 所有函数/类都与主要功能相关
- The main function of the file can be described in one sentence
- All functions/classes are related to the main function
2. 函数级别
2. Function Level
- 函数名清晰表达单一职责
- 内部逻辑围绕一个明确目标
- The function name clearly expresses the single responsibility
- Internal logic revolves around a clear goal
3. 模块级别
3. Module Level
- 按业务领域或技术层次划分
- 不存在循环依赖
- Divided by business domain or technical level
- No circular dependencies
AI Agent 行为要求
AI Agent Behavior Requirements
创建代码时
When Creating Code
- 在编码前规划好职责边界
- 如果不确定如何划分,主动与用户讨论
- Plan responsibility boundaries before coding
- If you are not sure how to divide, actively discuss with the user
修改代码时
When Modifying Code
- 检查当前职责划分是否合理
- 发现问题时提供重构建议
- 拆分前与用户确认方案
- Check whether the current responsibility division is reasonable
- Provide refactoring suggestions when problems are found
- Confirm the solution with the user before splitting
发现职责不清时
When Unclear Responsibilities Are Found
提供建议模板:
⚠️ 职责划分建议
当前问题:[描述]
建议拆分方案:[具体文件/职责]
是否执行拆分?Provide suggestion template:
⚠️ 职责划分建议
当前问题:[描述]
建议拆分方案:[具体文件/职责]
是否执行拆分?与 architecture-governance
的组合使用
architecture-governanceCombined Use with architecture-governance
architecture-governance- 当改动涉及分层边界、依赖方向、接口契约时,先触发 。
architecture-governance - 当改动核心是职责拆分、边界澄清、文件/类瘦身时,触发本 skill。
- 若两者同时出现,顺序为:
- (定架构边界)
architecture-governance - (做职责拆分)
single-responsibility - (复核依赖与分层)
architecture-governance
- When the change involves layered boundaries, dependency direction, interface contracts, trigger first.
architecture-governance - When the core of the change is responsibility splitting, boundary clarification, file/class slimming, trigger this skill.
- If both occur at the same time, the order is:
- (define architecture boundaries)
architecture-governance - (perform responsibility splitting)
single-responsibility - (review dependencies and layering)
architecture-governance
分类标注
Classification Labeling
- 本 skill 是可独立复用的通用原则 skill。
- 在架构治理场景中,作为 的联动子原则使用。
architecture-governance
- This skill is an independently reusable general principle skill.
- In architecture governance scenarios, it is used as a linked sub-principle of .
architecture-governance
参考资料
References
- - 文件级别职责划分详细说明
references/file-level.md - - 函数级别职责划分详细说明
references/function-level.md - - 模块级别职责划分详细说明
references/module-level.md
- - Detailed description of file-level responsibility division
references/file-level.md - - Detailed description of function-level responsibility division
references/function-level.md - - Detailed description of module-level responsibility division
references/module-level.md