polish-code-change
Skill2 starsChanged 3 months agoMITView on GitHub
Final, mutation-enabled quality gate for a staged diff or current branch after review. Use only when the user explicitly asks to polish or apply the final quality pass; never infer it from review completion.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- audit-agent-workflowsSkill
- find-simplificationsSkill
- frontend-acceptanceSkill
- page-performance-auditSkill
- review-code-changeSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 19 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈19
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 15
Use the first applicable target:
- Distinctive: line 22
Do not assume the base is main.
- Distinctive: line 24
Read repository instructions and inspect git status before making changes.
- Distinctive: line 30
Treat the paths and hunks in git diff --cached as the reviewed scope.
- Distinctive: line 31
Never use git add -A, git add ., or otherwise stage unrelated paths.
- Distinctive: line 32
If an in-scope file has no pre-existing unstaged changes, polish it and re-stage only that already-staged path after validation.
- Distinctive: line 33
If a file is partially staged or also has pre-existing unstaged changes, do not stage the whole file.
- Distinctive: line 39
Do not stage the resulting edits automatically.
- Distinctive: line 45
Read available findings, threads, test failures, accepted tradeoffs, and intentionally rejected suggestions.
- Distinctive: line 59
remove unused imports, exports, variables, unreachable branches, and stale compatibility code proven unused.
- Distinctive: line 64
delete comments that restate code while retaining concise rationale, contracts, and non-obvious failure boundaries.
- Distinctive: line 72
When the target contains React or UI code, also check:
- Distinctive: line 89
Stop and report when a fix requires a product decision, public API break, migration, destructive action, or meaningful scope expansion.
- Distinctive: line 91
Do not commit, push, publish comments, open a pull request, merge, or deploy unless separately requested.
- Distinctive: line 97
Run the narrowest formatter or lint checks that cover edited files.
- Distinctive: line 98
Run focused type, unit, integration, or build checks that exercise the changed contracts.
- Distinctive: line 103
Do not present static checks as browser, device, deployment, or production proof.
- Distinctive: line 107
no known P0 or P1 issue remains inside the scope.
- Distinctive: line 123
If the diff was already proportionate and clean, make no edits and say that the quality gate passed.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Polish Code Change
Perform the final quality pass after implementation and review. Fix high-confidence problems inside the reviewed boundary, then prove the resulting diff is ready for the user's next step.
This is not an initial code review or permission for a broad refactor. Invoke it explicitly after the review boundary is known.
Resolve The Target
Use the first applicable target:
- an explicit staged diff, branch, base, commit range, path, or file set;
- the review boundary already established in the conversation;
- a non-empty staged diff;
- the current branch against its actual upstream or merge base.
Do not assume the base is main. If staged and branch scopes are both plausible and no prior boundary decides between them, ask before editing.
Read repository instructions and inspect git status before making changes. Record staged, unstaged, untracked, and partially staged files. The target file set is fixed when every in-scope path and pre-existing out-of-scope change has been accounted for.
Preserve The Index Boundary
Staged mode
- Treat the paths and hunks in
git diff --cachedas the reviewed scope. - Never use
git add -A,git add ., or otherwise stage unrelated paths. - If an in-scope file has no pre-existing unstaged changes, polish it and re-stage only that already-staged path after validation.
- If a file is partially staged or also has pre-existing unstaged changes, do not stage the whole file. Leave polish edits unstaged or use hunk-specific staging only when the user explicitly requests it, then report the split state.
Branch or range mode
- Resolve and state the exact base and head or commit range.
- Inspect changed files from that boundary while reading enough unchanged context to reason correctly.
- Do not stage the resulting edits automatically.
In every mode, edit only the target surface. A small supporting edit outside a changed hunk is allowed only when required to keep the target correct and must be reported. Preserve all unrelated worktree changes.
Consume The Review
Read available findings, threads, test failures, accepted tradeoffs, and intentionally rejected suggestions. Do not reopen settled product decisions or repeat a broad review merely to generate more comments.
Turn each accepted finding into one of:
- a bounded fix;
- a validation obligation;
- a documented skip because it needs product input, external authority, or out-of-scope redesign.
The review is fully consumed when every material finding has one disposition and no accepted issue is silently dropped.
Polish The Diff
Prioritize changes that improve correctness or reduce maintenance cost without changing intended behavior:
- remove unused imports, exports, variables, unreachable branches, and stale compatibility code proven unused;
- simplify redundant assertions, types, intermediate values, conditions, control flow, and duplicated implementations;
- reuse an existing helper, component, hook, or abstraction only when it is equivalent and adaptation is smaller than the duplicate;
- collapse multiple sources of truth and unnecessary indirection when ownership and lifecycle remain clear;
- tighten error handling, cleanup, cancellation, resource ownership, and boundary cases exposed by the diff;
- delete comments that restate code while retaining concise rationale, contracts, and non-obvious failure boundaries;
- align names, formatting, imports, CSS, and local structure with repository conventions without creating style-only churn;
- strengthen tests when the changed contract or regression is not adequately pinned.
For substantial dead-code, duplication, or abstraction work, apply find-simplifications to the same fixed scope when it is available. Do not turn this pass into repository-wide cleanup.
React and frontend changes
When the target contains React or UI code, also check:
- derived state stored and synchronized through effects;
- duplicated server, form, URL, context, and component state;
- stale closures, missing cleanup, async races, and effect dependency mistakes;
- unstable or incorrect keys, render-time side effects, and unnecessary memoization;
- oversized components or hooks that mix policy, data ownership, and presentation;
- loading, empty, error, disabled, keyboard, touch, responsive, and accessibility states affected by the diff;
- repeated renders, request waterfalls, asset cost, and unbounded retained data.
Extract components or hooks only when the new boundary owns a coherent concept. Moving lines into more files is not itself an improvement.
Fix Policy
- Fix remaining correctness, security, privacy, data-loss, and contract problems when the safe behavior is clear.
- Fix high-confidence, low-risk maintainability and performance issues whose value exceeds the churn.
- Reject speculative abstractions, preference-only rewrites, dependency additions, and cleanup outside the target.
- Stop and report when a fix requires a product decision, public API break, migration, destructive action, or meaningful scope expansion.
Do not commit, push, publish comments, open a pull request, merge, or deploy unless separately requested.
Validate The Result
Discover commands from repository instructions, manifests, and existing scripts rather than assuming a package manager or framework.
- Run the narrowest formatter or lint checks that cover edited files.
- Run focused type, unit, integration, or build checks that exercise the changed contracts.
- Expand validation only when risk or repository policy justifies it.
- Re-read the final diff and confirm every edited hunk belongs to the fixed target.
- Re-search removed or consolidated symbols and verify callers, exports, tests, docs, configuration, and generated surfaces are consistent.
Do not present static checks as browser, device, deployment, or production proof. If visible behavior changed, run the relevant acceptance workflow when requested or explicitly record the missing runtime evidence.
The gate passes only when:
- no known P0 or P1 issue remains inside the scope;
- each quality edit has a concrete reason and preserves intended behavior;
- relevant checks pass, or every failure is identified as pre-existing or blocked with evidence;
- the final staged and unstaged state is explicit and contains no accidental paths.
Report
State:
- target mode and exact boundary;
- fixes made and why they improve the code;
- review findings rejected or skipped, with reasons;
- commands run and exact results;
- final staged, unstaged, and untracked state;
- remaining runtime, CI, compatibility, or product risks.
If the diff was already proportionate and clean, make no edits and say that the quality gate passed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

