Index of every page on this site: llms.txt
All skills
qiao-925 avatar

/single-responsibility

@50a1ee4
Run it yourself

单一职责能力单元,帮助 Agent 在文件拆分、函数重构、模块设计、代码审查与边界澄清场景中,识别职责混杂、变化原因耦合与命名失真问题,让文件、函数、类与模块都能围绕一个稳定职责组织。关键词:单一职责、职责拆分、边界澄清、重构、文件拆分、函数重构、模块设计。

Use this Skill: https://skilld.dev/gh/qiao-925/qiao-skills/single-responsibility

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesfunction-level.md

≈356 tokens on demand. Your agent reads this file only when SKILL.md points to it.

函数级:一个函数聚焦一个明确目标

核心问题

函数级单一职责,不是要求函数永远很短,而是要求目标清楚、主路径清楚、变化原因清楚。

高风险混杂模式

1. 获取 + 处理

  • 先查数据
  • 再做业务转换
  • 最后再决定输出格式

如果这些步骤变化频率不同,通常应拆开。

2. 验证 + 执行

函数一边做参数校验,一边做状态变更或持久化,往往会让边界不清。

3. 计算 + 输出

纯计算和展示/打印/格式化混在一起时,后续复用会很差。

4. 编排 + 细节实现

主流程函数既负责协调步骤,又深入处理每个步骤的细节,通常会越来越难读。

重构策略

  • 把错误和边界分支前置,先让主路径清楚。
  • 把变化频率不同的逻辑拆开。
  • 保留一个清晰编排函数,但把细节下沉到小函数。
  • 拆分后优先让函数名直接说明职责。

不要机械拆分

以下情况不必硬拆:

  • 函数虽然稍长,但始终围绕一个清晰目标
  • 拆分后只会制造大量一跳函数,降低阅读效率
  • 当前真正问题是算法复杂度或架构边界,而不是函数职责

检查清单

  • 函数目标是否能一句话说明。
  • 是否混入多个独立变化原因。
  • 主路径是否能顺序阅读。
  • 拆分后是否真的更容易理解和复用。

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning7mo4 checks · Risk SAFE
  • Gen Agent Trust Hub7mo

    This skill provides comprehensive architectural guidelines and best practices for implementing the Single Responsibility Principle (SRP). It is purely educational and instructional, containing no executable code, network operations, or sensitive data access. No security issues were detected.

  • Socket7mo

    No alerts

  • Snyk7mo

    Risk: LOW · No issues

  • Runlayer9mo

    4/4 files flagged

Signed by skilld at 50a1ee4. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago
Other metadata
metadata
{
  "type": "declarative",
  "category": "engineering",
  "scope": "generic",
  "role": "skill-unit"
}

README badge

README badge for qiao-925/qiao-skills/single-responsibility