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: "humanize this", "unslop this", "de-slop this", "fix AI writing", "remove AI tells", "clean up AI prose". Edits prose to remove AI writing patterns and add human voice. Analyzes first, then asks how to fix. Prose complement to mine.clean-code.
development
Use when the user says: "why is this code like this", "why does this exist", "why was this built this way", "decision rationale", "what's the history behind". Decision archaeology — reconstructs historical rationale from evidence, not speculation.
development
Use when the user says: "how does X work", "walk me through", "explain this subsystem", "explain how", "trace the flow". Complexity-adaptive subsystem explanation — builds mental models conversationally, not documentation artifacts.
development
Use when the user says: 'create an issue', 'file an issue', 'open an issue', 'write an issue', 'new issue for this'. Codebase-aware issue creation — investigates the code to produce well-structured issues with acceptance criteria, affected areas, and enough detail for automated triage.