/clean-code:reviewfrom clean-code
Review the staged diff for clean-code violations, present findings for one decision, and satisfy the commit gate
Ships in clean-code. Installing the plugin adds it to Claude Code.
Run the clean-code review over the staged diff and resolve the commit gate.
${CLAUDE_PLUGIN_ROOT}/hooks/gate.js is referred to below as the gate. Every
decision the gate makes is deterministic — never second-guess it, never write
marker files by hand, and never edit anything under .git/clean-review/.
node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" status. If state is
dormant or paused, tell the user the gate is not active in this repo
(suggest /clean-code:setup for dormant) and stop.reviewed is already true, the staged tree passed the gate earlier.
Say so in one line, go straight to S5, and do not review again.node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" config
gives the config and any repo-policy/personal rubric bodies.node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" diff.
This has the configured excludes already applied — do not run
git diff --staged yourself.max_diff_lines, do not silently review a subset. Say
how large it is and offer, via AskUserQuestion: review the largest-risk files
only (name them) / review everything anyway (slower) / bypass this commit
with a recorded reason.Spawn the clean-code-reviewer agent with the Task tool. Give it exactly:
${CLAUDE_PLUGIN_ROOT}/docs/principles/
(base layer), then the repo policy body, then the personal body — each
section labelled with its source,Tell the user in one line that the review is running. Parse the agent's JSON reply. If it is not valid JSON, retry the agent once; if it fails again, report the failure and offer the S3 options minus "Apply" — never fabricate findings, and never mark the gate on a failed review.
Gating findings are those with severity at or above the configured
severity_threshold and confidence: high. Everything else is advisory.
If there are no gating findings:
node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" mark passedClean-code review passed — committing. Add advisory items
only if any exist, as a short list below that line, and do not ask about them.Do not congratulate, summarise the diff, or explain what you reviewed. Silence on success is the point.
You must present the findings through AskUserQuestion. Do not decide on the user's behalf, do not apply fixes first and ask after, and do not retry the commit while findings are unresolved.
Before asking, print the findings as a readable list — one entry each:
src/auth.ts:142 — [base] validateAndSaveUser does validation, persistence, and email dispatch
A reviewer would block: the three concerns cannot be tested or changed independently.
Fix: extract validateUser and sendWelcomeEmail; leave saveUser as the persistence step.
Then ask exactly one question with these options, in this order:
| Option | Label |
|---|---|
| 1 | Apply all fixes — only when every gating finding has fix.type: edit |
| 2 | Apply selected — set multiSelect: true when offering this |
| 3 | I'll fix manually |
| 4 | Commit anyway — see bypass modes below |
Bypass mode comes from the resolved config's bypass key:
logged (default): label the option Commit anyway.reason-required: label it Commit anyway (reason required). If chosen, ask
for a one-line reason and pass it to the gate.disabled: omit option 4 entirely. Tell the user repo policy disables
local bypass and that the exception path is a CODEOWNERS-granted PR label.git diff --name-only). If so, warn in the summary that staging the
fix will also stage those pre-existing edits — the user may want to abort.git add each file you edited.node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" mark fixes-applied. The marker
binds to the post-fix tree, so the retry passes without re-reviewing.If some findings were fix.type: advice and were not selected, list them as
remaining work in the summary.
echo '<findings JSON array>' | node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" pending writefile:line — summary checklist. The
user is about to leave the conversation to edit; that list is what they take
with them. Tell them that after fixing they can commit again (the gate
re-reviews the changed diff) or run /clean-code:resume.bypass: reason-required, capture the reason first.node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" mark user-approved '{"reason":"<reason or empty>"}'node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" pending clearClean-Review: passed id=<review_id>Clean-Review: fixes-applied id=<review_id>Clean-Review: bypassed id=<review_id> reason="<reason>"
Get <review_id> from node "${CLAUDE_PLUGIN_ROOT}/hooks/gate.js" hash
before committing.--no-verify.What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub entelligentsia/skillforge --plugin clean-code4 commands in this plugin
/removePhase 1 — State reportRemove or pause the clean-code commit gate for this repository, restoring any hook it replaced/resumeStep 1 — Load pending findingsRe-open the clean-code review gate from findings saved earlier, without re-running the review/setupPhase 1 — Preflight reportActivate the clean-code commit gate for this repository — writes config and optionally installs the git pre-commit hookOther plugins' commands for the same job