afc-review
Code review — review code, analyze PR diff, evaluate quality and correctness
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Code review — review code, analyze PR diff, evaluate quality and correctness
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Code and component analysis — analyze code, trace flows, audit consistency, inspect components
Architecture analysis and design review
Full auto pipeline — run spec-to-clean cycle automatically for new features
Save session state for later resumption
Resolve spec ambiguities with clarifying questions
Pipeline artifact cleanup and codebase hygiene
| name | afc:review |
| description | Code review — review code, analyze PR diff, evaluate quality and correctness |
| argument-hint | [scope: file path, PR number, or staged] |
| allowed-tools | ["Read","Write","Grep","Glob","Bash","Task","LSP"] |
| model | sonnet |
Performs a comprehensive review of changed code (quality, security, performance, architecture compliance). Validates completeness of the review itself with convergence-based Critic Loop.
$ARGUMENTS — (optional) Review scope (file path, PR number, or "staged")
git diff of current branch (unstaged + staged)!cat .claude/afc.config.md 2>/dev/null || echo "[CONFIG NOT FOUND] .claude/afc.config.md not found. Create it with /afc:init."
Always read .claude/afc.config.md first — needed for CI Commands (YAML).
Architecture, Code Style, and Project Context are auto-loaded via .claude/rules/afc-project.md.
If config file is missing:
.claude/afc.config.md not found. Run /afc:init?"/afc:init, then restart with original $ARGUMENTS$ARGUMENTS = file path → that file only$ARGUMENTS = PR number → gh pr diff {number}$ARGUMENTS = "staged" → git diff --cachedgit diff HEAD.claude/afc/specs/{feature}/context.md and spec.md. If neither exists, skip SPEC_ALIGNMENT with note "no spec artifacts available"Assess complexity holistically: total diff size, file complexity, change diversity, and whether changes are localized or cross-cutting.
Pre-scan for parallel batch / swarm: Before distributing files, collect cross-boundary context — outbound calls between changed files with function signature + 1-line side-effect summary. Include Impact Map. Provide each agent a ## Cross-File Context block. Skip pre-scan for Direct mode.
| Mode | When to use | How |
|---|---|---|
| Direct | Small diff, single module, fits in context | Review all files in current context |
| Parallel batch | Multiple files/modules, substantial diff | 2–3 files per agent, single message |
| Swarm | Large-scale, cross-cutting, mixed types | Pre-assigned workers (≤5), single message |
// Parallel batch example
Task("Review: {file1, file2}", subagent_type: "general-purpose")
Task("Review: {file3, file4}", subagent_type: "general-purpose")
Note: Unlike implement swarm (prohibits self-claiming due to write conflicts), review workers use orchestrator pre-assignment. This is safe — review is read-only.
Collect all worker outputs, then write consolidated review.
When afc-architect and afc-security agents are available, delegate perspectives B and C in a single message:
Task("Architecture Review", subagent_type: "afc:afc-architect",
prompt: "Review changed files for architecture compliance. Files: {list}. Rules: {config.architecture}. Return: severity, file:line, issue, fix.")
Task("Security Review", subagent_type: "afc:afc-security",
prompt: "Scan changed files for security vulnerabilities. Files: {list}. Return: severity, file:line, issue, fix.")
Merge agent findings into the consolidated review (Step 4). If agents unavailable: fall back to direct review for B and C.
Review each changed file across all 8 perspectives. See perspectives.md for full criteria.
| Perspective | Focus |
|---|---|
| A. Code Quality | {config.code_style} compliance, naming, duplication, complexity |
| B. Architecture | Layer dependency direction, segment rules, placement (agent-enhanced) |
| C. Security | XSS, sensitive data exposure, injection (agent-enhanced) |
| D. Performance | Latency, redundant computation, resource management |
| E. Project Pattern | {config.code_style} + {config.architecture} conventions, framework idioms |
| F. Reusability | DRY adherence, extraction opportunities, abstraction level |
| G. Maintainability | Unit comprehensibility, naming clarity, self-contained files |
| H. Extensibility | Extension points, Open/Closed principle, future modification cost |
After reviews complete, the orchestrator MUST verify behavioral findings across file boundaries. See Cross-Boundary Verification for the full procedure.
## Code Review Results
### Summary
| Severity | Count | Items |
|----------|-------|-------|
| Critical | {N} | {summary} |
| Warning | {N} | {summary} |
| Info | {N} | {summary} |
### Impact Analysis
| Changed File | Affected Files | Method |
|---|---|---|
| {path} | {affected file list} | LSP / Grep |
> ⚠ Dynamic dependencies (runtime dispatch, reflection, cross-language calls) require manual verification.
### Detailed Findings
#### C-{N}: {title}
- **File**: {path}:{line}
- **Issue**: {description}
- **Suggested fix**: {code example}
#### W-{N}: {title} #### I-{N}: {title}
{same format}
### Positives
- {1-2 things done well}
If .claude/afc/memory/retrospectives/ exists, load the most recent 10 files (sorted descending) and check:
Always read
docs/critic-loop-rules.mdfirst and follow it. Safety cap: 5 passes.
| Criterion | Validation |
|---|---|
| COMPLETENESS | All changed files reviewed? All perspectives A–H covered? |
| SPEC_ALIGNMENT | Every SC satisfied ({M}/{N} SC verified), every GWT scenario has a code path, no spec constraint violated |
| SIDE_EFFECT_AWARENESS | Behavioral findings (call order, error handling, state mutation) verified against callee implementations. Unverified Critical → auto-downgrade to Info with note. Report {M}/{N} behavioral findings verified |
| PRECISION | Findings are actual issues, not false positives |
On FAIL: auto-fix and continue. On ESCALATE: pause, present options, resume. On DEFER: record, mark clean. On CONVERGE: ✓ Critic converged ({N} passes, {M} fixes, {E} escalations). On SAFETY CAP: ⚠ Critic safety cap ({N} passes). Review recommended.
Append to .claude/afc/memory/retrospectives/{YYYY-MM-DD}.md only when a pattern is new and actionable:
## Pattern: {category}
**What happened**: {concrete description}
**Root cause**: {why this keeps occurring}
**Prevention rule**: {actionable rule}
**Severity**: Critical | Warning
When inside a pipeline (.claude/afc/specs/{feature}/ exists):
.claude/afc/specs/{feature}/review-report.md with metadata header (date, files reviewed, finding counts).claude/afc/memory/reviews/{feature}-{date}.md)Standalone run: display results in console only.
Review complete
├─ Files: {changed file count}
├─ Found: Critical {N} / Warning {N} / Info {N}
├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
└─ Conclusion: {one-line summary}
afc.config.md standards, not personal preference.run_in_background: true on Task calls: review agents must return results before consolidation.