Install
openclaw skills install @tenequm/polish-newPre-release code review that converges - runs checks, launches parallel review agents (cleanliness, design, efficiency, side-effect gating) sized to the diff, validates findings against reproducible evidence in a run ledger, fixes on approval, then reviews its own fixes until a round warrants no edits. Run on /polish-new, or when asked for a polish or pre-release review before committing or pushing.
openclaw skills install @tenequm/polish-newA review is finished when a review of its own fixes warrants no further edits -
not when the fixes are written, not when checks pass. Evidence beats judgment: a
finding that cannot be reproduced from its own citations does not survive. The
fix pass is where the next round's defects come from, so it gets reviewed like
any other code. Findings live in files, not in this conversation - context can
be compacted away mid-run; if you are resuming after a compaction or
interruption, re-read ledger.md and the saved agent reports before continuing.
They are the source of truth, not the summary.
A base ref may be passed as an argument; Phase 2 uses it for scope.
Work in the repository under review - it may be a worktree, not the current directory. Establish state there:
git rev-parse --abbrev-ref HEAD
git status --short
git diff --stat
Create the run directory .agents/polish/<YYMM-DD-HHMM>-<slug>/ with an
agents/ subdirectory, and start ledger.md recording the reviewed sha
(git rev-parse HEAD) and, as they launch, one row per agent (lens, shard,
output file, launch time, plus any run identifier the harness exposes).
Base ref and diff stat are backfilled at the end of Phase 2. Findings get ledger
rows as reports arrive, not later.
If .agents/ is not already ignored, add .agents/polish/ to the project's
ignore file - run artifacts are working state, never committed.
The reviewed sha makes this review a certificate about one snapshot. Anything
committed after it is unreviewed; a later run scopes to <reviewed-sha>..HEAD.
Run the project's lint + type-check command. Check CLAUDE.md (or the equivalent
project instructions) for the correct validation command - commonly pnpm check,
just check, cargo clippy, uv run ruff check. If none is documented, ask.
If checks fail: fix all errors, re-run until clean, then continue. Do not start
the review against a failing gate. When a failure predates the diff (it
reproduces on the base ref), still fix it - but record it in the ledger as
pre-existing gate failure, fixed and surface it in the report.
Resolve the base ref: the argument if one was passed; else the repository's
default branch (git symbolic-ref refs/remotes/origin/HEAD, falling back to
whichever of main/master exists); if neither resolves or there is no merge
base (shallow clone, detached HEAD), say so and ask the user for a base.
Scope is a union: <base>...HEAD, plus staged and unstaged changes, plus
untracked (??) source files. The reviewed-sha certificate must be true of the
whole union. If the work under review was committed this session, the branch side
narrows to those commits. A staged change that references an untracked file is
itself a finding: without the file, fresh checkouts and CI break. If nothing
changed at all, report "nothing to review" and stop.
Write the diff to a file in the run directory. git diff does not emit
untracked files - append each one via git diff --no-index /dev/null <path>,
and include untracked paths in the changed-file list handed to agents. Exclude
lockfiles and generated outputs (Cargo.lock, pnpm-lock.yaml, *.snap,
generated bindings) - but never a plan or spec document the branch implements:
that is review input. For moved or rewritten code, note the prior version
(git show <ref>:<path>) for agents to compare behavior against. Backfill the
ledger header: base ref, diff stat.
Read the diff's structure, not every line: which subsystems it touches and which control flows it changes. Then produce the shard plan and arm the conditional lenses.
The shard plan. If the diff is tiny (under ~50 changed lines), skip the finder agents and review all lenses yourself, reading every changed line - the fast path skips ONLY the finder fan-out; the run directory, ledger, evidence standard for your own findings, skeptics on your confirmed correctness findings, report, approval gate, fix pass, and fix review all still apply. Otherwise one agent per lens. When a lens's share would exceed roughly 1500 lines of diff, split that lens across shards - enumerate the lens's natural units and assign each agent a few, drawing boundaries so control flows stay intact:
| Lens | Shard unit - enumerate these to shard |
|---|---|
| Cleanliness | files - the only genuinely local lens |
| Efficiency | hot paths (per-frame/per-request/per-render/per-log-line/per-CI-run work) and shared resources (memory limits, locks, caches, stores, pools, declared timeouts), each traced end to end |
| Design & Reuse | subsystems, with whole-diff visibility |
| Side-Effect Gating | side-effect flows - each costly or irreversible action the diff introduces or relocates (charges, writes, deletes, mutating external calls, notifications), traced entry point to effect |
A shard assigns accountability, not visibility: every agent gets the full diff and may read anything in the repository; it is answerable for complete coverage of its shard.
The conditional lenses. Arm Control Verification if the diff touches a security control (credentials, auth, permissions, payments, sandboxing, input validation at a trust boundary). Arm Plan Conformance if a plan or spec document for this branch exists.
Launch all agents concurrently. Every agent this skill spawns - finder, skeptic, dive, fix-review - receives the Agent Contract verbatim; finders also receive their lens section verbatim, plus:
Save each agent's report verbatim to agents/<lens>[-<shard>].md as it
lands. Do not summarize into the conversation and discard the original.
(pre-existing) or (out of diff)file:line, the check performed as an exact command with its observed output (for a purely code-local finding, the quoted code itself is the check), and the source of any external fact as a path or URL. A finding whose evidence cannot be reproduced from its citations is a claim, and claims do not survive validationFast, mechanical, high-confidence. Junk that should be removed.
console.log, console.debug, console.warn added during development; temporary debug variables, hardcoded test values. NOT structured logger callsTODO/FIXME/HACK markers left by the agent; unnecessary type annotations where the language infers; emoji in code (unless the project uses them); references to plan phases or section numbers meaningless to a reader of the coderg -n '[\x{2010}-\x{2015}\x{2018}-\x{201F}]' - a plain-text grep over a diff misses multi-byte characters0, 1, true, HTTP status codesRequires exploring beyond the diff. Structural and design issues.
Runtime performance and resource issues. Cost concentrates in two places: hot paths (frequency) and shared resources (accumulation). Trace your assigned paths and resources end to end, across files. Do not flag cold paths, one-time setup code, or scripts that run once - though a real leak or missing timeout on a cold path still counts.
Closed-scope correctness. Costly or irreversible side-effects that run before the checks meant to gate them. Does NOT judge whether business logic is correct - that is broader code review's job.
For each side-effect flow you own:
Every finding cites the side-effect line, the gate it precedes (or "ungated"), and the control-flow path between them. No finding without two line references.
Only when the diff touches a security control. A control makes a promise: this input cannot reach that effect, this caller cannot act without that check. Establish whether it holds on every path - the only way is to hunt for a counterexample. For each control the diff introduces or modifies, state its promise, then look for a path where it fails: another route to the guarded effect, an encoding of the input the filter does not recognize, a parse that fails open, a check that reads values the untrusted side supplies, ordering where the control is armed too late or consumed by the wrong event, resource exhaustion that disables it. Report each failing path with the exact sequence that reaches it. Where a promise held, say what you tried.
Only when a plan or spec document for this branch exists. Read it in full. For each requirement, decide: implemented as specified, implemented differently, or missing - and cite the code for each. Flag requirements silently dropped, behavior beyond what was specified, and any place the implementation contradicts a guarantee the plan states. The plan's own caveats and known-trap sections are review input: check whether this implementation walked into one.
Findings arrive as claims. Every raw finding from every report gets a row in
ledger.md - including findings buried inside an agent's "clean" section,
parenthetical asides, bundled items, and hedged caveats. Those are where true
findings die.
Reproduce, do not re-derive. For each finding, run the command it cites and compare the output; open the exact file and lines and confirm the code matches; follow the path or URL behind any external fact. You did not read the whole diff, so your judgment is not the standard - reproducibility is. Drop a finding when the line number is wrong, the code does not match the claim, the cited symbol does not exist, the cited command does not produce the claimed output, or the evidence is missing and cannot be reconstructed. Record every drop with its reason.
Never drop a side-effect, behavior-drift, or bypass finding as "a design decision" or "out of scope". If it reproduces, it is the highest-severity finding present.
For findings on rewritten or relocated code, check whether the flaw predates the
change; if so keep it, tagged (pre-existing). Separately flag test coverage
deleted with an old path and not replaced.
Assign each confirmed finding a disposition in the ledger:
fix - the defaultnot-worth-fixing (reason) - real, but the fix trades worse than the defect, or the code is a deliberate backstopseparate-change (reason) - real, but fixing it would bloat this change beyond what belongs in itJudge on long-term codebase benefit: out-of-diff findings default to fix, and a
low-risk fix that just makes maintenance easier is a fix, not a deferral.
Escalate where the evidence says there is more. In parallel:
Dive findings re-enter this phase: ledger row, reproduce, disposition, escalate. Repeat until a round produces nothing new. A clean diff exits after one pass; a diff with real defects keeps digging until it stops paying.
Render the report from ledger.md. Merge duplicates - if several agents flagged
the same code, one finding, all citations. The counts must reconcile: every raw
finding is in a category with its disposition, or in Dropped with its reason.
Control-verification failures report under Correctness tagged (control); Plan
Conformance gaps under Correctness tagged (plan) when behavior is missing or
wrong, under Design when structural only.
## Review Findings
Reviewed <sha> against <base>. <N> raw findings: <N> fix, <N> not-worth-fixing,
<N> separate-change, <N> dropped. Ledger: .agents/polish/<run>/ledger.md
### Correctness (N issues)
1. `path/to/file.ts:55` - chargeUser() runs before body validation (handler validates at :78, after next()); a malformed request is charged then 400s - fix
2. `path/to/proxy.ts:258` - every client frame now fully decoded - not-worth-fixing: the prefilter cannot see escaped method names; fail-closed beats microseconds
### Cleanliness (N) / Design (N) / Efficiency (N)
...same shape, one numbered line per finding, disposition last...
### Dropped after validation
1. `path/to/auth.go:88` - claimed bypass; the skeptic showed the parser rejects that encoding at :40 before the filter runs
**Total: X findings - Y to fix now**
**Awaiting approval before proceeding with fixes.**
List Correctness first, and always - including at (0 issues). A correctness
zero must state what was traced: which side-effect flows were inventoried, which
paths were enumerated, which gates cover them. It must never be batch-approved
alongside cosmetic items. If Phase 1 fixed pre-existing gate failures, say so here.
Approval semantics: a bare approval ("go", "proceed", "fix") approves every
finding marked fix. The user can override by number ("go, but skip design 2;
also fix efficiency 1") - overridden findings get their disposition updated in
the ledger (deferred (not approved) or fix), so counts still reconcile. Fix
nothing until the user explicitly approves.
If zero issues survive, report "Clean - no issues found", substantiate the correctness zero, offer next actions, and stop - a clean report needs no approval line.
All fixes happen in the working tree - create no commits until the very end.
Snapshot the pre-fix state first: SNAP=$(git stash create); [ -z "$SNAP" ] && SNAP=$(git rev-parse HEAD) - git stash create returns nothing on a clean
tree - and record it in the ledger. Then, for each approved finding:
tail or head and act on its apparent success: the pipeline reports the last command's status, so a failing gate looks green. Capture the exit code and print itRe-run the project's validation command. Fix anything new. Mark each ledger row fixed.
The fixes are unreviewed code written under momentum by someone thinking about a
finding rather than about the code - historically where the next round's defects
come from. Before reviewing, git add -N any files the fixes created, or
git diff will not show them. Launch a fresh agent over git diff <SNAP> (the
working tree against the snapshot), given the ledger, the Agent Contract, and
the lens sections relevant to what changed. It checks:
Classify the round's findings and act autonomously - no approval gate here:
Exit when a round warrants no edits. Convergence comes from the shrinking diff: each round reviews only the previous round's edits. Circuit breaker: after 5 rounds stop looping - run the checks and disclose what remains in the summary.
Finish with:
git add -A), fold into existing commits, or leave in the working tree. Push only if asked