cs-audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cs-audit

cs-audit

cs-issue
等你报 bug,
cs-refactor
等你指优化点,
cs-explore
等你提问题——但"我也不知道哪有问题,你先扫一遍看看"这个诉求没人接。
cs-audit
补上这块:在用户限定的范围内主动扫描,产出一份按严重度 × 性质交叉分类的发现清单
本技能只发现、不定修。修是
cs-issue
/
cs-refactor
的事。

cs-issue
waits for you to report bugs,
cs-refactor
waits for you to point out optimization points,
cs-explore
waits for you to raise questions—but the request "I don't know where the problems are, just scan through and check" had no one to handle it.
cs-audit
fills this gap: proactively scan within the scope defined by the user and generate a list of findings cross-classified by severity × nature.
This skill only identifies issues, not fixes them. Fixing is the responsibility of
cs-issue
/
cs-refactor
.

文件放哪儿

Where to Place Files

codestable/audits/{YYYY-MM-DD}-{slug}/
├── index.md           # 速览:范围、总评、发现清单交叉矩阵
├── finding-01.md
├── finding-02.md
└── ...
日期取审计当天。slug 短到一眼看出审计目标(
auth-module
order-flow
payment-security
)。
所有 audit 文档带 YAML frontmatter(
doc_type
分别为
audit-index
audit-finding
)便于
search-yaml.py
检索。

codestable/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-module
,
order-flow
,
payment-security
).
All audit documents include YAML frontmatter (with
doc_type
set to
audit-index
and
audit-finding
respectively) to facilitate retrieval via
search-yaml.py
.

维度矩阵(交叉分类)

Dimension Matrix (Cross Classification)

每个发现打两个标签:
性质
bug
|
security
|
performance
|
maintainability
|
arch-drift
严重度
P0
(必须修)|
P1
(应该修)|
P2
(可以修)
交叉示例:
  • security
    ×
    P0
    :SQL 注入、明文存密码
  • bug
    ×
    P1
    :特定边界条件下空指针,实际触发概率低
  • performance
    ×
    P2
    :循环内多余的对象分配,热点路径才需要改
另外每个发现带 置信度
high
/
medium
/
low
)和建议动作
cs-issue
/
cs-refactor
)。
完整模板见
reference.md

Each finding is tagged with two labels:
Nature:
bug
|
security
|
performance
|
maintainability
|
arch-drift
Severity:
P0
(Must fix) |
P1
(Should fix) |
P2
(Could fix)
Cross examples:
  • security
    ×
    P0
    : SQL injection, storing passwords in plaintext
  • bug
    ×
    P1
    : Null pointer under specific boundary conditions, with low actual trigger probability
  • performance
    ×
    P2
    : Redundant object allocation in loops, only needs modification in hot paths
Additionally, each finding includes confidence level (
high
/
medium
/
low
) and suggested action (
cs-issue
/
cs-refactor
).
See
reference.md
for the complete template.

工作流

Workflow

Phase 1:范围收敛

Phase 1: Scope Convergence

审计不能全仓库盲扫——成本高、噪音大。先帮用户把范围收窄到可执行。
问用户三样(有一样就能起步):
  1. 关键词:"跟 auth / payment / upload 相关的"
  2. 模块 / 目录:"
    src/services/
    下面"
  3. 一段话描述:"最近用户反馈订单页慢,帮我扫一下订单相关代码"
用户描述已清楚直接进 Phase 2。用户说"整个项目都扫" → 推回去——建议先扫最常改的模块或最近出过问题的区域。
收敛后给用户确认:"扫
src/services/order/
src/api/order.ts
,约 12 个文件,看安全 / 性能 / bug 隐患三个维度。范围 OK 吗?"
Blind 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):
  1. Keywords: "Related to auth / payment / upload"
  2. Module / Directory: "Under
    src/services/
    "
  3. 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
src/services/order/
and
src/api/order.ts
, approximately 12 files, covering three dimensions: security / performance / bug risks. Is the scope OK?"

Phase 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
    codestable/architecture/
    , layer leakage, implicit cross-module coupling
Use Glob / Grep / Read to actually read the code during scanning. Each finding must record
file:line number
+ specific code snippet.
Upper 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:
  • high
    : The code path can be confirmed to trigger, with clear impact
  • medium
    : The issue can be located via static analysis, but the trigger conditions are uncertain
  • low
    : Suspicious clues, need further confirmation but worth marking

Phase 3:定级 + 产出

Phase 3: Rating + Output

  1. 每个发现打性质 + 严重度 + 置信度 + 建议动作
  2. index.md
    :范围、总评、发现清单表格(交叉分类)
  3. 逐条写
    finding-NN.md
先写 index 再写 finding——这个顺序让 AI 先做整体判断再展开细节,避免陷入单条发现迷失全局。
  1. Tag each finding with nature + severity + confidence level + suggested action
  2. Write
    index.md
    : scope, overall assessment, findings list table (cross-classified)
  3. Write
    finding-NN.md
    one by one
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-issue
cs-refactor
cs-audit
自己不修。

At 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
cs-issue
or
cs-refactor
.
cs-audit
does not fix issues itself.

与相邻技能的边界

Boundaries with Adjacent Skills

技能触发cs-audit 怎么对待
cs-issue
用户报已知 bugaudit 发现 bug 后建议开
cs-issue
cs-refactor
用户指已知优化点audit 发现可优化点后建议开
cs-refactor
cs-explore
围绕一个问题查代码audit 是批量扫多个维度,不等同于 explore
cs-arch
维护架构文档cs-arch 维护文档,cs-audit 检查代码是否偏离文档
cs-security-review
安全审查audit 的安全维度是轻量扫描,深度安全审查走专项

SkillTriggerHow cs-audit Handles It
cs-issue
User reports a known bugAfter identifying a bug during audit, suggest creating a
cs-issue
cs-refactor
User points out a known optimization pointAfter identifying an optimization point during audit, suggest creating a
cs-refactor
cs-explore
Investigate code around a specific questionAudit involves batch scanning across multiple dimensions, which is not equivalent to explore
cs-arch
Maintain architecture documentscs-arch maintains documents, while cs-audit checks if code deviates from documents
cs-security-review
Security reviewThe 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: superseded
    +
    superseded-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: superseded
    +
    superseded-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

  • reference.md
    — index.md / finding-NN.md 模板
  • codestable/reference/shared-conventions.md
    — 跨工作流共享口径
  • codestable/architecture/
    — 架构偏离类发现对照源
  • reference.md
    — Template for index.md / finding-NN.md
  • codestable/reference/shared-conventions.md
    — Shared standards across workflows
  • codestable/architecture/
    — Reference source for architecture drift findings