cs-audit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecs-audit
cs-audit
cs-issuecs-refactorcs-explorecs-audit本技能只发现、不定修。修是 / 的事。
cs-issuecs-refactorcs-issuecs-refactorcs-explorecs-auditThis skill only identifies issues, not fixes them. Fixing is the responsibility of / .
cs-issuecs-refactor文件放哪儿
Where to Place Files
codestable/audits/{YYYY-MM-DD}-{slug}/
├── index.md # 速览:范围、总评、发现清单交叉矩阵
├── finding-01.md
├── finding-02.md
└── ...日期取审计当天。slug 短到一眼看出审计目标(、、)。
auth-moduleorder-flowpayment-security所有 audit 文档带 YAML frontmatter( 分别为 和 )便于 检索。
doc_typeaudit-indexaudit-findingsearch-yaml.pycodestable/audits/{YYYY-MM-DD}-{slug}/
├── index.md # Overview: scope, overall assessment, cross-matrix of findings list
├── finding-01.md
├── finding-02.md
└── ...The date is the day of the audit. The slug should be short enough to identify the audit target at a glance (e.g., , , ).
auth-moduleorder-flowpayment-securityAll audit documents include YAML frontmatter (with set to and respectively) to facilitate retrieval via .
doc_typeaudit-indexaudit-findingsearch-yaml.py维度矩阵(交叉分类)
Dimension Matrix (Cross Classification)
每个发现打两个标签:
性质: | | | |
bugsecurityperformancemaintainabilityarch-drift严重度:(必须修)| (应该修)| (可以修)
P0P1P2交叉示例:
- ×
security:SQL 注入、明文存密码P0 - ×
bug:特定边界条件下空指针,实际触发概率低P1 - ×
performance:循环内多余的对象分配,热点路径才需要改P2
另外每个发现带 置信度( / / )和建议动作( / )。
highmediumlowcs-issuecs-refactor完整模板见 。
reference.mdEach finding is tagged with two labels:
Nature: | | | |
bugsecurityperformancemaintainabilityarch-driftSeverity: (Must fix) | (Should fix) | (Could fix)
P0P1P2Cross examples:
- ×
security: SQL injection, storing passwords in plaintextP0 - ×
bug: Null pointer under specific boundary conditions, with low actual trigger probabilityP1 - ×
performance: Redundant object allocation in loops, only needs modification in hot pathsP2
Additionally, each finding includes confidence level ( / / ) and suggested action ( / ).
highmediumlowcs-issuecs-refactorSee for the complete template.
reference.md工作流
Workflow
Phase 1:范围收敛
Phase 1: Scope Convergence
审计不能全仓库盲扫——成本高、噪音大。先帮用户把范围收窄到可执行。
问用户三样(有一样就能起步):
- 关键词:"跟 auth / payment / upload 相关的"
- 模块 / 目录:"下面"
src/services/ - 一段话描述:"最近用户反馈订单页慢,帮我扫一下订单相关代码"
用户描述已清楚直接进 Phase 2。用户说"整个项目都扫" → 推回去——建议先扫最常改的模块或最近出过问题的区域。
收敛后给用户确认:"扫 和 ,约 12 个文件,看安全 / 性能 / bug 隐患三个维度。范围 OK 吗?"
src/services/order/src/api/order.tsBlind scanning of the entire repository for audits is not allowed—it's costly and generates excessive noise. First, help the user narrow down the scope to an executable range.
Ask the user for one of the three (any one is sufficient to start):
- Keywords: "Related to auth / payment / upload"
- Module / Directory: "Under "
src/services/ - Paragraph description: "Recently users reported that the order page is slow, help me scan the order-related code"
If the user's description is clear, proceed directly to Phase 2. If the user says "scan the entire project" → push back—suggest scanning the most frequently modified modules or areas that have had issues recently.
After convergence, confirm with the user: "Scanning and , approximately 12 files, covering three dimensions: security / performance / bug risks. Is the scope OK?"
src/services/order/src/api/order.tsPhase 2:扫描
Phase 2: Scanning
按用户圈定的维度逐维扫描(用户没指定就全扫 5 维):
- bug 隐患:空值路径、边界条件缺失、竞态条件、错误处理吞异常、类型断言无保护
- 安全:注入风险、敏感数据暴露、权限校验缺失、不安全依赖
- 性能:N+1 查询、重复计算、无缓存热点路径、内存泄漏、无分页全量加载
- 可维护性:超长函数(> 80 行)、圈复杂度 > 15、重复逻辑块、神秘常量、循环依赖
- 架构偏离:代码与 记录不一致、分层泄漏、跨模块隐式耦合
codestable/architecture/
扫描时用 Glob / Grep / Read 真实读代码。每条发现必须记录 + 具体代码片段。
文件:行号上限:每种维度最多报 5 条。不是凑数——够了就停,不够也不硬凑。
置信度口径:
- :代码路径可确认触发,影响明确
high - :静态分析能定位问题,但触发条件不确定
medium - :线索可疑,需要进一步确认但值得标记
low
Scan dimension by dimension according to the scope defined by the user (scan all 5 dimensions if not specified):
- Bug risks: Null value paths, missing boundary conditions, race conditions, swallowed exceptions in error handling, unprotected type assertions
- Security: Injection risks, exposure of sensitive data, missing permission checks, insecure dependencies
- Performance: N+1 queries, repeated calculations, hot paths without caching, memory leaks, full loading without pagination
- Maintainability: Extra-long functions (>80 lines), cyclomatic complexity >15, duplicate logic blocks, magic constants, circular dependencies
- Architecture drift: Inconsistencies between code and records in , layer leakage, implicit cross-module coupling
codestable/architecture/
Use Glob / Grep / Read to actually read the code during scanning. Each finding must record + specific code snippet.
file:line numberUpper Limit: Report a maximum of 5 findings per dimension. Don't fill in numbers—stop when enough are found, don't force it if not enough.
Confidence Level Definition:
- : The code path can be confirmed to trigger, with clear impact
high - : The issue can be located via static analysis, but the trigger conditions are uncertain
medium - : Suspicious clues, need further confirmation but worth marking
low
Phase 3:定级 + 产出
Phase 3: Rating + Output
- 每个发现打性质 + 严重度 + 置信度 + 建议动作
- 写 :范围、总评、发现清单表格(交叉分类)
index.md - 逐条写
finding-NN.md
先写 index 再写 finding——这个顺序让 AI 先做整体判断再展开细节,避免陷入单条发现迷失全局。
- Tag each finding with nature + severity + confidence level + suggested action
- Write : scope, overall assessment, findings list table (cross-classified)
index.md - Write one by one
finding-NN.md
Write index first, then findings—this order allows the AI to make an overall judgment first before expanding details, avoiding getting lost in individual findings.
Phase 4:建议下一步
Phase 4: Suggest Next Steps
index.md 末尾给优先级建议:
- "P0 的 3 条建议立刻开 issue 修"
- "P1 的 5 条可以排下个迭代"
- "P2 的 4 条有空再看"
用户选哪条 → 路由到 或 。 自己不修。
cs-issuecs-refactorcs-auditAt the end of index.md, provide priority suggestions:
- "It is recommended to immediately create issues for the 3 P0 findings"
- "The 5 P1 findings can be scheduled for the next iteration"
- "The 4 P2 findings can be reviewed when there is time"
Whichever option the user selects → route to or . does not fix issues itself.
cs-issuecs-refactorcs-audit与相邻技能的边界
Boundaries with Adjacent Skills
| 技能 | 触发 | cs-audit 怎么对待 |
|---|---|---|
| 用户报已知 bug | audit 发现 bug 后建议开 |
| 用户指已知优化点 | audit 发现可优化点后建议开 |
| 围绕一个问题查代码 | audit 是批量扫多个维度,不等同于 explore |
| 维护架构文档 | cs-arch 维护文档,cs-audit 检查代码是否偏离文档 |
| 安全审查 | audit 的安全维度是轻量扫描,深度安全审查走专项 |
| Skill | Trigger | How cs-audit Handles It |
|---|---|---|
| User reports a known bug | After identifying a bug during audit, suggest creating a |
| User points out a known optimization point | After identifying an optimization point during audit, suggest creating a |
| Investigate code around a specific question | Audit involves batch scanning across multiple dimensions, which is not equivalent to explore |
| Maintain architecture documents | cs-arch maintains documents, while cs-audit checks if code deviates from documents |
| Security review | The security dimension of audit is lightweight scanning; in-depth security review requires a special process |
守护规则
Guardrails
- 不盲扫全仓库——Phase 1 必须收敛范围,没范围不动手
- 每条发现必有证据——file:line + 代码片段 + 为什么构成问题。不准出现"感觉不好"、"可能有问题"类无证据发现
- 置信度必标——不准所有发现都标
high - 每种维度上限 5 条——逼 AI 挑最值得报的,不是 dump 所有发现
- 只发现不定修——cs-audit 不出代码改动。出现"顺便修了"就算越界
- 架构偏离引用当前文档——不准凭记忆判断架构应该长什么样,必须读 对照
codestable/architecture/ - 旧审计标注过期——同名模块新审计覆盖旧审计时,旧 index 标 +
status: supersededsuperseded-by: {新目录}
- No blind scanning of the entire repository—Phase 1 must converge the scope; do not start without a scope
- Every finding must have evidence—file:line + code snippet + why it constitutes a problem. No findings like "feels wrong" or "might have issues" without evidence are allowed
- Confidence level must be marked—do not mark all findings as
high - Maximum 5 findings per dimension—force the AI to select the most worthy findings, not dump all findings
- Only identify, do not fix—cs-audit does not produce code changes. It is considered out of bounds if "fix it by the way" appears
- Architecture drift references current documents—do not judge what the architecture should look like based on memory; must read and compare with
codestable/architecture/ - Mark old audits as expired—when a new audit for the same module covers an old one, mark the old index with +
status: supersededsuperseded-by: {new directory}
退出条件
Exit Criteria
- 审计范围已和用户确认
- 各维度扫描完成,至少有一个发现(若零发现:告知用户此范围内未发现明显问题)
- index.md 含完整交叉分类表
- 每条发现 file:line + evidence + confidence
- 每种维度 ≤ 5 条
- 给用户按优先级排列的下一步建议
- Audit scope has been confirmed with the user
- Scanning of all dimensions is completed, with at least one finding (if zero findings: inform the user that no obvious issues were found within this scope)
- index.md includes a complete cross-classified table
- Each finding has file:line + evidence + confidence level
- ≤5 findings per dimension
- Provide priority-ranked next-step suggestions to the user
相关文档
Related Documents
- — index.md / finding-NN.md 模板
reference.md - — 跨工作流共享口径
codestable/reference/shared-conventions.md - — 架构偏离类发现对照源
codestable/architecture/
- — Template for index.md / finding-NN.md
reference.md - — Shared standards across workflows
codestable/reference/shared-conventions.md - — Reference source for architecture drift findings
codestable/architecture/