[Documentation] Use when generating, smart-merging or refactoring the root AI context (CLAUDE.md, AGENTS.md) and its Claude/Codex projections. Config file only: project-config.
The English summary is being prepared. Showing the original description.
[Code Quality] Use when a workflow step or the user asks for code simplification for clarity and maintainability without changing behavior.
The English summary is being prepared. Showing the original description.
See how to installReview the instructions the agent will receive before you install.
<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:END -->[BLOCKING] Execute skill steps in declared order. NEVER skip, reorder, or merge steps without explicit user approval. Inside a workflow run,
/start-workflow→ Workflow-step mode bounds this rule. [BLOCKING] Before each step or sub-skill call, update todo tracking: setin_progresswhen step starts, setcompletedwhen step ends. [BLOCKING] Every completed/skipped step MUST include brief evidence or explicit skip reason. [BLOCKING] If Task tools are unavailable, create and maintain an equivalent step-by-step plan tracker with the same status transitions.
Goal: Lower the cost of the next change — cut coupling, hidden state, duplicated knowledge, unclear intent — by simplifying and refining code for clarity, consistency, and maintainability without altering any observable behavior. — why: every simplification serves future change cost, not aesthetics.
Summary: (read-this-if-nothing-else digest — purpose + every main step)
file:line BEFORE touching anything; apply a simplification ONLY when certain it preserves behavior, never when unsure. — why: an unverified "safe" rewrite silently breaks a downstream consumer./code-quality-review scoped to ONLY those changed files (recursion-safe leaf — NEVER /changes-review); skip + log the reason when nothing changed. Only an explicit --defer=review from a caller that runs a FULL review of the settled state afterwards skips it (see .claude/skills/workflow-review-changes/references/caller-mode.md); no flag means the gate runs. — why: the simplifier rewrites code after the main review batch, so its output ships unreviewed without this gate.--report-only: read-only mode for a caller that owns every fix (e.g. a review skill's simplification dimension or a workflow review barrier) — steps 1–3 only, each finding with file:line + proposed change + behavior-preservation note, no edit of any file, no nested sub-agent, no user question, only the report written; see Report-Only Mode.code-review-rules.md (anti-patterns/checklists) then project-structure-reference.md, both under the reference-docs root (default docs/project-reference; docsRoots.projectReference.path in docs/project-config.json overrides) — before any modification.MANDATORY IMPORTANT MUST ATTENTION Plan task to READ:
code-review-rules.mdunder the reference-docs root (defaultdocs/project-reference;docsRoots.projectReference.pathindocs/project-config.jsonoverrides) — anti-patterns, review checklists (READ FIRST)project-structure-reference.md— project patterns/structureIf not found, search for: project documentation, coding standards, architecture docs.
Workflow:
SYNC:verify-last-order, e.g. a --tests=defer review fix loop), verify statically instead — re-read the diff against the covering tests and run none, the caller's single verify proves themSYNC:review-policy). From Round 2 onward only validated CRITICAL/HIGH/MEDIUM findings reopen the loop, while LOW findings are recorded as deferred and do not justify another cycle. Failed binary gates always block./code-quality-review scoped to ONLY those changed files; skip + log if nothing changed, or when the caller passed --defer=review (record Self-review deferred to caller post-fix FULL review)Key Rules:
node .claude/scripts/ai-signal-scan.cjs): read .claude/skills/shared/protocols/ai-engineering-gate.md; never simplify away a timeout, retry bound, step or cost cap, output validation or approval gate; otherwise skip this line.docs/project-config.json, its referenced project docs, and relevant existing code; treat an explicit N/A or absent stack as a signal to verify the target, not as a missing pattern to invent--report-only)--report-only)Use when a caller needs simplification opportunities as findings without edits — e.g. a review skill running its simplification dimension, a workflow parallel review barrier, or a review batch — and another step owns every fix.
--report-onlyin$ARGUMENTSselects it; without the flag every step applies unchanged.MANDATORY — when
--report-onlyis passed, read.claude/skills/workflow-review-changes/references/caller-mode.mdin full FIRST. It holds the shared caller rules: a--report-onlypass returns one report with no source edits, the caller fixes once and requests fresh passes, and a child never mutates source in parallel or runs a nested loop. The rules below are this skill's own.Review lens in
workflow-review-changes. This mode can serve as the simplification lens inside the review barrier: report the findings, and the review'sfix --target=reviewstep applies the validated simplifications after findings validation.
- Run steps 1–3 only (Phase 0 Detect → Identify Targets → Analyze). Apply, Verify, the Self-Recursive loop, and the Self-Review Gate do not run: edit NO file — source, test, config, or doc. The caller runs its own findings-validation gate and owns every fix and re-review. — why: a simplifier that edits inside a review barrier races the diff every sibling reviewer is reading.
- Every finding carries:
file:line· the simplification dimension · the proposed change (concrete before → after, or the exact edit described) · a behavior-preservation note (the usages and consumers traced — grep/read evidence, plus any graph hint — and why observable behavior stays unchanged) · severity perSYNC:severity-rubric· confidence. A proposal whose behavior preservation cannot be proven is reported asbehavior-change risk, never as a safe simplification. — why: the fixer applies it later without this skill's trace, so the evidence must travel with the finding.- No nested fan-out. Skip the
Agent(subagent_type="code-simplifier", ...)execution path; analyze sequentially in this context.- Report file. Write it to
tmp/reports/code-simplifier-{date}-{slug}.md, appended per file.For this mode the declared step order ends at step 3; stopping there is the mode's contract, not a skipped step.
MUST ATTENTION classify before simplifying — detection drives focus and optional escalation only:
| Artifact Type | Detection | Key Focus |
|---|---|---|
| Source | Target paths and file types identified from project config or user scope | Preserve behavior; apply only responsibilities and conventions evidenced for the relevant code |
| UI/client (if any) | Affected UI paths identified from project config or source | Use configured UI, state, lifecycle, and styling conventions only when present; otherwise follow local evidence |
| Tests | Test paths and runner identified by project config or source | Preserve the assertions, async behavior, isolation, and runner conventions that apply to this project |
| Generated/migration/vendor | Generated markers, configured paths, or vendor/migration directories | SKIP generated, migration, and vendor code |
File extensions and stack-specific names in prompts or examples are search clues, not requirements. Classify the actual target using the project's config, references, and source.
Optional escalation by artifact:
| Artifact | Escalate only when |
|---|---|
| Source code/diffs | Broad review is requested after simplifier loop is clean |
| Security-sensitive | Security-specific risk is present |
| Performance-critical | Performance behavior is part of the change |
| Plans, docs, specs | Artifact review is explicitly requested |
The full gate is
SYNC:core-engineering-principles(protocol guide below; a hook delivers its text); its closing digest ends this file.
Skill focus: favor project-owned boundaries around external libraries (for example component/service input-output contracts) when they localize future library changes; reject pass-through wrappers that add ceremony without lowering change cost.
Skeptical-first: Verify before simplifying. Every change needs proof preserving behavior.
file:line evidence of what was verifiedDimension-based reasoning replaces fixed checklists. Each dimension has a Think: prompt forcing first-principles reasoning.
Think: Would a new engineer understand this in 30 seconds? What forces multiple file traces?
Think: Is the same responsibility repeated, and would a shared abstraction reduce future change cost without hiding intentional differences?
Think: Which module or layer owns this invariant under the project's documented architecture and current call paths?
Think: What is cognitive load? Can nesting/conditionals flatten?
Apply this dimension only when project config/reference docs identify a persistence system or relevant target code proves it is used, and the changed path reads or writes that system. If no database/storage is configured or evidenced in source, or the changed code does not use its query/index model, mark this dimension N/A — reason; do not require paging or indexes for unrelated code.
Think: Can this particular access path exceed its intended bound, and what evidence shows the configured or code-evidenced store needs a different access path?
GetAll, ToList, Find, or Skip/Take are search examples, not defects by themselves.N/A — reason.docs/project-config.json and its configured docs index; load only relevant backend/API, UI/client, test or other references, honoring custom paths and documented N/A.N/A — reason unless config/source confirms a database and the changed path uses its query/index model. UI checks require an evidenced UI surface.Optional: when grep and reading files alone may not reveal a high-risk blast radius (shared contract, many callers, cross-module/cross-service flow, public API), the code graph (.code-graph/graph.db) can add callers, dependents and impacted tests. Treat it as a hint, NOT proof: the graph can be stale or incomplete (it lags uncommitted edits and unindexed paths) — verify anything that matters by reading the files/grep. Skip it for low-risk or local changes.
Before simplifying, trace what depends on the target (grep/read; optionally the graph):
python .claude/scripts/code_graph trace <file> --direction downstream --json
Verify simplified code preserves the interface for every traced consumer. When the changed contract crosses a module, process, or service boundary, trace all consumers configured or found in source; message-bus consumers are one example only when the project uses that boundary.
Additional queries:
python .claude/scripts/code_graph query callers_of <function> --jsonpython .claude/scripts/code_graph query importers_of <module> --jsonpython .claude/scripts/code_graph batch-query file1 file2 --jsonAgent(subagent_type="code-simplifier", prompt="Review and simplify [target files]")
Example:
// Before
function getData() {
const result = fetchData();
if (result !== null && result !== undefined) {
return result;
} else {
return null;
}
}
// After
function getData() {
return fetchData() ?? null;
}
[HARD] §4 rule / §5 invariant intact and MUST NOT delete, relax, or trivialize any property test or mutation test that guards them. If a simplification changes observable behavior, that is NOT a silent change — it is a Dual-Feedback finding (feed the spec AND the tests, then re-review), report it and stop, never ship it. After simplifying, the package MUST still pass the SAME property/mutation bar it passed before — green tests on a weakened bar are not a pass.After applying simplifications, follow the Self-Recursive Simplification Loop below. It owns round closure, deferred LOWs, no-progress/unsafe stops and the subsequent Self-Review Gate. For caller-owned verify-last execution, use the static-verification exception in Workflow Step 5.
This skill is a code MUTATOR. It owns the review of its own output. Once the self-recursive simplification loop above is clean, gate the result:
- Caller deferral.
--defer=reviewin$ARGUMENTSmeans the caller runs a FULL review of the settled whole target after this skill returns (see.claude/skills/workflow-review-changes/references/caller-mode.md). Skip steps 1–3, recordSelf-review deferred to caller post-fix FULL review, and return the exact list of files this skill changed so that review covers them. Without the flag — including a bare invocation by another skill — run the gate.- Did this skill modify any files? Determine the exact set of files this skill changed (its own edits — not the whole working tree).
- No files changed → SKIP this gate and log the skip reason ("code-simplifier made no changes — no self-review needed"). Done.
- Files changed → continue.
- Self-invoke
/code-quality-reviewscoped to ONLY the changed files. Pass the explicit changed-file set as the review target — not the full diff, not unrelated files.- Integrate the
/code-quality-reviewfindings. If it surfaces blocking issues caused by the simplification, fix them (behavior-preserving only) and re-run the self-recursive loop + this gate. If issues are out of simplification scope, report them up — do not silently drop.Recursion safety:
/code-quality-reviewis a LEAF review skill — it does NOT invoke/code-simplifierback, so there is no cycle. Use/code-quality-reviewhere, NEVER/workflow-review-changes(its sequence contains acode-simplifierstep and would recurse) or/changes-review(a full-diff review heavier than this file-scoped gate needs).Why this gate exists:
/code-simplifierrewrites code after the main review batch has already run. Without this gate, the simplifier's output would ship unreviewed. This gate moves that review responsibility into the mutator itself — so theworkflow-review-changesworkflow no longer needs a separate/code-quality-reviewstep after/code-simplifier.
Used standalone (outside a review workflow), this self-review gate is sufficient for the simplifier's own changes; you may still finish with /changes-review or the active workflow's review gate for broader, whole-changeset coverage.
EXEMPT when invoked by a parent skill or workflow step, when running as a sub-agent, or under
--report-only: return the result to the caller; skipask user question tool.
MANDATORY — NO EXCEPTIONS after completing, use ask user question tool:
Completion ≠ Correctness. Before reporting work done, prove it:
- Grep every removed name. Extraction/rename/delete → grep confirms 0 dangling refs across ALL file types.
- Ask WHY before changing. Existing values intentional until proven otherwise. No "fix" without traced rationale.
- Verify ALL outputs. One build passing ≠ all builds passing. Check every affected stack.
- Evaluate pattern fit. Copying nearby code? Verify preconditions match — same scope, lifetime, base class, constraints.
- New artifact = wired artifact. Created? Prove registered, imported, reachable by all consumers.
[IMPORTANT] Use
TaskCreateto break ALL work into small tasks BEFORE starting. Keep task depth proportional to the work.
Prerequisites: MUST ATTENTION READ before executing:
domain-entities-reference.md under the reference-docs root (default docs/project-reference; docsRoots.projectReference.path in docs/project-config.json overrides) — domain entity catalog, relationships, cross-service sync (read when task involves business entities/models)External Memory: Complex/lengthy work → write findings to
tmp/reports/. Prevents context loss, serves as deliverable.
Evidence Gate: MANDATORY — every claim, finding, recommendation requires
file:lineproof or traced evidence (confidence >80% to act, <80% verify first).
DRY and abstraction fit: Compare repeated behavior and responsibility before proposing a shared abstraction. Recommend a function, module, or type only when evidence shows the instances share a reason to change and the abstraction reduces future edits; names or suffixes alone do not justify a base type. Verify any project-specific lint/analyzer rule in its config.
Purpose: Avoid spending tokens on a fresh-context review of this skill's own findings. The simplifier owns its own convergence loop; broader review workflows can still run after the simplifier reports clean.
Loop:
file:line evidence.Stop conditions:
Rules:
/code-quality-review scoped to those files (recursion-safe leaf skill); skip + log if nothing changed or the caller passed --defer=review.Protocol guides — Apply each protocol only when its read-when condition holds. If a protocol's text is not in your context, read its file below before you act on it.
complexity-prevention — Change-cost lens on complexity (Ousterhout); designing or reviewing code → .claude/skills/shared/protocols/complexity-prevention.mdcore-engineering-principles — Core quality gate: easy to change, easy to scale, easy to maintain, judged by future change cost; planning, implementing or reviewing any change → .claude/skills/shared/protocols/core-engineering-principles.mddesign-patterns-quality — Design quality: one owner per rule, fitted patterns, no speculative abstraction; designing or reviewing code structure → .claude/skills/shared/protocols/design-patterns-quality.mdreview-decision-autonomy — Choose supported review decisions and ask before extending the round budget; running any review or audit skill or mode → .claude/skills/shared/protocols/review-decision-autonomy.mdseverity-rubric — One consequence-based Critical, High, Medium, Low scale for every finding and gate; classifying a finding or deciding whether a review round passes → .claude/skills/shared/protocols/severity-rubric.mdshared-protocol-duplication-policy — Protocol copies in carriers are intentional: edit the canonical source, then propagate; editing a shared protocol or its carriers → .claude/skills/shared/protocols/shared-protocol-duplication-policy.mdsource-test-drift-check — When source behavior changes, reconcile the affected tests from evidence; code, fix, test or review work changes behavior → .claude/skills/shared/protocols/source-test-drift-check.mdsubagent-return-contract — Sub-agents return a structured envelope and a report path, never an inline report; spawning a sub-agent → .claude/skills/shared/protocols/subagent-return-contract.mdui-system-context — Resolve the project's UI conventions before a UI change; changing a user-interface surface → .claude/skills/shared/protocols/ui-system-context.mdunderstand-code-first — Read and trace the target and existing patterns before changing code; planning or editing code → .claude/skills/shared/protocols/understand-code-first.mdverify-last-order — Build all phases and write tests, review statically, then verify once with a mutation check; planning or running any code-changing task → .claude/skills/shared/protocols/verify-last-order.mdIMPORTANT MUST ATTENTION cite file:line evidence for every claim; never speculate. Confidence >80% to act, <60% = do NOT recommend; "not enough evidence" is valid output.
IMPORTANT MUST ATTENTION assess change amplification, cognitive load, coupling, leaked detail and invariant ownership from project evidence. Extract only when a real owner or consumer lowers change cost; no universal layer order or numeric threshold.
<!-- /SYNC:complexity-prevention:reminder --> <!-- SYNC:severity-rubric:reminder -->NOT VERIFIABLE only when the concern would be MEDIUM or higher (an observation otherwise) — never a speculative LOW.IMPORTANT MUST ATTENTION follow declared step order for this skill; NEVER skip, reorder, or merge steps without explicit user approval; inside a workflow run, /start-workflow → Workflow-step mode bounds this
IMPORTANT MUST ATTENTION for every step/sub-skill call: set in_progress before execution, set completed after execution
IMPORTANT MUST ATTENTION every skipped step MUST include explicit reason; every completed step MUST include concise evidence
IMPORTANT MUST ATTENTION if Task tools unavailable, maintain an equivalent step-by-step plan tracker with synchronized statuses
MUST ATTENTION Decide supported review choices and recommendations, record the rationale, and finish without routine user questions. Keep round-limit extension, indispensable facts and actual action authority; preserve source coverage, validation, tests, read-only boundaries and budgets. Review decisions do not accept open risks or make a failed gate pass.
<!-- /SYNC:review-decision-autonomy:reminder -->IMPORTANT MUST ATTENTION Goal: Lower the cost of the next change — cut coupling, hidden state, duplicated knowledge, unclear intent — by simplifying and refining code for clarity, consistency, and maintainability without altering any observable behavior. — why: every simplification serves future change cost, not aesthetics.
IMPORTANT MUST ATTENTION Main steps (run in declared order, never skip/merge): (1) Phase 0 Detect target and scope from project config/source → (2) Identify Targets (skip generated/migration/vendor) → (3) Analyze the 5 Dimensions and mark inapplicable ones N/A with a reason → (4) Apply one refactoring type at a time → (5) Verify tests after EACH change → (6) Self-Recursive Loop until the current round's exit bar is clear (round 1: zero open findings; round 2: zero CRITICAL/HIGH/MEDIUM, LOW deferred) → (7) Self-Review Gate (/code-quality-review on changed files; skipped only under --defer=review). — why: AI keeps forgetting the skill's own steps; surfacing them here is the recency anchor.
Protocols in force (concise digest of the SYNC/shared blocks this skill carries):
SYNC:severity-rubric; round 1 blocks on every open validated finding (LOW deferral), round 2 blocks only CRITICAL/HIGH/MEDIUM, and LOW is recorded/deferred. Failed binary gates always block.IMPORTANT MUST ATTENTION apply a simplification ONLY when certain it preserves behavior — grep all usages + trace consumers (grep/read; an optional graph downstream trace may hint at more) and cite file:line BEFORE touching anything; if unsure → DO NOT apply. — why: an unverified "safe" rewrite silently breaks a downstream consumer.
IMPORTANT MUST ATTENTION NEVER simplify generated, migration, or vendor files — HARD-SKIP them in Phase 0. — why: regenerated output overwrites edits and migrations are one-time execution paths, not core logic.
IMPORTANT MUST ATTENTION run the Self-Recursive Loop (analyze → simplify → verify) until the current round's exit bar is clear (round 1: zero open findings; round 2: zero CRITICAL/HIGH/MEDIUM, LOW deferred); do NOT spawn a fresh-context reviewer for this skill's own findings. — why: re-reviewing your own findings in fresh context burns tokens the convergence loop already owns.
file:line proof or a traced call chain; confidence >80% to act, 60-80% verify first, <60% DO NOT recommend. NEVER use "obviously"/"I think"/"should be" without proof.TaskCreate BEFORE starting; keep exactly one in_progress; mark completed immediately; add a final review task. On context loss, TaskList first — resume, never duplicate.code-review-rules.md FIRST, then project-structure-reference.md — both under the reference-docs root (default docs/project-reference; docsRoots.projectReference.path in docs/project-config.json overrides); search 3+ existing patterns and read the target code BEFORE modification. The code graph is optional advice for high-risk blast radius.[HARD] §4 rule or §5 invariant; a behavior change is a Dual-Feedback finding (feed spec AND tests, re-review) — report and stop, never ship silently. — why: green tests on a weakened bar are not a pass.SYNC:verify-last-order), compile/type-check each change and leave the test run to that caller's single verify. — why: multi-stack changes regress the stack you didn't check./code-quality-review scoped to ONLY the changed files (recursion-safe leaf skill; NEVER /workflow-review-changes, whose code-simplifier step would recurse, nor the heavier /changes-review); skip + log the reason when nothing changed or when the caller passed --defer=review. The simplifier owns review of its own output. — why: the simplifier rewrites code after the main review batch, so its output ships unreviewed without this gate.--report-only runs steps 1–3 only — edit NO file, no nested sub-agent, no user question; every finding carries file:line + proposed change + behavior-preservation note; write only the report and return it. — why: a mutator inside a read-only review barrier races the diff its siblings are reading.Anti-Rationalization:
| Evasion | Rebuttal |
|---|---|
| "Already searched" | Show file:line evidence. No proof = no search. |
| "Just a small simplification" | Small change at wrong layer cascades. Trace consumers first. |
| "Code is self-explanatory" | Future readers need an evidence trail. Document non-obvious intent. |
| "Simplification is safe" | NEVER assume safe — grep ALL usages first; <80% confidence = do not apply. |
| "Best practice says abstract it" | Abstract only when it lowers future change cost; pass-through indirection is complexity, not simplification. |
| "This pattern is everywhere" | Pattern fit ≠ pattern presence. Verify same scope/lifetime/base-class/constraints before copying. |
| "Tests still pass, ship it" | Did you weaken the bar? A relaxed property/mutation test passing is not a pass. Keep the SAME invariant bar. |
| "Skip recursive check after fixing" | Every simplification changes the diff. Re-run this skill's own simplification analysis until the current round bar is clear; after round 1, LOW-only findings are recorded/deferred rather than causing another cycle. |
| "Generated file is messy too" | NEVER touch generated/migration/vendor — HARD-SKIP. Regeneration overwrites you. |
[TASK-PLANNING] Before acting, analyze task scope and systematically break into small todo tasks using TaskCreate.
<!-- SYNC:core-engineering-principles:reminder -->MUST ATTENTION Core Engineering Principles — every plan, implementation and review must be Easy to change (reuse first, one owner per rule, interfaces/adapters at volatile boundaries, no speculative abstraction) · Easy to scale (extend by addition, bounded growth, explicit boundaries, sized to the project's real profile) · Easy to maintain (intent-named tests that fail when the rule breaks across happy/error/edge paths; harness green locally and in CI). Before done: next change → how many edit sites? 10× → what breaks? which test goes red?
<!-- /SYNC:core-engineering-principles:reminder -->No reviews yet. Tell others what you thought.
No login needed. Share how it worked for you, ask a question, or note where it did not run.
No comments yet. Be the first to write one.
[Documentation] Use when generating, smart-merging or refactoring the root AI context (CLAUDE.md, AGENTS.md) and its Claude/Codex projections. Config file only: project-config.
The English summary is being prepared. Showing the original description.
[Code Quality] Use when a workflow step or the user asks for AI code or plan review: LLM calls, prompts, agents, RAG, evals and guardrails. --mode={code|plan}; --report-only is read-only.
The English summary is being prepared. Showing the original description.
[Architecture] Use when a workflow step or the user asks for architecture design, compliance review, scalability grading or whole-project audit via --mode={design|review|scalability|full}.
The English summary is being prepared. Showing the original description.
[Content] Use when a workflow step or the user asks for product/feature ideation with ranked opportunities and validation tests. --mode={roadmap|scope}.
The English summary is being prepared. Showing the original description.
[Content] Use when a workflow step or the user asks for business viability: Business Model Canvas, financials, risks and go-to-market recommendation.
The English summary is being prepared. Showing the original description.
[Code Quality] Use when a workflow step or the user asks for a focused code-change review: staged, unstaged, branch diff or simple pull request. --fix-loop fixes and re-reviews. Complex pull request: workflow-review-changes; rationale: why-review.
The English summary is being prepared. Showing the original description.