refactor-architecture
Skill1 starsChanged 4 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 repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- 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
- executing-plansSkill
- subagent-driven-developmentSkill
- test-driven-developmentSkill
- complexity-auditSkill
- containing-an-incidentSkill
- debuggingSkill
- diagnosing-a-sessionSkill
- post-mortemSkill
- define-goalsSkill
- feasibility-checkSkill
- scopingSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- security-auditsSkill
- verification-before-completionSkill
- verification-strategySkill
- visual-ui-verificationSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
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
- Very specific: line 64
Ask through the harness's user-input action when one exists, else print this block.
- Very specific: line 70
Only after exact scope and decision authority: REQUIRED SUB-SKILLS: invoke test-driven-development and yagni.
- Distinctive: line 77
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 213,897 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. The vocabulary these
steps lean on — module, interface, depth, seam, adapter, leverage, and the
deletion test — is defined in references/vocabulary.md; open it when a
term below reads unfamiliar.
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. All four answers on the ordinary route → stay here. Any not → wait for an approved, current migration and assurance contract and passed entry gates. An authorized prerequisite consumes only its exact proposed contract; it cannot edit the target, approve the contract, or satisfy entry.
- Pin the exact source revision, the contracts it must honour, the external inputs it consumes.
- Inventory the surface and the friction with stable IDs. Trace callers, behavior, performance and resource profile, compatibility surface. Unmeasured friction is a preference.
- REQUIRED SUB-SKILLS: invoke
using-git-worktrees, thentest-driven-developmentfor the preservation cycle in that workspace: baseline green, deliberate divergence red, exact restoration green. Compile-only or target-derived oracle → insufficient.
Step 2: Decide the structure
- Deletion test per suspect module: removal spreads complexity to callers → keep; complexity merely relocates → collapse.
- Seam only for repeated behavior with a stable owner and measured change friction, or one real volatile or external boundary with measured impedance, failure policy, or test isolation. Never for count or hypothetical variation.
- Fill
assets/structural-proposal.mdbefore presenting it: distinct structures compared, removals and where their invariants now live, slice table, approver rule. Decision outcome and slice progress stay outside it. - Hard-to-reverse choice → invoke
architecture-decisions. Present. 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 through the harness's user-input action when one exists, else print this block; end the turn;
clarifying-intentowns what closes it.- Input drift, or a change to what was approved → an approved successor; affected slices invalid.
Step 3: Transform under preservation
- Only after exact scope and decision authority: REQUIRED SUB-SKILLS:
invoke
test-driven-developmentandyagni. Multi-step slices → invokewriting-plans; its mode answer names the executor. - Per slice: migrate its callers, run the bound and project gates, compare
accepted floors, retain the known-green state. Checkpoint under
using-git-worktrees. - Behavior delta → stop. Return to its requirement or new-behavior cycle.
- Before removing a surface, inventory every path that could still reach it: static calls, dynamic registration, reflection, configuration, generated inputs, tests, external consumers. Unsure → it stays, or waits for a completed deprecation and migration.
- Map every invariant the surface carried to surviving coverage. 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.

