godmode:refactoring
Skill1 starsChanged 56 days agoMITView on GitHub
Guided refactoring with test discipline. Use when restructuring code without changing observable behaviour — extract, rename, reorganise, decouple.
In this repository76 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- godmode:agent-governanceSkill
- godmode:agent-improvement-loopSkill
- agents-skill-saveSkill
- baml-add-typesSkill
- godmode:brainstormSkill
- godmode:capSkill
- godmode:changelogSkill
- godmode:ci-fixSkill
- godmode:code-reviewSkill
- godmode:context-mapSkill
- godmode:cross-issueSkill
- godmode:crs-discoverSkill
- godmode:crs-hook-testingSkill
- godmode:crs-installSkill
- godmode:crs-propose-rulesSkill
- godmode:crs-validateSkill
- godmode:dead-codeSkill
- godmode:decomposeSkill
- godmode:dep-auditSkill
- godmode:dep-bumpSkill
- godmode:designSkill
- devloop-session-primerSkill
- godmode:dialecticSkill
- godmode:doc-maintainerSkill
- godmode:doc-reviewSkill
- godmode:doc-syncSkill
- godmode:doc-writerSkill
- doob-db-inspectorSkill
- doob-release-managerSkill
- godmode:doublecheckSkill
- dual-forge-pr-mergeSkill
- gh-bulk-issuesSkill
- godmode:health-scoreSkill
- godmode:ingestSkill
- godmode:introspectionSkill
- godmode:issue-triageSkill
- godmode:memory-bankingSkill
- godmode:mergeSkill
- godmode:mini-context-graphSkill
- godmode:mistake-trackerSkill
- godmode:moaSkill
- notfiles-release-workflowSkill
- godmode:observability-as-infrastructureSkill
- godmode:parallel-agentsSkill
- godmode:pattern-learnerSkill
- planning-with-cruxSkill
- godmode:pr-authorSkill
- godmode:receiving-reviewSkill
- godmode:release-notesSkill
- release-readiness-checkSkill
- remote-upstream-triageSkill
- repo-gap-backlogSkill
- godmode:rust-conventionsSkill
- rustqualSkill
- rustqual-workspaceSkill
- rust-release-workflow-authorSkill
- godmode:self-reflectSkill
- session-wrap-commit-pushSkill
- godmode:systematic-debuggingSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 10 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
If tests are red before you start, fix them first.
- Distinctive: line 31
When you're tempted to refactor and add a feature simultaneously — split the work
- Very specific: line 32
When tests don't exist yet — write tests first (godmode:task-driven-development)
- Distinctive: line 33
When the "refactor" would change public API behaviour — that's a feature change
- Distinctive: line 56
Do not expand scope without surfacing to user.
- Very specific: line 63
Run taskit test run — must stay green
- Distinctive: line 64
If red, revert and diagnose before proceeding
- Distinctive: line 69
No new public API surface unless explicitly approved
- Distinctive: line 70
No behaviour changes smuggled into the refactor
- Distinctive: line 74
Before committing, verify you are on the correct branch:
- Distinctive: line 101
Do not rename public items without checking all downstream callsites
- Very specific: line 102
Do not move items across crate boundaries without updating Cargo.toml deps
- Distinctive: line 103
Do not combine rename + extract in one step — rename first, verify green, then extract
- Very specific: line 107
Run godmode:code-review on your own diff before committing.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Refactoring
Core Rule
REFACTOR ONLY WHEN ALL TESTS PASS
Never change behaviour and structure at the same time.If tests are red before you start, fix them first. Refactoring on a red baseline hides regressions.
When to Use
- Extracting a helper that is duplicated 3+ times
- Renaming for clarity after the design has stabilised
- Decoupling I/O from pure logic (hexagonal prep)
- Removing dead code after a feature is complete
When NOT to Use
- When you're tempted to refactor and add a feature simultaneously — split the work
- When tests don't exist yet — write tests first (
godmode:task-driven-development) - When the "refactor" would change public API behaviour — that's a feature change
Process
1. Confirm green baseline
Run via
godmode verifyor use the commands below:
taskit test run
taskit check lintBoth must pass before touching anything.
2. State scope
Name exactly what you're changing and why:
- Which file(s)
- What pattern (extract, rename, move, inline, decouple)
- Why (duplication, clarity, coupling reduction)
Do not expand scope without surfacing to user.
3. Make one structural change at a time
Each change:
- Edit code
- Run
taskit test run— must stay green - If red, revert and diagnose before proceeding
4. Verify behaviour unchanged
- Tests pass with identical outcomes
- No new public API surface unless explicitly approved
- No behaviour changes smuggled into the refactor
5. Branch guard + full gate
Before committing, verify you are on the correct branch:
git branch --show-current # must NOT be mainRun via
godmode verifyor use the commands below:
taskit check fmt --check
taskit check lint
taskit test runCommon Refactoring Patterns (Rust)
| Pattern | Signal | Approach |
| Extract function | Block of code used 2+ times | Move to fn, pass args |
| Extract module | File > ~300 lines, mixed concerns | Split by responsibility |
| Extract trait | Two types share identical method set | Define trait, impl on each |
| Inline variable | Variable used once, name adds noise | Inline the expression |
| Decouple I/O | Pure logic calls std::fs | Pass &Path or Read trait bound |
| Rename | Name misleads or contradicts usage | Edit tool + Grep tool to find callsites |
Scope Rules
- Do not rename public items without checking all downstream callsites
- Do not move items across crate boundaries without updating
Cargo.tomldeps - Do not combine rename + extract in one step — rename first, verify green, then extract
After Refactoring
Run godmode:code-review on your own diff before committing.
Additional Resources
references/refactoring-patterns.md— extract function/module/trait, decouple I/O, rename patterns with code exampleshelpers/refactor-checklist.md— before/during/after checklist and scope creep check
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

