Code Review Skill
Purpose
Comprehensive code quality assessment and verification.
When Active
User uses /review, asks for code review, or before committing code.
Expertise
Review Process
- Scope resolution (before git diff):
- If user provided file paths, component name, or
--files list → explicit scope: use those directly, skip git diff
- Otherwise → implicit scope: identify changed files via
git diff or git log
- Read the plan file if one exists — understand requirements before reviewing
- Systematic review: structure, logic, types, performance, security
- Categorize findings: Critical > High > Medium > Low
- Update plan TODO status if plan exists
Systematic Review
All code review rules are defined in references/code-review-standards.md with numbered IDs, severity, and pass/fail criteria.
| Category |
Human Name |
Rules |
Scope |
| SEC |
Security |
SEC-001..008 |
OWASP Top 10, credentials, injection, auth |
| PERF |
Performance |
PERF-001..006 |
N+1, renders, caching, bundle |
| TS |
Type Safety |
TS-001..006 |
Unsafe any, casts, guards, generics |
| LOGIC |
Logic & Correctness |
LOGIC-001..006 |
Null handling, edge cases, race conditions |
| DEAD |
Dead Code |
DEAD-001..003 |
Unreachable, unused, orphaned |
| ARCH |
Architecture |
ARCH-001..005 |
File org, boundaries, circular deps, layers |
| STATE |
State Management |
STATE-001..004 |
Completeness, exits, guards, concurrency |
Severity Classification
- Critical: Security vulnerabilities, data loss, breaking changes
- High: Performance issues, type safety violations, missing error handling
- Medium: Code smells, maintainability issues, documentation gaps
- Low: Style inconsistencies, minor optimizations
Escalation Gate (Reviewer Decision)
After initial review, the reviewer decides based on findings:
| Finding |
Action |
| Critical severity found |
Escalate to /audit --code — activate knowledge-retrieval for deeper context before reporting |
| Task is UI code review/audit (components, tokens, design system) |
Delegate to epost-muji — runs /audit --ui with klara-theme standards + INTEGRITY gate |
| Task is about a11y (accessibility, WCAG, VoiceOver, TalkBack, keyboard nav, screen reader) |
Delegate to epost-a11y-specialist — runs /audit --a11y with full WCAG 2.1 AA rules |
| High severity, UI component finding |
Escalate to /audit --ui → epost-muji for full component audit |
| High severity, a11y issue |
Escalate to /audit --a11y — a11y specialist audits with WCAG rules |
| Medium/Low only |
Complete inline, no escalation needed |
Rule: Code review is lightweight by default (no knowledge-retrieval). Escalate to audit only when findings warrant it. Audit always activates knowledge-retrieval.
Lightweight vs. Escalated Review Scope
| Category |
Lightweight (default) |
Escalated (knowledge-retrieval active) |
| ARCH |
ARCH-001..003 (file org, boundaries, circular deps) |
+ ARCH-004..005 (layer violations, dependency direction) |
| LOGIC |
LOGIC-001..003 (null handling, edge cases, error paths) |
+ LOGIC-004..006 (race conditions, off-by-one, comparison) |
| STATE |
STATE-001..002 (completeness, exit states) |
+ STATE-003..004 (transition guards, concurrent mutations) |
| TS |
TS-001..003 (unsafe any, unvalidated cast, missing guard) |
+ TS-004..006 (generic constraints, non-null assertions, strict null) |
| PERF |
PERF-001..003 (N+1, re-renders, loops) |
+ PERF-004..006 (caching, bundle, lazy loading) |
| SEC |
SEC-001..004 (injection, XSS, secrets, auth) |
+ SEC-005..008 (input validation, SSRF, deserialization, data logging) |
| Tests |
Test file exists, covers changed code |
+ coverage gap analysis, edge case completeness |
| Standards source |
code-review-standards.md only |
+ docs/ conventions, RAG patterns |
Rule: Lightweight review does NOT load knowledge-retrieval. Only categories in the "Lightweight" column are checked. If a Critical finding is detected, escalate to the full column.
Subagent Constraint
Code-reviewer runs as a subagent (spawned via Agent tool). Subagents cannot spawn further subagents. Therefore:
- Code-reviewer does NOT dispatch muji, a11y-specialist, or any other agent
- Hybrid orchestration (muji + code-reviewer) is handled by the main context via
audit/SKILL.md
- Code-reviewer is a pure reviewer: reads files, applies rules, writes report
When Invoked with Muji Report
If the caller provides a muji report path (hybrid audit):
- Read muji report at the provided path
- Extract
finding_locations: Set of file:line already flagged by muji
- Run SEC/PERF/TS/ARCH/STATE/LOGIC/DEAD rules on the same files
- Dedup: skip any file:line already in muji's finding set
- Write report to the provided
output_path
Critical Escalation (self-dispatch, no Agent tool needed)
When a Critical finding is detected during review:
- Load
knowledge-retrieval skill (already in agent skills list)
- Execute: L1 docs/ → L2 RAG → L4 Grep fallback
- Document KB layers used in Methodology
- Re-examine files with retrieved context; update findings
RAG Lookup (when reviewing)
ToolSearch("web-rag") → discover mcp__web-rag-system__* tools
- Call
status → confirm available
- Call
query with module + "prior findings security architecture"
- If unavailable: fallback to Grep on
reports/ for prior audit files
- Append "L2-RAG" or "L2-RAG-unavailable" to methodology
Post-Delegation Report Merging
After specialist reports arrive:
- Read the specialist's Markdown report
- Add a delegation section to your report: agent name, report path, verdict, finding count
- Adjust your overall verdict: if specialist found Critical → your verdict cannot be APPROVE
- List specialist report paths in the report's Related Documents section
Report consolidation: After all specialist reports are merged into your report, the final deliverable is YOUR single report file. Sub-agent reports are source material — do not surface them as separate deliverables to the user unless explicitly requested.
Write session.json (always — after writing report.md)
Write {session_folder}/session.json per audit/references/session-json-schema.md:
- Inline review:
type: "code-review", agents: [{name: "epost-code-reviewer", report: "report.md", verdict, findings}]
- Hybrid:
type: "hybrid-audit", include all participating agents with their verdicts and counts
Persist Findings (always — after writing report)
Ownership per audit/references/output-contract.md: code-reviewer → .epost-data/code/, muji → .epost-data/ui/, a11y → .epost-data/a11y/.
Persist SEC/PERF/TS/LOGIC/DEAD/ARCH/STATE findings (critical, high, medium) to .epost-data/code/known-findings.json:
- Check if
.epost-data/code/known-findings.json exists
- If not:
mkdir -p .epost-data/code/ then create it with { "schemaVersion": "1.0.0", "lastUpdated": "{today}", "findings": [] }
- Pre-scan for regressions: for each finding in current pass, check if same
rule_id + file_pattern exists with resolved: true → flag regression: true in report; with resolved: false → reference existing id, do not duplicate
- For each NEW finding (severity critical/high/medium) not already open in DB:
- Auto-increment
id from max(existing_ids) + 1 (start at 1 for empty)
- Map:
module, rule_id, category (SEC/PERF/TS/LOGIC/DEAD/ARCH/STATE), title, file_pattern, code_pattern, fix_template, priority, severity, source (hybrid-audit or code-review), source_agent: "epost-code-reviewer", source_report: "{report_path}", first_detected_at: "{YYYY-MM-DDTHH:MM}"
- Append to
findings[]
- Save updated JSON
- Log: "Persisted {N} code findings to
.epost-data/code/known-findings.json" in Methodology
Schema: code-review/references/code-known-findings-schema.md
Output Format
Use references/report-template.md for all code review reports.
Key requirements:
- Session folder: All output paths per
audit/references/output-contract.md. mkdir -p before any write.
- One main report per session —
report.md is the single surface for the user. Sub-agent .md files are source material.
- Header: Date, Agent, Plan (if applicable), Status
- Executive Summary first
- Methodology section (required): docs loaded, KB layers used, tools used, files scanned, coverage gaps
- Delegation Log section (required if delegation occurred): agent, scope, template, verdict, finding count
- Findings table with ID, Severity, File:Line, Issue, Fix
- Verdict:
APPROVE | FIX-AND-RESUBMIT | REDESIGN
- Unresolved questions footer always present
Related Skills
knowledge-retrieval — activated on Critical escalation
knowledge-capture — use after task to persist learnings
auto-improvement — session metrics and improvement trends
1---2name: code-review-803description: (ePost) Use when reviewing code, checking quality before commit, or auditing changed files for issues4---5
6# Code Review Skill
7
8## Purpose
9Comprehensive code quality assessment and verification.
10
11## When Active
12User uses /review, asks for code review, or before committing code.
13
14## Expertise
15
16### Review Process
171. Scope resolution (before git diff):
18 - If user provided file paths, component name, or `--files` list → **explicit scope**: use those directly, skip git diff
19 - Otherwise → **implicit scope**: identify changed files via `git diff` or `git log`
202. Read the plan file if one exists — understand requirements before reviewing
213. Systematic review: structure, logic, types, performance, security
224. Categorize findings: Critical > High > Medium > Low
235. Update plan TODO status if plan exists
24
25### Systematic Review
26
27All code review rules are defined in `references/code-review-standards.md` with numbered IDs, severity, and pass/fail criteria.
28
29| Category | Human Name | Rules | Scope |
30|----------|-----------|-------|-------|
31| SEC | Security | SEC-001..008 | OWASP Top 10, credentials, injection, auth |
32| PERF | Performance | PERF-001..006 | N+1, renders, caching, bundle |
33| TS | Type Safety | TS-001..006 | Unsafe any, casts, guards, generics |
34| LOGIC | Logic & Correctness | LOGIC-001..006 | Null handling, edge cases, race conditions |
35| DEAD | Dead Code | DEAD-001..003 | Unreachable, unused, orphaned |
36| ARCH | Architecture | ARCH-001..005 | File org, boundaries, circular deps, layers |
37| STATE | State Management | STATE-001..004 | Completeness, exits, guards, concurrency |
38
39### Severity Classification
40- **Critical**: Security vulnerabilities, data loss, breaking changes
41- **High**: Performance issues, type safety violations, missing error handling
42- **Medium**: Code smells, maintainability issues, documentation gaps
43- **Low**: Style inconsistencies, minor optimizations
44
45### Escalation Gate (Reviewer Decision)
46
47After initial review, the reviewer decides based on findings:
48
49| Finding | Action |
50|---------|--------|
51| Critical severity found | Escalate to `/audit --code` — activate `knowledge-retrieval` for deeper context before reporting |
52| Task is UI code review/audit (components, tokens, design system) | Delegate to **epost-muji** — runs `/audit --ui` with klara-theme standards + INTEGRITY gate |
53| Task is about a11y (accessibility, WCAG, VoiceOver, TalkBack, keyboard nav, screen reader) | Delegate to **epost-a11y-specialist** — runs `/audit --a11y` with full WCAG 2.1 AA rules |
54| High severity, UI component finding | Escalate to `/audit --ui` → **epost-muji** for full component audit |
55| High severity, a11y issue | Escalate to `/audit --a11y` — a11y specialist audits with WCAG rules |
56| Medium/Low only | Complete inline, no escalation needed |
57
58**Rule**: Code review is lightweight by default (no `knowledge-retrieval`). Escalate to audit only when findings warrant it. Audit always activates `knowledge-retrieval`.
59
60### Lightweight vs. Escalated Review Scope
61
62| Category | Lightweight (default) | Escalated (knowledge-retrieval active) |
63|----------|-----------------------|---------------------------------------|
64| ARCH | ARCH-001..003 (file org, boundaries, circular deps) | + ARCH-004..005 (layer violations, dependency direction) |
65| LOGIC | LOGIC-001..003 (null handling, edge cases, error paths) | + LOGIC-004..006 (race conditions, off-by-one, comparison) |
66| STATE | STATE-001..002 (completeness, exit states) | + STATE-003..004 (transition guards, concurrent mutations) |
67| TS | TS-001..003 (unsafe any, unvalidated cast, missing guard) | + TS-004..006 (generic constraints, non-null assertions, strict null) |
68| PERF | PERF-001..003 (N+1, re-renders, loops) | + PERF-004..006 (caching, bundle, lazy loading) |
69| SEC | SEC-001..004 (injection, XSS, secrets, auth) | + SEC-005..008 (input validation, SSRF, deserialization, data logging) |
70| Tests | Test file exists, covers changed code | + coverage gap analysis, edge case completeness |
71| Standards source | code-review-standards.md only | + docs/ conventions, RAG patterns |
72
73**Rule**: Lightweight review does NOT load knowledge-retrieval. Only categories in the "Lightweight" column are checked. If a Critical finding is detected, escalate to the full column.
74
75### Subagent Constraint
76
77Code-reviewer runs as a **subagent** (spawned via Agent tool). Subagents **cannot spawn further subagents**. Therefore:
78- Code-reviewer does NOT dispatch muji, a11y-specialist, or any other agent
79- Hybrid orchestration (muji + code-reviewer) is handled by the **main context** via `audit/SKILL.md`
80- Code-reviewer is a pure reviewer: reads files, applies rules, writes report
81
82### When Invoked with Muji Report
83
84If the caller provides a muji report path (hybrid audit):
851. Read muji report at the provided path
862. Extract `finding_locations`: Set of file:line already flagged by muji
873. Run SEC/PERF/TS/ARCH/STATE/LOGIC/DEAD rules on the same files
884. **Dedup**: skip any file:line already in muji's finding set
895. Write report to the provided `output_path`
90
91### Critical Escalation (self-dispatch, no Agent tool needed)
92
93When a Critical finding is detected during review:
941. Load `knowledge-retrieval` skill (already in agent skills list)
952. Execute: L1 docs/ → L2 RAG → L4 Grep fallback
963. Document KB layers used in Methodology
974. Re-examine files with retrieved context; update findings
98
99### RAG Lookup (when reviewing)
100
1011. `ToolSearch("web-rag")` → discover `mcp__web-rag-system__*` tools
1022. Call `status` → confirm available
1033. Call `query` with module + "prior findings security architecture"
1044. If unavailable: fallback to Grep on `reports/` for prior audit files
1055. Append "L2-RAG" or "L2-RAG-unavailable" to methodology
106
107### Post-Delegation Report Merging
108
109After specialist reports arrive:
1101. Read the specialist's Markdown report
1112. Add a delegation section to your report: agent name, report path, verdict, finding count
1123. Adjust your overall verdict: if specialist found Critical → your verdict cannot be APPROVE
1134. List specialist report paths in the report's Related Documents section
114
115**Report consolidation**: After all specialist reports are merged into your report, the final deliverable is YOUR single report file. Sub-agent reports are source material — do not surface them as separate deliverables to the user unless explicitly requested.
116
117## Write session.json (always — after writing report.md)
118
119Write `{session_folder}/session.json` per `audit/references/session-json-schema.md`:
120- Inline review: `type: "code-review"`, `agents: [{name: "epost-code-reviewer", report: "report.md", verdict, findings}]`
121- Hybrid: `type: "hybrid-audit"`, include all participating agents with their verdicts and counts
122
123## Persist Findings (always — after writing report)
124
125Ownership per `audit/references/output-contract.md`: code-reviewer → `.epost-data/code/`, muji → `.epost-data/ui/`, a11y → `.epost-data/a11y/`.
126
127Persist SEC/PERF/TS/LOGIC/DEAD/ARCH/STATE findings (critical, high, medium) to `.epost-data/code/known-findings.json`:
128
1291. Check if `.epost-data/code/known-findings.json` exists
130 - If not: `mkdir -p .epost-data/code/` then create it with `{ "schemaVersion": "1.0.0", "lastUpdated": "{today}", "findings": [] }`
1312. **Pre-scan for regressions**: for each finding in current pass, check if same `rule_id` + `file_pattern` exists with `resolved: true` → flag `regression: true` in report; with `resolved: false` → reference existing `id`, do not duplicate
1323. For each NEW finding (severity critical/high/medium) not already open in DB:
133 - Auto-increment `id` from `max(existing_ids) + 1` (start at 1 for empty)
134 - Map: `module`, `rule_id`, `category` (SEC/PERF/TS/LOGIC/DEAD/ARCH/STATE), `title`, `file_pattern`, `code_pattern`, `fix_template`, `priority`, `severity`, `source` (`hybrid-audit` or `code-review`), `source_agent: "epost-code-reviewer"`, `source_report: "{report_path}"`, `first_detected_at: "{YYYY-MM-DDTHH:MM}"`
135 - Append to `findings[]`
1364. Save updated JSON
1375. Log: "Persisted {N} code findings to `.epost-data/code/known-findings.json`" in Methodology
138
139Schema: `code-review/references/code-known-findings-schema.md`
140
141## Output Format
142
143Use `references/report-template.md` for all code review reports.
144
145Key requirements:
146- **Session folder**: All output paths per `audit/references/output-contract.md`. `mkdir -p` before any write.
147- **One main report per session** — `report.md` is the single surface for the user. Sub-agent `.md` files are source material.
148- Header: Date, Agent, Plan (if applicable), Status
149- Executive Summary first
150- **Methodology** section (required): docs loaded, KB layers used, tools used, files scanned, coverage gaps
151- **Delegation Log** section (required if delegation occurred): agent, scope, template, verdict, finding count
152- Findings table with ID, Severity, File:Line, Issue, Fix
153- Verdict: `APPROVE` | `FIX-AND-RESUBMIT` | `REDESIGN`
154- Unresolved questions footer always present
155
156### Related Skills
157- `knowledge-retrieval` — activated on Critical escalation
158- `knowledge-capture` — use after task to persist learnings
159- `auto-improvement` — session metrics and improvement trends