Code Polish
Resolve scope once, make only high-confidence simplifications, fix evidenced defects by risk, and verify the final
state.
Modes
--simplify: simplify only.
--review: review and fix only.
- Neither or both: simplify, then review the simplified result.
--with-profile <name> / --skip-profile <name>: add or suppress review profiles; skip wins.
Fixed Scope
- Require a Git repository.
- Use explicit paths, patterns, ranges, natural-language targets, or a supplied
resolved-scope block when present.
Otherwise use only files modified in this session; if session history is unavailable, use all uncommitted tracked and
untracked files.
- Exclude lockfiles, generated outputs, vendored code, minified bundles, and large data snapshots from manual review
unless explicitly requested. Validate relevant excluded outputs through their generator, schema, or invariants.
- Emit one authoritative
resolved-scope block and optional excluded-scope block. Do not broaden or recompute scope
later. Stop if it is empty.
Simplify
Preserve public contracts, inputs, outputs, side effects, error behavior, performance-sensitive characteristics,
telemetry, and operational guards. Apply only changes with a concrete comprehension or defect-risk benefit:
- flatten avoidable control-flow nesting;
- clarify misleading names or dense transforms;
- remove real duplication when the abstraction reduces total complexity;
- tighten local types and contracts without broad churn;
- remove only dead code caused by this session's edits.
Do not split by line count, perform architecture cleanup, convert sync/async APIs, add speculative configurability, or
replace readable duplication with a one-use abstraction. A no-op is a valid result.
Review and Fix
Judge the diff against the user's request. Prioritize CRITICAL → HIGH → MEDIUM → LOW:
- CRITICAL: exploitable security, data loss, or critical outage path.
- HIGH: behavior, error-path, boundary, or performance defect affecting core behavior.
- MEDIUM: resource leak, complexity hotspot, test gap, over-scoped change, speculative complexity, or weak success
criterion likely to cause defects.
- LOW: localized clarity or style issue with a real maintenance cost.
Every finding must cite a verified location, triggering input/state, failure mode, blast radius, and evidence in the
changed code. Merge duplicates and apply the smallest defensible fix. When intent is ambiguous, stop or record the
assumption instead of guessing.
Select every applicable profile and read it once:
| Surface |
Profile |
| auth, secrets, crypto, external input/network, unsafe parsing |
security |
| env, config, timeouts, retries, pools, limits |
configuration |
| Go behavior, concurrency, context, errors |
go |
| TypeScript types, modules, packages, async behavior |
typescript |
| Python services, scripts, async, packaging, data IO |
python |
| shell, CI, deploy, installers, quoting |
shell |
| CSV/JSON/YAML/binary, schemas, migrations, generated data |
data-formats |
| naming and intent clarity |
naming unless skipped |
Profiles live at references/profiles/<name>.md. Missing selected profiles are a stop condition.
Verification and Report
Run the narrowest formatter/lint, targeted tests, typecheck, and invariant checks that prove the final touched behavior.
Broaden only for shared contracts. Name skipped checks and why.
Report Scope, Simplifications when run, Review Findings and Fixes when run, Verification, and Residual Risks.
Findings include severity, location, impact, evidence, fix, and confidence. A residual risk states the assumption,
consequence if wrong, and how to check it. Completion requires fixed scope, traceable edits/findings, and validation
evidence.
Stop when behavior parity or required high-risk validation cannot be established, or a fix requires an unrequested
public-contract change or larger redesign.
1---
2argument-hint: "[paths] [--simplify] [--review] [--with-profile <name>] [--skip-profile <name>]"
3disable-model-invocation: false
4name: code-polish
5user-invocable: true
6description:
7 "Polish changed code when the user explicitly asks, or when an active workflow requests post-implementation
8 simplification and risk-profiled review over a fixed file scope."
9metadata:
10 source: https://skillmd.com/skills/om-scogo/code-polish
11---
12
13# Code Polish
14
15Resolve scope once, make only high-confidence simplifications, fix evidenced defects by risk, and verify the final
16state.
17
18## Modes
19
20- `--simplify`: simplify only.
21- `--review`: review and fix only.
22- Neither or both: simplify, then review the simplified result.
23- `--with-profile <name>` / `--skip-profile <name>`: add or suppress review profiles; skip wins.
24
25## Fixed Scope
26
271. Require a Git repository.
282. Use explicit paths, patterns, ranges, natural-language targets, or a supplied `resolved-scope` block when present.
29 Otherwise use only files modified in this session; if session history is unavailable, use all uncommitted tracked and
30 untracked files.
313. Exclude lockfiles, generated outputs, vendored code, minified bundles, and large data snapshots from manual review
32 unless explicitly requested. Validate relevant excluded outputs through their generator, schema, or invariants.
334. Emit one authoritative `resolved-scope` block and optional `excluded-scope` block. Do not broaden or recompute scope
34 later. Stop if it is empty.
35
36## Simplify
37
38Preserve public contracts, inputs, outputs, side effects, error behavior, performance-sensitive characteristics,
39telemetry, and operational guards. Apply only changes with a concrete comprehension or defect-risk benefit:
40
41- flatten avoidable control-flow nesting;
42- clarify misleading names or dense transforms;
43- remove real duplication when the abstraction reduces total complexity;
44- tighten local types and contracts without broad churn;
45- remove only dead code caused by this session's edits.
46
47Do not split by line count, perform architecture cleanup, convert sync/async APIs, add speculative configurability, or
48replace readable duplication with a one-use abstraction. A no-op is a valid result.
49
50## Review and Fix
51
52Judge the diff against the user's request. Prioritize `CRITICAL → HIGH → MEDIUM → LOW`:
53
54- **CRITICAL**: exploitable security, data loss, or critical outage path.
55- **HIGH**: behavior, error-path, boundary, or performance defect affecting core behavior.
56- **MEDIUM**: resource leak, complexity hotspot, test gap, over-scoped change, speculative complexity, or weak success
57 criterion likely to cause defects.
58- **LOW**: localized clarity or style issue with a real maintenance cost.
59
60Every finding must cite a verified location, triggering input/state, failure mode, blast radius, and evidence in the
61changed code. Merge duplicates and apply the smallest defensible fix. When intent is ambiguous, stop or record the
62assumption instead of guessing.
63
64Select every applicable profile and read it once:
65
66| Surface | Profile |
67| ------------------------------------------------------------- | ----------------------- |
68| auth, secrets, crypto, external input/network, unsafe parsing | `security` |
69| env, config, timeouts, retries, pools, limits | `configuration` |
70| Go behavior, concurrency, context, errors | `go` |
71| TypeScript types, modules, packages, async behavior | `typescript` |
72| Python services, scripts, async, packaging, data IO | `python` |
73| shell, CI, deploy, installers, quoting | `shell` |
74| CSV/JSON/YAML/binary, schemas, migrations, generated data | `data-formats` |
75| naming and intent clarity | `naming` unless skipped |
76
77Profiles live at `references/profiles/<name>.md`. Missing selected profiles are a stop condition.
78
79## Verification and Report
80
81Run the narrowest formatter/lint, targeted tests, typecheck, and invariant checks that prove the final touched behavior.
82Broaden only for shared contracts. Name skipped checks and why.
83
84Report `Scope`, `Simplifications` when run, `Review Findings and Fixes` when run, `Verification`, and `Residual Risks`.
85Findings include severity, location, impact, evidence, fix, and confidence. A residual risk states the assumption,
86consequence if wrong, and how to check it. Completion requires fixed scope, traceable edits/findings, and validation
87evidence.
88
89Stop when behavior parity or required high-risk validation cannot be established, or a fix requires an unrequested
90public-contract change or larger redesign.