skills/architect-refactor/SKILL.md
Disciplined methodology for code architecture refactoring. Use when the user asks to refactor architecture, decouple code, restructure a family of classes, redesign an interface, or rename/reorganize a set of related components. Forces a big-picture analysis before any code is written. Do NOT use for simple bug fixes, feature additions, or single-file refactoring.
npx skillsauth add nicolas-codemate/claudecodeconfig architect-refactorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill is for architecture-level refactoring. Not for bug fixes, not for features, not for single-file polish. Use it when the job is to restructure how things fit together.
Trigger this skill when:
Do NOT use for:
DO NOT WRITE A SINGLE LINE OF CODE BEFORE THE 7 PHASES BELOW ARE COMPLETE.
This skill exists because micro-iterations during refactoring waste massive amounts of time. One clear plan up front beats 40 commits of corrections.
Before starting, internalize these principles. They are non-negotiable:
A ticket like "Decouple X from Y" describes a symptom. Your job is to find the disease. The disease is almost always bigger than the ticket.
Ask yourself:
Pretend the current code doesn't exist. Ask:
Then compare with reality. The gap is the refactoring scope.
If the right answer is "throw away 3 classes and make 1 new one", say so. Do not compromise by keeping legacy abstractions "because they exist". Existence is not a justification.
Cheap compromises to refuse:
The ticket scope is a hint, not a cage. If respecting the ticket scope produces bad architecture, the architecture wins. The ticket was written by someone who saw one symptom; you see the whole system.
Resist the urge to start coding the first phase. Resist the urge to "just get started". The 30 minutes spent on deep analysis save 4 hours of micro-iterations.
Find ALL the code that shares the pattern being refactored, not just what the ticket mentions.
Actions:
Output: A written inventory of the family. Example:
Family: query builders for server-side tables
- 1 interface (NativeQueryBuilderConfiguratorInterface)
- 1 concrete builder (DatatableQueryBuilder)
- 7 resolvers using it (GetInvestments, GetAccounts, ...)
- 8 configurator implementations
- 1 external consumer (FilterTypeResolver)
RULE: You cannot proceed to Phase 2 until this inventory is complete.
Look at the family with fresh eyes. Where are the duplications? Where are the inconsistencies?
Actions:
Output: A list of smells. Example:
- 5 query builders with ~80 lines of identical plumbing (getBaseQueryBuilder, handleSearch, addJoin)
- Abstract class with only one concrete child (= dead abstraction)
- `getAllSearchableColumns` implemented identically in 5 classes
- Namespaces: 3 files in `Datatable/`, 2 in `Query/`, 1 in `Service/` (inconsistent)
- Method names: `invoke`, `invokeV1`, `invokeV2`, `invokeAgGrid` (inconsistent)
RULE: If this list is empty, the refactoring is probably smaller than you think. Re-read the ticket.
Answer these before proposing any architecture. Do not skip any.
RULE: Write the answers down. Do not hand-wave. If you can't answer a question, that's a sign you need more discovery — go back to Phase 1.
Do NOT propose a single plan. Propose 2 or 3 target architectures with explicit trade-offs.
Format:
### Option A — Minimum viable
- Changes: X, Y
- Trade-offs: accepts duplication in Z, doesn't fix naming
- Effort: small
- Longevity: likely to be re-refactored within 6 months
### Option B — Complete decoupling
- Changes: X, Y, Z, W
- Trade-offs: touches all resolvers, requires doc update
- Effort: medium
- Longevity: stable for years
### Option C — Full redesign
- Changes: new namespace, new interface, new builder, migrate all
- Trade-offs: big churn, requires buy-in from team
- Effort: large
- Longevity: generational rewrite
RULE: Present options with honest trade-offs. Do not pitch. Let the user choose in full knowledge.
Before writing any code, validate every name with the user:
Why before: Renaming is cheap in a text editor, but every rename cascades into imports, tests, docs, and consumers. Validate once, rename never.
RULE: Present the chosen names as a list, get explicit validation, then lock them.
Write a plan with at most 6 steps. If the plan has 15 steps, you did not think enough in Phase 1–4.
Good plan example:
1. Create new interface + shared builder + composition helper
2. Migrate all property-aware resolvers
3. Migrate non-property resolvers (stakeholders, DMS)
4. Delete legacy code (old builder, old interface, dead methods)
5. Documentation pass (single pass, final architecture)
6. Full Behat validation
Bad plan example (DO NOT DO THIS):
1. Create a temporary query builder for Investment
2. Copy logic from DatatableQueryBuilder
3. Add one method to the abstract
4. Wire into GetInvestments resolver
5. Create a query builder for Account
6. ... (15 more steps)
RULE: Micro-steps = insufficient planning. Consolidate. If it's hard, Phase 1–4 were incomplete.
Only now, write code.
Rules during implementation:
Documentation pass: After ALL code is stable and all tests pass, do one single documentation pass. Not multiple. One.
If the user (or you) catches yourself doing any of these, STOP and go back to the appropriate phase.
| Anti-pattern | Fix | |--------------|-----| | Starting Phase 7 before Phase 3 is answered | Back to Phase 3 | | "Let's do the minimum for now and refactor later" | Present Option A/B/C and let user choose | | "This is out of scope" without justification | Re-read the ticket; is it really out of scope or are you avoiding work? | | Creating a class that duplicates another class | Stop. Go back to Phase 2. Find the real abstraction. | | Renaming something during implementation | Stop. Go back to Phase 5. Validate the new name. | | Updating documentation before the architecture is stable | Stop. Doc pass only at the end. | | "Let me fix just this one more thing" | Stop. Note it. Fix it in the planned sequence. |
Before starting Phase 7, verify:
If any box is unchecked, do not proceed.
Without discipline, architecture refactoring devolves into 30+ micro-commits, 8 renames, 5 doc rewrites, and a lot of wasted time. The user should not have to drag you back to the big picture at every step.
This skill is a forcing function. It makes you slow down at the start so you can move fast for the rest. The 30 minutes spent on Phases 1–4 save hours of iteration later.
Embrace it. It is not a constraint — it is a tool to protect the quality of your thinking.
Do not fear rewriting everything. If the honest answer is "throw it all out and start over", say so. The worst outcome is a half-refactored codebase that is worse than the original.
tools
--- name: deep-review description: Performs deep code review via an isolated fresh agent (triple perspective, anti-bias). Use when the user asks for an in-depth review of current branch changes, or when invoked by /resolve step 08. Do NOT use for reviewing PRs from GitHub (use review-pr skill instead) or for a quick correctness scan with effort levels (use bundled /code-review instead). argument-hint: [--ticket <id>] [--base <branch>] [--fix] [--severity <level>] allowed-tools: Read, Glob, Grep,
tools
Resolve git rebase conflicts methodically. Classifies each conflict (imports/namespace cleanup vs real logic clash), analyzes the commit introducing the change against the current ticket context, auto-fixes only trivial cases with a per-file summary, and asks the user when ambiguous. Verifies static analysis tools pass at the end and optionally runs functional tests. Use after `git rebase` triggers conflicts, or when the user asks to "resolve conflicts", "fix rebase", "j'ai des conflits", "aide-moi sur ce rebase".
development
Synchronize the markdown test plan in docs/qa/ with the current state of the codebase. Use after adding or modifying features to keep the plan up to date, or to bootstrap a test plan for the first time. Do NOT use to execute tests (use /qa-run instead) and do NOT use to design product specs (use /express-need instead).
tools
Execute the markdown test plan in docs/qa/ via Playwright MCP and create a ticket on each failing scenario. Use after /qa-sync, before a release, or to validate a feature end-to-end. Do NOT use to design or update scenarios (use /qa-sync instead) and do NOT use for visual regression (use visual-verify agent instead).