refactor
Improve existing code without changing behavior — split large functions, backfill tests, simplify.
Skill by helderberto
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/helderberto-refactor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/refactor
What's inside
- Skill name
refactor- 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).
- License
- MIT
- Instructions
- 38 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# 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.
From helderberto/agent-skills, MIT.
More from helderberto/agent-skills
- 0.646score
safe-repo
helderberto
Scan the repository for committed secrets and sensitive data; `--diff [<base>]` scopes to a branch's changes.
SkillAFreshness: A★ 17Claude Code +9 - 0.646score
tdd
helderberto
Test-driven development, from unit to end-to-end tests.
SkillAFreshness: A★ 17Claude Code +9 - 0.646score
visual-review
helderberto
Two visual modes — render a PR diff as an HTML page with each hunk annotated by principle, or check a UI change in a real browser (screenshots, console…
SkillAFreshness: A★ 17Claude Code +9 - 0.646score
prototype
helderberto
Build a throwaway prototype — a shareable HTML demo for state/logic questions, or several UI variations toggleable from one route.
SkillAFreshness: A★ 17Claude Code +9 - 0.646score
codebase-design
helderberto
Shared vocabulary for designing deep modules — interface, seam, depth.
SkillAFreshness: A★ 17Claude Code +9 - 0.643score
to-doc
helderberto
Turn an investigation, data, or a decision into a doc for readers across the company, published to Confluence, a GitHub issue, or Markdown.
SkillAFreshness: A★ 17Claude Code +9 - 0.643score
triage
helderberto
Classify any input — idea, bug, ticket key, `#42`, PR URL, stack trace — size it, and name the command to type; with no args, report where you are.
SkillAFreshness: A★ 17Claude Code +9 - 0.643score
build
helderberto
Implement the next unblocked ticket test-first and commit it, or fan every ticket out to parallel subagents with `--all`.
SkillAFreshness: A★ 17Claude Code +9 - 0.641score
commit
helderberto
Group unstaged changes into atomic commits by concern, matching repository style.
SkillAFreshness: A★ 17Claude Code +9 - 0.641score
feedback
helderberto
Fetch unresolved review comments on a GitHub PR (Copilot and human), verify against the code, classify Address / Skip / Optional / Discuss.
SkillAFreshness: A★ 17Claude Code +9 - 0.641score
harden
helderberto
Harden code where untrusted input enters the system.
SkillAFreshness: A★ 17Claude Code +9 - 0.641score
domain-modeling
helderberto
Build a project's domain model — challenge terms, pin down a ubiquitous language, write the glossary down.
SkillAFreshness: A★ 17Claude Code +9
Signals
- Stars
- 17
- Forks
- 2
- Open issues
- 0
- Last commit (this folder)
- Oct 23, 2026 (6 days ago)
- Last release
- Oct 24, 2026 (5 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/helderberto/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from helderberto
- 0.646score
visual-review
helderberto
Two visual modes — render a PR diff as an HTML page with each hunk annotated by principle, or check a UI change in a real browser (screenshots, console…
SkillAFreshness: A★ 17Claude Code +9 - 0.646score
tdd
helderberto
Test-driven development, from unit to end-to-end tests.
SkillAFreshness: A★ 17Claude Code +9 - 0.646score
safe-repo
helderberto
Scan the repository for committed secrets and sensitive data; `--diff [<base>]` scopes to a branch's changes.
SkillAFreshness: A★ 17Claude Code +9 - 0.646score
prototype
helderberto
Build a throwaway prototype — a shareable HTML demo for state/logic questions, or several UI variations toggleable from one route.
SkillAFreshness: A★ 17Claude Code +9 - 0.646score
codebase-design
helderberto
Shared vocabulary for designing deep modules — interface, seam, depth.
SkillAFreshness: A★ 17Claude Code +9 - 0.643score
build
helderberto
Implement the next unblocked ticket test-first and commit it, or fan every ticket out to parallel subagents with `--all`.
SkillAFreshness: A★ 17Claude Code +9
Cite this page
refactor skill. Agent Mart. https://agentmart.dev/skills/helderberto-refactor (last updated 2026-10-24)