skills/mine.decompose/SKILL.md
Use when the user says: 'decompose this', 'find decomposition opportunities', 'what should I split', 'break this apart', 'this file is too big', 'split opportunities', 'extract candidates', 'find god classes'. Analyzes code for decomposition opportunities — prioritized by Git behavioral signals and structural metrics, with concrete split suggestions.
npx skillsauth add NodeJSmith/Claudefiles mine.decomposeInstall 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.
Analyzes a codebase (or portion of it) for decomposition opportunities — files that should be split, god classes that need extraction, functions doing too much. Prioritizes by ROI using Git behavioral signals (what changes often) combined with structural metrics (what's complex), then proposes concrete splits with before/after sketches.
$ARGUMENTS — optional target scope. Can be:
/mine.decompose src/services//mine.decompose src/services/payment.py/mine.decompose "god classes" or /mine.decompose "coupling hotspots"Read the code and reason about it directly. Subagents use Read, Grep, Glob to examine files. Do NOT write or execute analysis scripts — no AST parsers, no custom complexity calculators.
Allowed commands during analysis:
git log / git shortlog / git diff-tree / git show — churn, change coupling, developer dispersion, per-commit diffswc -l — file and function size countsfind / grep — file discovery, import/fan-in analysissort, uniq, head, xargs — text processing for git output pipelines<concern_filter> to that keyword — this narrows what subagents look for in Phase 2. If it's a path, set <concern_filter> to empty.find <scope> -type f \( -name '*.py' -o -name '*.ts' -o -name '*.js' -o -name '*.go' -o -name '*.rs' -o -name '*.java' \) | wc -l (adapt extensions to project language). If >200: stop here, ask the user to narrow scope, and restart Phase 1 with the new scope.Run get-skill-tmpdir mine-decompose to create a temp directory.
Squash-merge caveat: If git log --oneline | head -50 shows mostly single-commit merges (squash-merge workflow), note this in the report. Change coupling data is diluted — functions bundled in the same PR appear coupled even when they aren't. The behavioral signals are still directionally useful if PRs are reasonably focused, but lean harder on structural signals for ranking when the history is squash-heavy.
Launch two subagents in parallel (both subagent_type: general-purpose, model: haiku). See REFERENCE.md for full prompt templates — substitute the actual <tmpdir> path, <scope>, and <concern_filter> into each template before dispatching.
Each subagent writes structured output to the tmpdir — the orchestrator reads both files in Phase 3 and joins on file path.
Writes to <tmpdir>/git-analysis.md. Examines Git history for decomposition signals:
Output must start with a per-file summary table: | file | commits_6mo | co_changing_files | authors | notes |
Writes to <tmpdir>/structural-analysis.md. Reads the code to assess structural signals:
Output must start with a per-file summary table: | file | lines | functions | clusters | fan_in | fan_out | notes |
Read <tmpdir>/git-analysis.md and <tmpdir>/structural-analysis.md. Join on file path — for each file, merge behavioral signals (churn, coupling, dispersion) with structural signals (size, clusters, fan-in/fan-out). Files appearing in only one report get partial data; note the gap.
Two-stage ranking: qualify (does this file clear any decomposition bar?), then rank (given qualifying signals, what priority?). Behavioral signals dominate structural when they conflict.
Qualification — a file is a decomposition candidate if ANY of these hold:
Do NOT qualify files that are cohesive, well-tested, and stable — size alone is not a decomposition signal.
Ranking — given qualified candidates, assign priority:
| Priority | Determining signal | |----------|--------------------| | HIGH | Behavioral signal present (high churn, change coupling violations, high developer dispersion) | | MEDIUM | Structural signals only (multiple clusters, high fan-in, large size) with low or no churn | | LOW | Single marginal signal (e.g., size threshold crossed but cohesive) |
For each HIGH and MEDIUM opportunity, propose a concrete split. See REFERENCE.md for the full output format. Each suggestion includes:
Before finalizing any suggestion, check for two failure modes:
coupling-delta field. If positive, drop the suggestion — splitting creates modules that must always change together, which is worse than the status quo.Write <tmpdir>/decomposition-report.md (same tmpdir from Phase 2). See REFERENCE.md for the full format template.
Present the top findings inline — lead with HIGH priority, include the key signal that flagged each, and show the proposed split in brief. End with: Full report at <tmpdir>/decomposition-report.md
AskUserQuestion:
question: "What would you like to do with these findings?"
header: "Next steps"
multiSelect: false
options:
- label: "Build top opportunity"
description: "Implement the highest-priority decomposition via /mine.build"
- label: "File as issues"
description: "Create GitHub issues for the decomposition opportunities"
- label: "Save report"
description: "Save to design/audits/ for future reference"
- label: "Done"
description: "Acknowledged — no action this session"
If the user chooses "Build top opportunity", invoke /mine.build with a description of the decomposition. If "File as issues", create one issue per HIGH/MEDIUM opportunity via gh-issue create. If "Save report", copy to design/audits/YYYY-MM-DD-decomposition/decomposition.md.
/mine.build/mine.audit — audit covers broad codebase health. This focuses specifically on decompositiondevelopment
Use when the user says: "document how X works", "write up how this works", "durable explanation", "explain this for the docs", "document this subsystem". Writes a durable, architectural-altitude explanation that survives code churn.
development
Use when picking up a fresh session after /clear, a stop, or an unanswered AskUserQuestion. Reconstructs the prior session's intent from its transcript tail and surfaces any unresolved decision; user-invoked only — for a hand-written end-of-day handoff use /mine-good-morning instead.
development
Use when the user says: "what did we discuss", "continue where we left off", "remember when", "as I mentioned", "you suggested", "we decided", "search my conversations", "find the conversation where", "what did we work on", or uses implicit signals like past-tense references, possessives without context, or assumptive questions. Direct search over past Claude Code sessions via cass.
tools
Use when the user says: "what context do I have", "relevant history for this task", "what have we done related to this". Also usable proactively when starting work that likely has prior history. Assembles a structured context brief from past session history via cass, scoped to the current task and workspace.