maji-refactorlisted
Install: claude install-skill Ijam18/MAJI-Skills
# maji-refactor — Scope-Guarded Refactoring
A skill that refactors code without sliding into "while I was there" syndrome.
---
## When to Use
Type `maji-refactor <target>: <intent>` where:
- target = file/function/module
- intent = the specific refactor goal
Examples:
- `maji-refactor src/auth.ts: extract token logic into separate module`
- `maji-refactor UserList component: switch from class to function with hooks`
- `maji-refactor src/api/: consolidate duplicate fetch helpers`
---
## The Refactor Protocol
### Step 1 — Define Scope
Write down explicitly:
- **What changes:** [files / functions / modules]
- **What stays the same:** [behaviour, public API, return shapes]
- **Out of scope:** [adjacent improvements I'll resist]
### Step 2 — Identify Minimum Diff
Find the smallest set of changes that achieves the intent. If diff exceeds expectation:
- Re-question scope
- Split into multiple refactors
### Step 3 — Pre-Action Gate
Before writing the refactor:
1. Are tests covering the behaviour I'm preserving?
2. If not, write tests FIRST (so the refactor has a safety net).
3. Will my refactor change any public API? If yes, document the migration.
4. Are there callers I haven't checked? If yes, list them.
### Step 4 — Apply Diff
- Touch only files in scope
- Preserve naming where possible (rename only when necessary)
- Keep diff readable in PR review
### Step 5 — Verify
- Run tests — all pass
- Diff is what was promised
- No "while I was there" changes
---
##