scan
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodebase 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 and ask the user which to scan against.
.claude/skills/ - If skill doesn't exist, list available skills and tell the user.
- Read plus any files in
.claude/skills/<name>/SKILL.mdandreferences/subdirectories.rules/ - 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 that don't define code patterns or rules), tell the user it's not scannable and stop.
why
从传递给本Skill的参数中提取Skill名称。
- 如果未提供Skill名称,列出目录下的可用Skill,并询问用户要对照哪项进行扫描。
.claude/skills/ - 如果指定的Skill不存在,列出可用Skill并告知用户。
- 读取文件,以及
.claude/skills/<名称>/SKILL.md和references/子目录下的所有文件。rules/ - 将Skill的内容提炼为编号的标准检查清单:一份扁平化的具体可测试规则列表,标记为C1、C2、C3等。每条标准应为描述检查内容的单句。
- 如果该Skill没有可评估的代码标准(例如像这类仅涉及工作流、未定义代码模式或规则的Skill),告知用户该Skill不可扫描并终止流程。
why
2. Discover relevant files
2. 发现相关文件
Use the skill's criteria to infer file scope:
- React/frontend criteria → ,
app/**/*.tsxapp/**/*.ts - Backend criteria →
services/**/*.ts - General/mixed → both of the above
- CSS/styling → ,
app/**/*.cssapp/**/*.tsx
Always exclude: , , , , , , generated files.
node_modules/dist/*.test.**.spec.***/migrations/****/*.d.tsCount candidate files. If zero, tell the user and stop.
根据Skill的标准推断文件范围:
- React/前端标准 → ,
app/**/*.tsxapp/**/*.ts - 后端标准 →
services/**/*.ts - 通用/混合标准 → 上述两者
- CSS/样式标准 → ,
app/**/*.cssapp/**/*.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 files | Teammates |
|---|---|
| < 100 | 2 (or skip team for < 20) |
| 100–500 | 3 |
| 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:
| 候选文件数量 | 团队成员数 |
|---|---|
| < 100 | 2个(若少于20个文件则可跳过团队) |
| 100–500 | 3个 |
| 500+ | 4–5个,按顶层目录拆分 |
对于非常小的扫描任务(少于20个文件),跳过团队组建——直接进行内联扫描并跳至步骤6。
4. Spawn scan team
4. 启动扫描团队
- with name
spawnTeamscan-<skill-name> - Create one per chunk with:
TaskCreate- 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
- Subject:
- Spawn teammates as subagent_type (they need Read, Glob, Grep + team communication)
general-purpose - Name teammates ,
scanner-1, etc.scanner-2 - Assign tasks via with
TaskUpdateowner
- 调用创建名为
spawnTeam的团队scan-<skill名称> - 为每个区块创建一个任务:
TaskCreate- 主题:
扫描<目录区域>以对照<skill名称>标准 - 描述:包含完整的标准检查清单、文件范围(glob模式)以及中的团队成员说明
references/teammate-instructions.md
- 主题:
- 以子代理类型启动团队成员(他们需要具备Read、Glob、Grep权限以及团队通信能力)
general-purpose - 为团队成员命名为、
scanner-1等scanner-2 - 通过为任务分配
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 | DescriptionCollect all findings from teammate messages.
等待所有团队成员完成任务。每个成员需以结构化格式报告发现的问题:
FINDING: C<n> | 严重程度 | file/path.ts:行号 | 描述从团队成员的消息中收集所有发现的问题。
6. Generate report
6. 生成报告
Create using the format in .
.claude-scan/<skill-name>.mdreferences/report-format.mdKey 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 to all teammates, then
shutdown_requestcleanup - 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. 修复团队(若用户同意)
- Read the report's "Recommended Fix Order" section
- Group fixes into non-overlapping file batches
- with name
spawnTeamfix-<skill-name> - 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
- Spawn teammates named
general-purpose,fixer-1, etc. (need Edit/Write)fixer-2 - Assign tasks and wait for completion
- Shutdown and cleanup fix team
- Ask user if they want to re-scan to verify fixes
- 读取报告中的“推荐修复顺序”章节
- 将修复任务按不重叠的文件组进行分组
- 调用创建名为
spawnTeam的团队fix-<skill名称> - 为每个批次创建任务——每个任务描述包含:
- 需修复的具体违规问题(来自报告)
- 相关的标准定义
- 中的说明
references/fix-team-instructions.md
- 以类型启动名为
general-purpose、fixer-1等的团队成员(需要具备Edit/Write权限)fixer-2 - 分配任务并等待完成
- 关闭并清理修复团队
- 询问用户是否要重新扫描以验证修复效果