code-polish
paulrberg/agent-skills
Polish and review changed code with risk-profiled simplification and defect detection.
What is code-polish?
Code Polish simplifies changed code and performs risk-prioritized review against security, configuration, language-specific, and data-format profiles. Use it after implementation to reduce complexity, fix defects, and verify the final state within a fixed scope.
- Simplify code by flattening control flow, clarifying names, and removing duplication while preserving public contracts and performance characteristics
- Review changes against CRITICAL/HIGH/MEDIUM/LOW risk profiles covering security, configuration, language-specific patterns, and data formats
- Fix evidenced defects with smallest defensible changes and cite location, triggering state, failure mode, and evidence
- Validate changes through targeted formatters, linters, typechecks, and invariant checks
- Resolve scope once using explicit paths, Git history, or natural-language targets; exclude lockfiles, generated outputs, and vendored code unless requested
How to install code-polish
npx skills add https://github.com/paulrberg/agent-skills --skill code-polish- Git repository (required)
- Applicable review profiles in references/profiles/ (security, configuration, language-specific, data-formats, naming)
How to use code-polish
- 1.Invoke with explicit file paths, patterns, ranges, or natural-language targets: `code-polish <paths>`
- 2.Optionally specify `--simplify` (simplify only), `--review` (review only), or both (default: both)
- 3.Add or skip review profiles with `--with-profile <name>` or `--skip-profile <name>`
- 4.Review the report, which includes scope, simplifications, verification results, and resolved/open issues
- 5.Address any CRITICAL or HIGH findings before merging; document residual risks and assumptions
Use cases
- Polish a feature branch before code review to catch defects and reduce complexity
- Run post-implementation simplification and security review on changed files in a session
- Review a specific file or directory against language-specific and security profiles
- Validate behavior parity after refactoring with targeted tests and invariant checks
- Audit external-input handling, secrets, and crypto usage in changed code
- Software engineers performing code review or refactoring
- Teams enforcing security and configuration standards across changes
- Developers working in Go, Rust, TypeScript, Python, or shell environments
- Anyone needing defect detection and simplification guidance before merging
code-polish FAQ
It uses files modified in the current session if available; otherwise all uncommitted tracked and untracked files in the Git repository. You can override this with explicit paths, patterns, or a resolved-scope block.
No. Simplifications preserve public contracts, inputs, outputs, side effects, error behavior, and performance characteristics. It will not split by line count, convert sync/async APIs, or make speculative changes.
Review judges the diff against your request and applies risk-profiled checks (CRITICAL → HIGH → MEDIUM → LOW) across security, configuration, language-specific, and data-format profiles. Every finding cites location, triggering state, failure mode, and evidence.
Yes. Use `--skip-profile <name>` to suppress a profile (e.g., `--skip-profile naming`). Use `--with-profile <name>` to add a profile. Skip wins if both are specified.
Code Polish reports which checks were skipped and why, and stops if behavior parity or required validation cannot be established. It will not proceed if a fix requires an unrequested public-contract change or larger redesign.
Full instructions (SKILL.md)
Source of truth, from paulrberg/agent-skills.
argument-hint: "[paths] [--simplify] [--review] [--with-profile <name>] [--skip-profile <name>]" name: code-polish description: "Polish changed code when the user explicitly asks, or when an active workflow requests post-implementation simplification and risk-profiled review over a fixed file scope."
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-scopeblock 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.
- Resolve and retain one authoritative scope set and optional exclusions for execution. 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 |
| Rust, Cargo/workspaces, async/concurrency, unsafe/FFI | rust |
| 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.
Summarize scope with the file count and smallest useful repository-relative roots, globs, ranges, or user-supplied
targets. Do not enumerate every file merely to prove scope; name individual paths only for a small explicit scope or to
clarify exceptions and findings. Findings include severity, location, impact, evidence, fix, and confidence. A residual
risk states the assumption, consequence if wrong, and how to check it. Under Issues and caveats, group verified fixes
with evidence as Resolved, and remaining problems, limitations, or unverified assumptions as Open, with their impact
and next step. Omit empty groups and report each item once; put neutral context and agreed decisions under changes or
scope. Reserve blocker for something preventing required work and risk for a specific potential adverse outcome. A
workaround leaves an item open when the underlying issue still affects the result. Completion requires fixed scope,
traceable edits/findings, and validation evidence.
Render a successful report as ### ✨ Code polish — ✅ complete, a small summary-count table, a compact Scope
summary, ### ✨ Simplifications, ### 🧪 Verification, and ### Issues and caveats, omitting inapplicable sections.
When review ran and found no defects, state ✅ No verified review findings. If a stop condition below prevents
completion, lead with ### ✨ Code polish — ⛔ blocked and report the evidence and required decision. Keep severity
tokens, profile IDs, commands, locations, reproduction inputs, and security evidence exact and undecorated.
Stop when behavior parity or required high-risk validation cannot be established, or a fix requires an unrequested public-contract change or larger redesign.
Related skills
More from paulrberg/agent-skills and the wider catalog.

code-review
Find high-impact defects in code reviews, PRs, and diffs with evidence-based severity ranking.

code-simplify
Simplify and refactor code while preserving behavior, clarity, and maintainability.

effect-ts
Apply Effect 3 semantics for services, layers, typed errors, Schema, Config, and runtime patterns.

md-docs
Initialize and update README.md and AGENTS.md documentation for Claude Code workflows.

tailwind-css
Apply and maintain Tailwind v4 styling with class management, configuration, and migration support.

yeet
Create and update GitHub PRs, issues, and discussions with templated workflows and idempotency checks.