refactor
/refactor
Improve existing code without changing behavior — split large functions, backfill tests, simplify. Use when asked to "refactor", "add missing tests", "split functions", "simplify", "clean up code", or "reduce complexity". Don't use for new features (/tdd), security hardening (/harden), or PR review (/code-review).
- Author
- helderberto ↗
- Repository
- agent-skills ↗
- Licence
- MIT
- Last repository change
- 24.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Improve existing code without changing behavior — split large functions, backfill tests, simplify. Use when asked to "refactor", "add missing tests", "split functions", "simplify", "clean up code", or "reduce complexity". Don't use for new features (/tdd), security hardening (/harden), or PR review (/code-review).
Triggers from the description
Original author description
Improve existing code without changing behavior — split large functions, backfill tests, simplify. Use when asked to "refactor", "add missing tests", "split functions", "simplify", "clean up code", or "reduce complexity". Don't use for new features (/tdd), security hardening (/harden), or PR review (/code-review).
How it works
- Workflow
SKILL.md preview
--- name: refactor effort: high description: Improve existing code without changing behavior — split large functions, backfill tests, simplify. Use when asked to "refactor", "add missing tests", "split functions", "simplify", "clean up code", or "reduce complexity". Don't use for new features (/tdd), security hardening (/harden), or PR review (/code-review). --- # Refactor Target: $ARGUMENTS (file, directory, or module — if blank, use unstaged changes) Behavior is frozen — the test suite is the contract. Green before and after; if a test's meaning has to change, you've gone too far. ## Workflow ### 1. Scope - Identify target files (blank → unstaged changes) - Locate each file's tests using the project's convention (co-located, `__tests__/`, `tests/`, `spec/`). A file with no tests gets **Test gaps** items first — Split/Simplify on untested code is unverifiable, so backfill or skip. No test runner at all → ask which to use. UI flows → backfill end-to-end tests: call the Skill tool with `tdd`, which holds the UI-tests reference. Entrypoint scripts without exports → audit only. - Run the suite. If red, stop — don't refactor broken code ### 2. Audit List findings, most-impactful first: | Bucket | What to look for | Fix | |---|---|---| | **Split** | Functions > 20 lines, multiple responsibilities, I/O mixed with logic | Extract pure logic into named helpers; keep I/O at the edges; preserve the original signature | | **Edge cases** | Missing null/empty/boundary checks at system boundaries, unhandled error paths | Test first, then guard | | **Test gaps** | Untested public functions, uncovered branches, missing sad-path tests | Backfill through the public interface | | **Simplify** | Nesting > 2 levels, dead code / unused params, duplicated logic, dense one-liners, shallow pass-through wrappers, speculative config never used, unclear names / primitive obsession | Guard clauses, delete, extract one helper, expand, inline (call the Skill tool with `codebase-design` for the deletion test), remove, rename to intent / small type | **Chesterton's Fence**: before removing anything, explain why it's there. If you can't, leave it and flag it. Present the audit as a checklist and ask which items to address — "All items" first, marked (Recommended). ### 3. Apply — one item at a time Per approved item: RED (failing test exposing the gap, when the item adds behavior coverage) → GREEN (minimal change) → run tests. Real values over mocks; mock only external I/O (call the Skill tool with `tdd` for its mocking guide). If red after the change, revert it and flag as blocked. Never batch. ### 4. Report Items addressed, tests added, functions extracted, items skipped with reason (Chesterton), suite result before/after.
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · helderberto/agent-skills | 100 | MIT |
| froglet-studio/cosmic-shore | 100 | MIT |
| mgiovani/cc-arsenal | 100 | MIT |
| jongio/skills | 100 | MIT |
| boshu2/agentops | 100 | Apache-2.0 |
| y-miyazaki/terraform-aws-base | 100 | Apache-2.0 |
| mickeyyaya/evolve-loop | 100 | Apache-2.0 |
| j0hanz/j0hanz-marketplace | 100 | MIT |
| kriscard/kriscard-claude-plugins | 100 | MIT |
Database snapshot: 13.11.2026 · package version 483df16cc489 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90refactor-safely
Refactor code without changing what it does (rename, extract, split files, remove duplication, simplify). Use when the user says "clean this up", "refactor", "split this file", "simplify this function", "rename X everywhere", or "remove this duplication". - 95simplify
Use when the user wants to simplify or clean up code without changing behavior. Accepts standalone scope or user-selected findings from /refactor. - 86simplify
Use when the user asks to simplify, clean up or refactor recently changed code without changing what it does (duplication, dead code, needless complexity). - 100dx-simplify
Simplify working code without changing its behavior — Chesterton's Fence, Rule of 500. Use for 'simplify', 'reduce complexity', 'refactor for clarity'. - 84refactor-code
Refactor code with safety checks and pattern application. Use when user says "refactor this code", "clean up this function", "simplify this logic", "extract this into a separate function", "apply the strategy pattern here", "reduce the complexity of this module", or "reorganize this file structure". - 100acp-refactor
Use when the user asks to refactor, clean up, simplify, modularize, deduplicate, rename, or improve the structure of existing code WITHOUT changing behavior. If the user wants new behavior, do not use this skill. Enforces small reversible steps and behavior preservation.