agentleFS
89jobrien89jobrien/godmode/skills/decompose/SKILL.md

godmode:decompose

Skill1 starsChanged 56 days agoMITView on GitHub

Use when the user wants to break up a large diff, PR, or branch into smaller independent PRs or branches. Handles mechanical analysis (file-to-crate mapping, concern classification, coupling detection), proposes a decomposition plan, requires explicit approval, then executes the split (creates branches, stages subsets, runs taskit check compile per split, optionally opens PRs). Trigger on "decompose this PR", "split this branch", "this diff is too big", "break this into smaller PRs", "make this reviewable", "/decompose", or any request to split a large changeset into independent units.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the branch has more than one commit, also inspect the commit log for structure clues:

    line 47
  2. Distinctive:

    Run the analyzer. This is deterministic — no LLM judgment yet.

    line 63
  3. Distinctive:

    Read and summarize the report.

    line 88
  4. Distinctive:

    Run the splitter for each approved split:

    line 144
  5. Distinctive:

    If checks pass: commits with a conventional message

    line 163
  6. Distinctive:

    If checks fail: reports failure, rolls back the branch, stops — does not continue to next split

    line 164
  7. Distinctive:

    After all splits pass:

    line 168
  8. Distinctive:

    If the user wants PRs opened:

    line 185
  9. Very specific:

    If any split failed verification, list it as FAILED with the failure summary.

    line 229
  10. Distinctive:

    Source branch is read-only: Never commit to it, never delete it.

    line 236
  11. Distinctive:

    Plan approval is required: No git mutations before the user says go.

    line 237
  12. Distinctive:

    Coverage check: After all splits, verify every changed file appears in exactly one split.

    line 240

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

godmode:decompose — Diff Decomposition Agent

Splits a large diff or branch into independent, reviewable units. Mechanical analysis runs first and is fully verifiable. LLM judgment is used only where the mechanical analysis is ambiguous — and always requires explicit user approval before any git mutations occur.

Helpers

FilePurpose
helpers/analyze-diff.nuMechanical analysis: file→crate map, concern classification, coupling detection
helpers/split-branch.nuBranch creation, file staging, per-split verification loop
helpers/decompose-proptest.rsProperty tests for grouping and coverage invariants
references/split-strategies.mdDecision guide for ambiguous grouping calls

Step 0 — Identify the input

Determine what to decompose:

# Option A: current branch vs main
git diff main...HEAD --name-only

# Option B: a specific PR
gh pr diff <number> --name-only

# Option C: patch file provided by user — read it directly

If the branch has more than one commit, also inspect the commit log for structure clues:

git log --oneline main..HEAD

Record:

  • Source branch: the branch being decomposed (never modified)
  • Base: the branch to split against (default: main)
  • Changed files: full list with paths

Step 1 — Mechanical analysis

Run the analyzer. This is deterministic — no LLM judgment yet.

nu skills/decompose/helpers/analyze-diff.nu \
  --base main \
  --branch $(git branch --show-current) \
  | save --force .ctx/godmode/decomps/$(git branch --show-current | str replace '/' '-')-analysis.json

The analyzer produces a JSON report with:

{
  "files": [...],
  "crate_groups": { "crate-name": ["path/to/file.rs", ...] },
  "concern_groups": { "tests": [...], "deps": [...], "docs": [...], "logic": [...] },
  "coupling_warnings": [
    { "files": ["a.rs", "b.rs"], "reason": "shared import: crate::foo::Bar" }
  ],
  "proposed_splits": [
    { "id": 1, "files": [...], "crate": "crate-name", "concern": "logic", "coupled_to": [] }
  ]
}

Read and summarize the report. Surface all coupling warnings — these are files the mechanical analysis grouped separately but that share a type or module import. They may need to move together.


Step 2 — LLM review of proposed splits

