scan

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Codebase Scan

代码库扫描

Audit the codebase against another skill's criteria using a parallel agent team.
使用并行Agent团队,对照另一项Skill的标准审计代码库。

Workflow

工作流程

1. Parse args & load skill

1. 解析参数并加载Skill

Extract the skill name from the args passed to this skill.
  • If no skill name provided, list available skills in
    .claude/skills/
    and ask the user which to scan against.
  • If skill doesn't exist, list available skills and tell the user.
  • Read
    .claude/skills/<name>/SKILL.md
    plus any files in
    references/
    and
    rules/
    subdirectories.
  • Distill the skill's content into a numbered criteria checklist: a flat list of concrete, testable rules labeled C1, C2, C3, etc. Each criterion should be a single sentence describing what to check for.
  • If the skill has no evaluable code criteria (e.g., workflow-only skills like
    why
    that don't define code patterns or rules), tell the user it's not scannable and stop.
从传递给本Skill的参数中提取Skill名称。
  • 如果未提供Skill名称,列出
    .claude/skills/
    目录下的可用Skill,并询问用户要对照哪项进行扫描。
  • 如果指定的Skill不存在,列出可用Skill并告知用户。
  • 读取
    .claude/skills/<名称>/SKILL.md
    文件,以及
    references/
    rules/
    子目录下的所有文件。
  • 将Skill的内容提炼为编号的标准检查清单:一份扁平化的具体可测试规则列表,标记为C1、C2、C3等。每条标准应为描述检查内容的单句。
  • 如果该Skill没有可评估的代码标准(例如像
    why
    这类仅涉及工作流、未定义代码模式或规则的Skill),告知用户该Skill不可扫描并终止流程。

2. Discover relevant files

2. 发现相关文件

Use the skill's criteria to infer file scope:
  • React/frontend criteria →
    app/**/*.tsx
    ,
    app/**/*.ts
  • Backend criteria →
    services/**/*.ts
  • General/mixed → both of the above
  • CSS/styling →
    app/**/*.css
    ,
    app/**/*.tsx
Always exclude:
node_modules/
,
dist/
,
*.test.*
,
*.spec.*
,
**/migrations/**
,
**/*.d.ts
, generated files.
Count candidate files. If zero, tell the user and stop.
根据Skill的标准推断文件范围:
  • React/前端标准 →
    app/**/*.tsx
    ,
    app/**/*.ts
  • 后端标准 →
    services/**/*.ts
  • 通用/混合标准 → 上述两者
  • CSS/样式标准 →
    app/**/*.css
    ,
    app/**/*.tsx
始终排除:
node_modules/
,
dist/
,
*.test.*
,
*.spec.*
,
**/migrations/**
,
**/*.d.ts
以及生成的文件。
统计候选文件数量。如果数量为0,告知用户并终止流程。

3. Plan team composition

3. 规划团队组成

Split files into chunks by directory subtree so no file is assigned to two agents:
Candidate filesTeammates
< 1002 (or skip team for < 20)
100–5003
500+4–5, split by top-level directory
For very small scans (< 20 files), skip the team — scan inline and jump to step 6.
按目录子树将文件拆分为多个区块,确保没有文件被分配给多个Agent:
候选文件数量团队成员数
< 1002个(若少于20个文件则可跳过团队)
100–5003个
500+4–5个,按顶层目录拆分
对于非常小的扫描任务(少于20个文件),跳过团队组建——直接进行内联扫描并跳至步骤6。

4. Spawn scan team

4. 启动扫描团队

  1. spawnTeam
    with name
    scan-<skill-name>
  2. Create one
    TaskCreate
    per chunk with:
    • Subject:
      Scan <directory-area> against <skill-name> criteria
    • Description: Include the full criteria checklist, the file scope (glob patterns), and the teammate instructions from
      references/teammate-instructions.md
  3. Spawn teammates as
    general-purpose
    subagent_type (they need Read, Glob, Grep + team communication)
  4. Name teammates
    scanner-1
    ,
    scanner-2
    , etc.
  5. Assign tasks via
    TaskUpdate
    with
    owner
  1. 调用
    spawnTeam
    创建名为
    scan-<skill名称>
    的团队
  2. 为每个区块创建一个
    TaskCreate
    任务:
    • 主题:
      扫描<目录区域>以对照<skill名称>标准
    • 描述:包含完整的标准检查清单、文件范围(glob模式)以及
      references/teammate-instructions.md
      中的团队成员说明
  3. general-purpose
    子代理类型启动团队成员(他们需要具备Read、Glob、Grep权限以及团队通信能力)
  4. 为团队成员命名为
    scanner-1
    scanner-2
  5. 通过
    TaskUpdate
    为任务分配
    owner
    (负责人)

5. Collect & synthesize

5. 收集与整合

Wait for all teammates to complete their tasks. Each teammate reports findings in structured format:
FINDING: C<n> | SEVERITY | file/path.ts:LINE | Description
Collect all findings from teammate messages.
等待所有团队成员完成任务。每个成员需以结构化格式报告发现的问题:
FINDING: C<n> | 严重程度 | file/path.ts:行号 | 描述
从团队成员的消息中收集所有发现的问题。

6. Generate report

6. 生成报告

Create
.claude-scan/<skill-name>.md
using the format in
references/report-format.md
.
Key sections:
  • Executive Summary (2-3 sentences)
  • Criteria Evaluated (table with violation counts)
  • Findings by Severity (Critical → Warning → Info tables)
  • Patterns Observed
  • Statistics
  • Recommended Fix Order (batched by non-overlapping file groups)
使用
references/report-format.md
中的格式创建
.claude-scan/<skill名称>.md
文件。
关键章节:
  • 执行摘要(2-3句话)
  • 已评估的标准(包含违规次数的表格)
  • 按严重程度分类的发现问题(从严重→警告→信息的表格)
  • 观察到的模式
  • 统计数据
  • 推荐修复顺序(按不重叠的文件组批量划分)

7. Cleanup & present

7. 清理与展示

  • If a team was spawned: send
    shutdown_request
    to all teammates, then
    cleanup
  • Display inline summary: total findings by severity, top violated criteria, scan scope
  • Tell the user the full report is at
    .claude-scan/<skill-name>.md
  • Ask: "Want me to spawn a fix team to address these findings?"
  • 如果启动了团队:向所有团队成员发送
    shutdown_request
    ,然后执行
    cleanup
    操作
  • 展示内联摘要:按严重程度统计的总问题数、违规最多的标准、扫描范围
  • 告知用户完整报告位于
    .claude-scan/<skill名称>.md
  • 询问:“是否需要我启动修复团队来解决这些问题?”

8. Fix team (if user says yes)

8. 修复团队(若用户同意)

  1. Read the report's "Recommended Fix Order" section
  2. Group fixes into non-overlapping file batches
  3. spawnTeam
    with name
    fix-<skill-name>
  4. Create tasks per batch — each task description includes:
    • The specific violations to fix (from the report)
    • The relevant criteria definitions
    • Instructions from
      references/fix-team-instructions.md
  5. Spawn
    general-purpose
    teammates named
    fixer-1
    ,
    fixer-2
    , etc. (need Edit/Write)
  6. Assign tasks and wait for completion
  7. Shutdown and cleanup fix team
  8. Ask user if they want to re-scan to verify fixes
  1. 读取报告中的“推荐修复顺序”章节
  2. 将修复任务按不重叠的文件组进行分组
  3. 调用
    spawnTeam
    创建名为
    fix-<skill名称>
    的团队
  4. 为每个批次创建任务——每个任务描述包含:
    • 需修复的具体违规问题(来自报告)
    • 相关的标准定义
    • references/fix-team-instructions.md
      中的说明
  5. general-purpose
    类型启动名为
    fixer-1
    fixer-2
    等的团队成员(需要具备Edit/Write权限)
  6. 分配任务并等待完成
  7. 关闭并清理修复团队
  8. 询问用户是否要重新扫描以验证修复效果