Help us improve
Share bugs, ideas, or general feedback.
From claude-agent-dev
Use when a codebase has structural problems (circular deps, God modules, testability issues) or when designing new systems. Trigger on 'architecture review', 'where should this code live', 'too coupled', 'God class', 'design this system'.
npx claudepluginhub j0hanz/claude-agent-dev-pluginHow this skill is triggered — by the user, by Claude, or both
Slash command
/claude-agent-dev:architectureThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
If the user's message provides no clear intent — a single word, a vague noun, no codebase context — ask one targeted question before selecting a mode:
agents/architecture-scanner.mdevals/evals.jsonreferences/ADR_TEMPLATE.mdreferences/DOMAIN_INTERVIEW.mdreferences/INTERFACE_SHAPES.mdreferences/MIGRATION_STRATEGIES.mdreferences/SEAMS_BY_EXAMPLE.mdreferences/architecture-patterns.mdscripts/check-locality.mjsscripts/check-locality.test.mjsscripts/detect-bleed.mjsscripts/detect-bleed.test.mjsscripts/detect-hotspots.mjsscripts/estimate-risk.mjsscripts/fixtures/a.tsscripts/fixtures/b.tsscripts/fixtures/c.tsscripts/fixtures/domain.tsscripts/git-coupling.mjsscripts/scaffold-boundary.mjsProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Guides systematic root-cause debugging when tests fail, builds break, or unexpected errors occur. Provides a structured triage checklist to preserve evidence, localize, and fix issues instead of guessing.
Share bugs, ideas, or general feedback.
If the user's message provides no clear intent — a single word, a vague noun, no codebase context — ask one targeted question before selecting a mode:
"Are you looking to diagnose an existing codebase, or design something new?"
Only apply the routing table once you have enough signal to distinguish Mode A from Mode B. Do not silently analyze a nearby codebase just because one exists; confirm it's the intended target first.
Read this first — pick one mode and follow only that section.
| Signal | Mode |
|---|---|
| Codebase already exists; user wants to find/fix structural problems (coupling, God modules, testability, circular deps) | MODE A — DIAGNOSE |
| New feature or module; user asks where logic should live, which pattern to pick, how to design interfaces | MODE B — DESIGN |
When in doubt: if there's code to look at and the user has indicated they want a diagnosis, use Mode A. If there's a blank page, use Mode B.
Surface deepening opportunities — places where a shallow module could become a deep one with better leverage, testability, and locality. Explore first, present candidates, then deepen conversationally. Don't design solutions before you've seen the problem.
Bundled guides in references/:
Load these as needed during the 3-phase procedure.
Claude, you already understand SOLID principles and cohesion. Do not regurgitate them. Instead, apply these battle-tested diagnostics for identifying poor boundaries:
Architectural refactoring fails when it adds indirection without adding depth. NEVER propose the following common AI-flavored refactoring mistakes:
utils/, controllers/, types/). This destroys locality. Always group by domain concept (e.g., billing/, auth/). A utils/ folder is a complexity graveyard.Walk the codebase using the automated analysis scripts. Scripts gracefully skip inaccessible directories and unreadable files. All scripts support TypeScript, JavaScript, and Python projects — no configuration needed.
node <skill-dir>/scripts/check-locality.mjs [dir] to find circular dependencies and "God modules" (high fan-out). Example: node <skill-dir>/scripts/check-locality.mjs srcnode <skill-dir>/scripts/detect-bleed.mjs [domain_dir] [infra_packages] to find infrastructure leaks (e.g., Express or Prisma in domain logic). Examples: node <skill-dir>/scripts/detect-bleed.mjs src/domain express,prisma,typeorm — for Python/FastAPI: node <skill-dir>/scripts/detect-bleed.mjs src/domain sqlalchemy,django,flask,fastapi,celery,requestsnode <skill-dir>/scripts/git-coupling.mjs [dir] to find files that always change together in git history — the hidden coupling that import graphs cannot reveal. Example: node <skill-dir>/scripts/git-coupling.mjs src. If the output shows pairs with >5 co-changes that have no imports of each other, those are your highest-priority seam candidates.node <skill-dir>/scripts/detect-hotspots.mjs [dir] [infra_packages] for a single ranked table combining fan-out + bleed + churn + size into an Architectural Debt Score. Use this when you need to triage a large codebase quickly. Example: node <skill-dir>/scripts/detect-hotspots.mjs src express,prisma,sqlalchemyAfter scripts complete — spawn the architecture-scanner subagent (agents/architecture-scanner.md):
Agent(
description: "Architecture scan of [target_dir]",
prompt: |
target_dir: [the directory you scanned]
locality_output: [paste full stdout of check-locality.mjs here]
bleed_output: [paste full stdout of detect-bleed.mjs here]
git_coupling_output: [paste full stdout of git-coupling.mjs here, or "skipped — not a git repo"]
hotspot_output: [paste full stdout of detect-hotspots.mjs here, or "skipped"]
)
The agent reads every flagged file, applies the Deletion/Seam/Locality tests, and returns a candidates JSON array ranked by impact. Use that array as your Phase 2 input — each element maps directly to the candidate format in Phase 2. Skip manual file reading in the main context when the agent is available.
If no directory is available (user pasted inline code without a path):
Manual Exploration (if scripts don't fit the project structure, or no directory is available):
Look for these friction signals:
express.Request, database entity types, or UI frameworks (mechanism bleeding into policy).You must constrain yourself. Do NOT write implementation code, typed interface signatures, or seam proposals in Phase 2 — no function bodies, class implementations, interface definitions, or working logic. These belong exclusively in Phase 3 AFTER the user selects a candidate. List 3–6 deepening opportunities, ordered by impact. Use this exact format:
**[Short Name of Opportunity]**
- **Files:** `src/foo.ts`, `src/bar.ts`
- **The Bleed:** [1 sentence: What mechanism is leaking, or what makes this shallow?]
- **The Deepening:** [Plain English: Where the new boundary goes and why it increases leverage.]
- **Impact:** [Locality | Testability | AI-Navigability]
- **Risk:** [LOW | MEDIUM | HIGH] — [1 sentence: callers + test coverage + churn. e.g. "8 callers, no test file, changed 12 times in 90 days."]
Risk scoring guide (run node <skill-dir>/scripts/estimate-risk.mjs <root> <file...> for exact numbers, or estimate manually):
MEDIUM for files with multiple infrastructure imports, LOW for logic-only files. Label as: Risk: MEDIUM (estimated — no directory for caller count)Refer to SEAMS_BY_EXAMPLE.md in references/ for 3 real examples of good and bad seams.
Example candidate:
**Extract Auth Domain from Scattered Files**
- **Files:** `src/auth.ts`, `src/middleware.ts`, `src/utils.ts`, `src/routes/login.ts`
- **The Bleed:** Password hashing is in utils, JWT generation is in middleware, user lookup is in routes. Each change requires touching 4 files. Testing requires a database.
- **The Deepening:** Consolidate password hashing, token generation, and credential validation into one `auth/` module. Routes and middleware become thin adapters that call auth, not the other way around. Tests can mock the user lookup, so no database needed.
- **Impact:** Locality (auth logic concentrated in one module) | Testability (test password and token logic in isolation) | AI-Navigability (one module to understand instead of four)
- **Risk:** MEDIUM — 3 callers, no dedicated test file, changed 7 times in 90 days.
End your response exactly with:
"Which of these candidates interests you most?"
STOP HERE. Do not proceed to Phase 3 content (seam interfaces, domain interview, migration strategies) until the user has selected a candidate in their next message. Do not append bonus analysis, interface sketches, or migration notes below the question.
Once the user picks a candidate, do NOT start writing code immediately.
Align Terminology: Conduct a brief interview (1 question at a time, see DOMAIN_INTERVIEW.md in references/) to establish Canonical Terms and resolve ambiguous concepts.
Propose the Seam: Only after the domain language is clear, propose the concrete refactoring — specifically, the new interface shape using the agreed-upon glossary terms. Examples are in INTERFACE_SHAPES.md in references/. Show what callers will import and use; don't write implementation yet.
Apply the Deletion Test aloud: Ask the user: "If we deleted this module, where would the logic go?" If they say "it would duplicate across 5 callers," you've got a good deepening. If they say "it would just move to the caller," the module is shallow and needs rethinking.
Wait for user approval before modifying files.
Migration Path: When the user approves a seam, load MIGRATION_STRATEGIES.md from references/ and recommend the appropriate strategy for their situation (Strangler Fig for module replacement, Branch by Abstraction for inserting a new interface, Feature Flag if they need instant rollback). State the strategy name and the first concrete step.
Handoff: This skill diagnoses and proposes seams — it does not implement them. Once a seam is approved, execute it with the refactor skill for a behavior-preserving extraction, or hand the proposed seam to planning when the change spans multiple files or phases.
Required output for Mode A: A ranked candidate list (3–6 items in Phase 2 format) + a proposed seam interface (typed signatures only, no implementation bodies) for the user-selected candidate. No code changes. No file edits until the user explicitly approves and the appropriate downstream skill is invoked.
Stop proposing candidates when:
Architecture is the set of decisions that are hard to change later. Your goal is to maximize Reversibility and Boundary Integrity. Do not just "clean the code"; design the system to survive the "Churn of Infrastructure" (frameworks, DBs, APIs).
Before proposing a structure, run this diagnosis:
references/architecture-patterns.md to evaluate its failure modes before recommending.Once the user approves: load MIGRATION_STRATEGIES.md and name the appropriate strategy (Strangler Fig, Branch by Abstraction, Feature Flag, etc.) with its first concrete step. Then offer to scaffold the boundary skeleton:
node <skill-dir>/scripts/scaffold-boundary.mjs <domain> <pattern> [output-dir]
# pattern: hexagonal | vertical-slice | layered
# Example: node <skill-dir>/scripts/scaffold-boundary.mjs notifications hexagonal src
The scaffold generates typed interface stubs (ports, adapters, entities) as a starting point with no implementation. Invoke the refactor or planning skill for implementation once the user confirms the scaffold structure.
shared module that couples them forever.utils, common, and shared are where architectural integrity goes to die. If logic is shared, it usually belongs in a named domain concept or a specific infrastructure adapter.@nestjs/common, Express.Request).Do NOT escalate to architecture if:
Manager, Processor, Service) without a domain prefix that explains the what.Required output for Mode B: A proposed public surface (interface/type signatures — no implementation bodies), the result of the Swap Test stated explicitly ("If we swapped X, only Y would change"), and a single ADR entry using the template in references/ADR_TEMPLATE.md. After user approval, proceed to Step 4 (migration strategy + scaffold offer).