From eng-utils
Explore a codebase for architectural friction (scattered concepts, shallow modules, tight coupling), quantify issues with coupling metrics, design multiple interface alternatives via parallel agents, and produce a proposal document with old/new architecture diagrams and honest pros/cons. Proposal-only — never makes code changes. Use when asked to "refactor architecture", "improve codebase structure", "deepen modules", "reduce coupling", "make code more navigable", or when /code-review repeatedly surfaces structural issues. Invocable as /refactor-architecture [scope-path].
How this skill is triggered — by the user, by Claude, or both
Slash command
/eng-utils:refactor-architectureThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Identify structural problems at the module/component level and produce an architectural
Identify structural problems at the module/component level and produce an architectural
refactoring proposal. This skill operates between code-level simplification (/tidy) and
system-level documentation (/c4-architecture). It never makes code changes — all output
is a proposal document that feeds into /create-plan-tdd.
Parse $ARGUMENTS for:
src/services/)Explore the codebase organically, noting where understanding breaks down. The friction you encounter IS the signal.
Spawn codebase-explorer to navigate the scoped directory. Instruct it to:
Read architectural context if available:
~/.claude/thoughts/shared/architecture/ for a C4 workspace.dslClassify friction points: Read references/friction-patterns.md and classify each
discovered issue by pattern (Scattered Concept, Shallow Module, God Class, Tight
Coupling, Feature Envy, Missing Abstraction, Leaky Abstraction, Untested Integration Seam).
Compute quantitative signals (see Quantitative Signals section in
references/friction-patterns.md):
grep -rl "ConceptName" <scope> | wc -lgrep -c "^import" <file>grep -rl "ModuleName" <scope> | wc -l (estimates Ca)Present refactoring candidates to the user for selection.
Rank candidates by composite score:
Present numbered list. For each candidate show:
references/dependency-categories.md
(In-process / Local-substitutable / Remote-owned / External)Do NOT propose interfaces yet. Ask: "Which of these would you like to explore?"
Wait for user selection — one or multiple candidates.
For the selected candidate(s), design multiple radically different interfaces.
Frame the problem space (show to user):
Agent verification: create an explicit agent contract per
${CLAUDE_PLUGIN_ROOT}/commands/shared/agent-verification-pattern.md.
Spawn parallel general-purpose agents, each with a different interface constraint.
Choose the number and constraints appropriate to the problem. Example constraints:
Each agent receives a technical brief with: file paths, coupling details, dependency category, what complexity is being hidden. Each outputs:
references/dependency-categories.md)Present designs sequentially, then compare in prose. Evaluate on:
Give an opinionated recommendation: which design is strongest and why. If elements from different designs combine well, propose a hybrid.
Generate the architectural proposal document. This skill never makes code changes.
User picks interface or accepts recommendation.
Generate proposal using references/proposal-template.md:
Create output directory: mkdir -p ~/.claude/thoughts/shared/refactor-proposals/
Write proposal to ~/.claude/thoughts/shared/refactor-proposals/YYYY-MM-DD-description.md
Present summary to user with the file path and key findings.
Next step: "To implement this proposal, run /create-plan-tdd with the proposal
document path."
Read these files when the workflow reaches their relevant phase:
references/friction-patterns.md — Read in
Phase 1 when classifying friction points and computing quantitative signals. Contains
8 friction patterns with detection heuristics and severity thresholds, plus 3
navigability metrics (files-per-concept, context budget, module depth).
references/dependency-categories.md — Read
in Phase 2 when classifying dependency types for each candidate. Contains 4 categories
(in-process, local-substitutable, remote-owned, external) with testing strategies and
before/after examples.
references/proposal-template.md — Read in
Phase 4 when generating the output document. Contains the full proposal template with
YAML frontmatter, section structure, PlantUML C4 syntax guide, and navigability
metrics guide.
npx claudepluginhub jonnycbb/claude-code-config --plugin eng-utilsAudits codebase architecture for tightly-coupled modules and suggests refactors toward deep modules with simple interfaces. Use for architectural improvement, refactoring opportunities, or making code more testable.
Explores codebases to identify architectural friction and opportunities to deepen shallow modules, improving testability, refactoring, and AI navigability.
Scans codebase for architectural friction: shallow modules, tight coupling, untestable seams. Produces an HTML report with before/after diagrams and refactoring candidates.