Skip to content

feat: add gw split command for branch decomposition - #35

Merged
jondeibel merged 1 commit into
mainfrom
gw-split
Mar 9, 2026
Merged

jondeibel merged 1 commit into
mainfrom
gw-split

Conversation

@jondeibel

Copy link
Copy Markdown
Owner

Summary

  • Adds gw split command that decomposes a fat branch into a clean stack of focused branches
  • Interactive TUI with bucket assignment (navigate commits, assign to named branches with color-coded display)
  • Non-interactive --plan <file> mode for scripting
  • Cherry-picks commits one-at-a-time with full conflict handling (--continue/--abort)
  • Crash-safe state persistence via SplitState in state.toml
  • Mid-stack splits automatically rebase descendants onto the new leaf
  • Works on both tracked (in-stack) and untracked branches
  • Original branch kept as backup

Files changed

  • src/commands/split.rs — Execution engine: plan parsing, cherry-pick state machine, continue/abort, finalize
  • src/commands/split_tui.rs — Interactive TUI with bucket assignment, viewport scrolling, text input mode
  • src/cli.rs — Commands::Split with --plan, --base, --name, --yes, --continue, --abort
  • src/main.rs — Split dispatch + polymorphic state guard (ActiveState)
  • src/state.rs — SplitState, SplitBucket, ActiveState enum, load_active_state()
  • src/context.rs — active_state(), save_split_state(), remove_state()
  • src/git.rs — cherry_pick(), cherry_pick_continue/abort(), delete_branch(), log_commits()
  • src/validate.rs — validate_sha()
  • tests/split_test.rs — 13 integration tests
  • README.md, CLAUDE.md, SKILL.md — Documentation updates

Test plan

  • 45 unit tests pass (including 10 new split plan parsing tests)
  • 13 new integration tests covering: happy path, tracked/untracked branches, mid-stack descendant rebase, conflict abort, precondition checks (dirty tree, merge commits, single commit, single bucket, branch collisions), state guard, plan file validation
  • All 101 existing tests still pass
  • Manual test: created a 6-commit branch, split into auth (3 commits) + dashboard (3 commits) via plan file — verified branches, files, stack config, tree output

🤖 Generated with Claude Code

Split a fat branch with many commits into a clean stack of focused branches.
Supports interactive TUI with bucket assignment and non-interactive --plan file mode.
Cherry-picks commits one-at-a-time with full conflict handling (--continue/--abort),
crash-safe state persistence, and automatic descendant rebasing for mid-stack splits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jondeibel
jondeibel merged commit 93a0d85 into main Mar 9, 2026
1 check passed
@jondeibel
jondeibel deleted the gw-split branch March 9, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant