skills/polish-code/SKILL.md
Polish and refine code by delegating to a framework-aware simplifier subagent (auto-detected or specified). Use proactively after implementation phases, when asked to "simplify", "clean up", "polish", or "refactor" code. Do NOT use for architectural refactoring or for code review (use deep-review instead).
npx skillsauth add nicolas-codemate/claudecodeconfig polish-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Delegates code simplification to the most relevant {framework}-simplifier subagent, mirroring the pattern used by /resolve step 07-simplify.
$ARGUMENTS
--agent generic|symfony — force specific agent (skip auto-detect)--scope modified|all — scope (default: modified)--file <path> — target a specific file (repeatable)--dry-run — analyze only, do not modify filesIf --agent is not provided, auto-detect from project files:
if [ -f "composer.json" ] && grep -q "symfony/framework-bundle" composer.json; then
AGENT="symfony-simplifier"
else
AGENT="code-simplifier"
fi
Display: Agent detected: {AGENT}
--file providedUse the listed files as-is.
--scope modified (default)Determine base branch in this priority order:
.claude-work/{ticket-id}/status.json → options.base_branch.claude/ticket-config.json → branches.default_basemainBASE_BRANCH=$(cat .claude-work/*/status.json 2>/dev/null | jq -r '.options.base_branch // empty' | head -1)
[ -z "$BASE_BRANCH" ] && BASE_BRANCH=$(cat .claude/ticket-config.json 2>/dev/null | jq -r '.branches.default_base // "main"')
# Uncommitted first, then branch diff
CHANGED=$(git diff --name-only)
[ -z "$CHANGED" ] && CHANGED=$(git diff --name-only "${BASE_BRANCH}...HEAD")
echo "$CHANGED"
Filter by extension based on agent:
symfony-simplifier → *.phpcode-simplifier → *.js *.ts *.jsx *.tsx *.py *.go *.rs *.rb--scope allAskUserQuestion:
question: "Simplifier tout le codebase peut prendre du temps. Continuer ?"
header: "Scope"
options:
- label: "Oui, tout simplifier"
description: "Analyser tous les fichiers correspondant à l'agent"
- label: "Non, seulement les modifiés"
description: "Limiter aux fichiers modifiés (recommandé)"
Invoke the subagent directly (same pattern as /resolve step 07):
Agent:
subagent_type: {AGENT}
description: "Polish {N} file(s)"
prompt: |
Review and simplify the following files:
{list of absolute paths, one per line}
Project root: {cwd}
Mode: {apply|dry-run}
{if dry-run}
DO NOT modify files. Only report proposed changes.
{else}
Apply improvements directly to each file using Edit.
{endif}
Focus on: clarity, naming, redundancy removal, early returns,
pattern compliance, type annotations. Preserve all behavior.
RETURN FORMAT (mandatory):
```
POLISH_REPORT:
agent: {AGENT}
files_analyzed: {count}
files_modified: {count}
changes:
- file: path/to/file.ext
line: {line range}
category: [Readability | Redundancy | Naming | Abstraction | Consistency]
description: "{what was changed and why}"
no_changes_needed:
- path/to/file.ext (reason: already clean)
summary: "{1-2 sentence overall assessment}"
```
Output the subagent's POLISH_REPORT verbatim. Do NOT summarize — the user needs to see every change to decide whether to keep them.
--dry-runNo changes applied. Re-run without --dry-run to apply, or target specific files:
/polish-code --file {path}
git diff --stat
Display:
Modifications appliquées. Review with `git diff`, then commit when satisfied:
git diff # Full diff
git add -A && git commit -m "refactor: polish code ({AGENT})"
git restore -- <file> # Blocked by hook — ask for override if needed
Do NOT auto-commit and do NOT propose a revert (destructive git is hook-blocked).
# Auto-detect agent, simplify modified files
/polish-code
# Force Symfony agent
/polish-code --agent symfony
# Simplify specific file
/polish-code --file src/Service/UserService.php
# Preview without applying
/polish-code --dry-run
# Simplify entire codebase (with confirmation)
/polish-code --scope all
User-facing messages in French. Code examples and technical output in English.
Begin with $ARGUMENTS:
POLISH_REPORTgit diff and commit instructionsdevelopment
Method to diagnose and raise the Lighthouse performance score of a public page (landing, marketing, home). Use when asked to improve Lighthouse/PageSpeed scores, when auditing the first uncached paint of a public page, or when a landing embedded in a SPA must reach a top score. Do NOT use for in-app screen performance (data loading, rendering). For a brand-new landing, the first recommendation is static HTML with no framework runtime — most of this skill exists for when that is not an option.
tools
Audits a project's Claude Code setup against real usage — mines the project's conversations (worktrees included), confronts the project's skills/agents/CLAUDE.md with best practices, and proposes adjustments or new skills/agents/rules. Use when the user asks to audit the project config, analyze project conversations, or find automation opportunities for the current project. Do NOT use for the global ~/.claude configuration (use /audit-config instead).
development
Coaching workflow orchestrator. Guides the developer through implementation without writing code.
development
Disciplined methodology for code architecture refactoring. Use when the user asks to refactor architecture, decouple code, restructure a family of classes, redesign an interface, or rename/reorganize a set of related components. Forces a big-picture analysis before any code is written. Do NOT use for simple bug fixes, feature additions, or single-file refactoring.