refactor-architecture
Skill1 starsChanged 3 months agoMITView on GitHub
Redesigns the structure of existing code when that structure makes change expensive: tangled boundaries, logic in the wrong layer, one small change touching many files. Use when the structure of existing code is what makes change expensive and needs redesigning, or when the user says this codebase is a mess, everything imports everything, or every feature makes the next one slower. Skip designing a new system, quick local cleanups, and read-only audits.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- QuentinHsu/skillstheir own version, first seen May 10, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- QuentinHsu/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- working-from-a-ticketSkill
- writing-specsSkill
- clarifying-intentSkill
- dispatching-parallel-agentsSkill
- handoffSkill
- mapping-the-codebaseSkill
- prototypingSkill
- using-git-worktreesSkill
- using-sdlc-skillsSkill
- viewing-artifactsSkill
- writing-skillsSkill
- yagniSkill
- finishing-a-branchSkill
- release-readinessSkill
- architecture-decisionsSkill
- coding-standardsSkill
- data-modelSkill
- migration-strategySkill
- reviewing-plansSkill
- system-architectureSkill
- ui-ux-designSkill
- writing-plansSkill
- adding-observabilitySkill
- changing-a-live-schemaSkill
- executing-plansSkill
- rollout-controlsSkill
- subagent-driven-developmentSkill
- test-driven-developmentSkill
- complexity-auditSkill
- containing-an-incidentSkill
- debuggingSkill
- deprecating-an-apiSkill
- diagnosing-a-sessionSkill
- eliminating-correctionsSkill
- large-scale-changesSkill
- post-mortemSkill
- brainstormingSkill
- define-goalsSkill
- feasibility-checkSkill
- scopingSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- reviewing-a-prSkill
- security-auditsSkill
- verification-before-completionSkill
- verification-strategySkill
- visual-ui-verificationSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 43
Run the deletion test on each suspect module.
- Distinctive: line 46
Add a seam only for repeated behavior with a stable owner and measured change friction, or for one real volatile or external boundary with …
- Very specific: line 54
If a choice is hard to reverse, invoke architecture-decisions.
- Very specific: line 70
Ask this and end the turn.
- Distinctive: line 71
If the inputs drift, or what was approved changes, that needs an approved successor, and the slices it affects are invalid.
- Distinctive: line 76
Only after the exact scope and the decision authority are in place,
- Distinctive: line 84
If a behavior delta appears, stop.
- Distinctive: line 86
Before removing a surface, inventory every path that could still reach it: static calls, dynamic registration, reflection, configuration, …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Refactor Architecture
Improve the structure of code that already exists. The goal is deep
modules, a lot of behaviour behind a small interface, and locality, so
a change lives in one place. Read references/vocabulary.md when a term
below reads unfamiliar; it defines the words these steps lean on: module,
interface, depth, seam, adapter, leverage, and the deletion test.
When to use
- An existing codebase has friction: a change bounces you across many files, modules are thin wrappers, tests couple to internals, seams leak.
- Skip for greenfield design (
system-architecture) or a one-off local fix.
Step 1: Classify and measure
- Fill the classification block (the structural proposal's High-risk classification section). If all four answers are on the ordinary route, stay here. If any answer is not, wait for an approved, current migration and assurance contract and for the entry gates to pass. Work authorized as a prerequisite takes in only its exact proposed contract; it cannot edit the target, approve the contract, or satisfy entry.
- Pin down the exact source revision, the contracts it must honour, and the external inputs it consumes.
- Inventory the surface and the friction, giving each item a stable ID. Trace callers, behavior, the performance and resource profile, and the compatibility surface. Friction that has not been measured is a preference.
- REQUIRED SUB-SKILLS: invoke
using-git-worktrees, thentest-driven-developmentfor the preservation cycle in that workspace: the baseline green, a deliberate divergence red, the exact restoration green. An oracle that is compile-only or derived from the target is not enough.
Step 2: Decide the structure
- Run the deletion test on each suspect module. If removing it would spread complexity to its callers, keep it. If the complexity would merely relocate, collapse it.
- Add a seam only for repeated behavior with a stable owner and measured change friction, or for one real volatile or external boundary with measured impedance, failure policy, or test isolation. Never add one for implementation count or for hypothetical variation.
- Fill
assets/structural-proposal.mdbefore presenting it: the distinct structures compared, the removals and where their invariants now live, the slice table, and the approver rule. The decision outcome and the slice progress stay outside it. - If a choice is hard to reverse, invoke
architecture-decisions. Present the proposal. Never pick the structure yourself:
Structural proposal {{identity (per template)}} Friction: {{measured, one line}} Target: {{one line}} Alternatives: {{list}} Slices: {{n}} Rollback: {{one line}} 1. Approve under the preservation gate 2. Request changes 3. Reject and retain the current structure 4. Cancel Recommendation: {{option the friction and recovery evidence support}} — {{one sentence}}.Ask this and end the turn;
clarifying-intentowns what closes it.- If the inputs drift, or what was approved changes, that needs an approved successor, and the slices it affects are invalid.
Step 3: Transform under preservation
- Only after the exact scope and the decision authority are in place,
REQUIRED SUB-SKILLS: invoke
test-driven-developmentandyagni. If the slices take more than one step, invokewriting-plans; its mode answer names the executor. - For each slice: migrate its callers, run the bound gate and the project
gate (the checks its row of the slice table names), compare against the
accepted floors, and retain the known-green state. Checkpoint under
using-git-worktrees. - If a behavior delta appears, stop. Return to its requirement or to a new-behavior cycle.
- Before removing a surface, inventory every path that could still reach it: static calls, dynamic registration, reflection, configuration, generated inputs, tests, and external consumers. If unsure, it stays, or waits for a completed deprecation and migration.
- Map every invariant the surface carried to the coverage that survives. Falsify that surviving gate. Keep the rollback recoverable until integration.
Gotchas
- A surface with zero static callers can still be reached through dynamic registration, reflection, or a generated config — a plain call-site search finds none of those and reads as proof the surface is dead when it is only unproven.
- The deletion test's "removal spreads complexity to callers" branch is only as good as the caller trace behind it: run it against a guessed caller set and a genuinely load-bearing module reads as a thin wrapper worth collapsing.
Common mistakes
- Refactoring for tidiness, not leverage: change structure only where it cuts real friction.
- Combining so many structural moves that behavior, performance, compatibility, or rollback can no longer be attributed to one slice.
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.