Review the mechanical groupings with judgment:

  1. Check coupling warnings — if two proposed splits share a public API type or trait impl, merge them. The mechanical analysis detects imports but not semantic dependency. Read references/split-strategies.md for decision heuristics.
  2. Check group sizes — a split with 1 file and a split with 40 files suggests the coarse grouping needs subdivision. Apply concern sub-classification (see split strategies).
  3. Name each split — use a conventional branch name: <source-branch>-split-<N>-<scope> (e.g., feat/auth-split-1-core, feat/auth-split-2-tests)
  4. Write a one-line rationale for each split: why these files belong together and why they are independent from the other splits.

Step 3 — Present the decomposition plan

Show the full plan before doing anything. Format:

Decomposition plan for: <branch> (N files changed)

Split 1: <name>
  Branch: <branch-name>
  Files: N files
    - crates/foo/src/lib.rs
    - crates/foo/src/bar.rs
  Rationale: <one line>
  Coupling risk: none | <warning if any>

Split 2: <name>
  ...

Coupling warnings (review before approving):
  - a.rs and b.rs both import crate::foo::Bar — confirm they can ship independently

Dry run? [y/n] — reply 'go' to execute, 'adjust' to modify the plan, or give me new groupings.

Do not proceed until the user explicitly confirms. This is the guardrail. Every split that is created after this point was approved by the user.


Step 4 — Execute the splits

Run the splitter for each approved split:

nu skills/decompose/helpers/split-branch.nu \
  --source <source-branch> \
  --base main \
  --split-id 1 \
  --branch <split-branch-name> \
  --files "path/a.rs path/b.rs ..." \
  --output-dir .ctx/godmode/decomps/<decomp-name>

The splitter:

  1. Checks out main (or base)
  2. Creates the split branch
  3. Cherry-picks by file: git checkout <source-branch> -- <files>
  4. Runs taskit check compile
  5. Runs taskit test run (or scoped to affected crates)
  6. If checks pass: commits with a conventional message
  7. If checks fail: reports failure, rolls back the branch, stops — does not continue to next split

Process splits sequentially, not in parallel. A failing split must be resolved before continuing.

After all splits pass:

# Verify no file was dropped — writes result to .ctx/godmode/decomps/
nu skills/decompose/helpers/analyze-diff.nu --verify-coverage \
  --source <source-branch> \
  --splits "split-1-branch split-2-branch ..." \
  | save --force .ctx/godmode/decomps/<decomp-name>/coverage.json

Coverage check: the union of all split files must equal the source branch file list. Report any files that appear in the source but no split (orphaned files).


Step 5 — Open PRs (optional)

If the user wants PRs opened:

gh pr create \
  --base main \
  --head <split-branch> \
  --title "<conventional title for this split>" \
  --body-file - <<'EOF'
## Summary
<rationale from plan>

## Part of
Decomposed from #<original-PR-number-or-branch>.
Depends on: #<prior-split-PR> (if sequential dependency exists)

## Files
- crates/foo/src/lib.rs
- crates/foo/src/bar.rs

## Test plan
- [ ] taskit test run passes
- [ ] clippy clean
EOF

Print each PR URL as it's created.


Step 6 — Report

Decomposition complete: <source-branch> → N splits

Split 1: <name> | <sha> | PR #<N> <url>
Split 2: <name> | <sha> | PR #<N> <url>
...

Coverage: all N changed files accounted for.
Orphaned: none | <list if any>

Source branch <source-branch> was not modified.

If any split failed verification, list it as FAILED with the failure summary. The source branch is always intact regardless.


Guardrails

  • Source branch is read-only. Never commit to it, never delete it. All splits branch from base.
  • Plan approval is required. No git mutations before the user says go.
  • Sequential verification. Each split must pass taskit check compile + nextest before the next begins. A failing split halts the process — do not skip forward.
  • Coverage check. After all splits, verify every changed file appears in exactly one split. Files in multiple splits or no split are bugs.
  • Coupling warnings are not blockers — but they must be shown. The user decides whether to merge the affected splits or accept the dependency.
  • Dry-run by default on ambiguous inputs. If uncertain what the user wants decomposed, ask rather than acting.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.