9thlevelsoftware/legion/code-polish
- community
Checking that the SKILL.md file is still in the repository.
Structured multi-pass code cleanup engine for removing noise, simplifying structure, improving naming, and normalizing conventions
Install
npx vskill@latest install 9thlevelsoftware/legion/code-polishSKILL.md
Code Polish
Structured four-pass code cleanup engine. Takes files that already work and makes them clearer, shorter, and more consistent without changing behavior. Each pass has a single focus and a concrete rubric with auto-apply rules (safe, mechanical) and flag-only rules (require human judgment).
Two integration modes:
- Standalone: invoked via
/legion:polish— user selects scope, engine runs all 4 passes, outputs POLISH.md - Review-integrated: invoked by review-loop after fix cycles complete — scope is the files just reviewed, output appends to REVIEW.md
The engine always dispatches to the testing-code-polisher agent personality. Load agents/testing-code-polisher.md before invoking any pass.
Section 1: Scope Resolution
Determines which files to polish. Runs before any pass begins.
Section 2: Convention Detection
Detects project patterns before making any changes. Conventions discovered here govern all four passes. Higher-precedence sources override lower ones.
Section 3: Pass 1 — Comment Cleanup
Remove comments that add no information. Preserve comments that explain non-obvious intent. This is a deletion pass — it adds nothing.
3.1 REMOVE Rules (severity: CLEAN)
Apply these removals automatically. Every removal is logged.
| Rule | Description | Example | |
|---|---|---|---|
restates-code | Comment restates what the next line does | // increment counter above counter++ | |
ai-narration | AI-generated narration or step-by-step commentary | // Now we need to fetch the user data from the API | |
commented-out-code | Code in comments with no explanation of why it is kept | // const oldHandler = () => { ... } | |
stale-todo | TODO/FIXME/HACK with no issue reference and no date, older than the current sprint | // TODO: fix this later | |
noise-divider | Decorative dividers or section banners that separate obvious blocks | // ===================== or // --- helpers --- | |
signature-restatement | Comment restates function name, parameters, or return type already visible in the signature | /** Gets user by ID */ above function getUserById(id: string): User |
Detailed examples:
3.2 PRESERVE Rules (severity: KEEP)
Never remove comments matching these patterns. If uncertain, preserve.
| Rule | Description | Example | |
|---|---|---|---|
intent | Explains WHY, not what — reasoning, tradeoff, workaround | // Using setTimeout because requestAnimationFrame skips background tabs | |
business-logic | Encodes domain rules not obvious from code | // Tax-exempt if order originated from EU VAT-registered entity | |
legal-header | License, copyright, attribution | // SPDX-License-Identifier: MIT | |
todo-with-ref | TODO/FIXME with issue tracker reference | // TODO(PROJ-123): migrate to v2 API after deprecation deadline | |
gotcha-warning | Warns about non-obvious side effects or constraints | // WARNING: this mutates the input array — caller must clone if needed | |
type-annotation | Type hints in dynamically typed languages | # type: Dict[str, List[int]] in Python 2-style code | |
regex-explanation | Explains complex regex patterns | // Matches ISO-8601 dates with optional timezone offset |
3.3 Logging Format
Section 4: Pass 2 — Code Simplification
Reduce code volume and complexity without changing behavior. This pass targets structural waste — code that does more work than necessary to express its intent.
4.1 SIMPLIFY Rules (auto-apply)
Apply these transformations automatically. Each must be provably behavior-preserving.
| Rule | Description | |
|---|---|---|
guard-clause | Replace nested if/else with early returns | |
lookup-table | Replace if/else chains or switch on value with object/map lookup | |
dead-code | Remove unreachable code after return/throw/break/continue | |
unused-vars | Remove declared but never-referenced variables | |
unused-imports | Remove imported but never-referenced symbols | |
inline-trivial | Inline variables used exactly once on the next line | |
collapse-wrapper | Remove functions that only call another function with same args | |
stdlib-equivalent | Replace hand-rolled logic with standard library calls |
Detailed examples:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/code-polish/SKILL.md
Popularity
- Repository stars
- 62
- Repository forks
- 7
- 7-day trend score
- 21
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/9thlevelsoftware/legion/code-polish)