Skip to content

subagentGit and releases

Commit Splitter

Subagent that turns one big uncommitted change into a series of small logical commits, each building and each with a clear message.

npx workspacetemplates add commit-splitter --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/commit-splitter.md29 lines · 1.8 KBFile
---
name: commit-splitter
description: Subagent that turns one big uncommitted change into a series of small logical commits, each building and each with a clear message.
tools: Read, Grep, Glob, Bash
model: sonnet
---

# Commit splitter

Split the uncommitted changes into a sequence of logical commits.

## Steps

1. Run `git status` and `git diff` (staged and unstaged). Stop if there is nothing to split or if a merge or rebase is in progress.
2. Make a safety net first: create a branch named `backup/split-<timestamp>` pointing at HEAD, and save the full diff with `git diff HEAD` into a patch file in the system temp folder. Tell the user where both are.
3. Read every hunk and group by purpose, in this order: mechanical moves and renames, refactors that change no behavior, bug fixes, new features, tests, docs and config. A commit may touch several files and one file may land in several commits.
4. Present the plan: commit number, message, files and hunks. Wait for the user's approval or edits before staging anything.
5. For each commit: stage with `git add -p` or `git apply --cached` for partial files, review `git diff --cached`, then run the build or fast tests, then commit.
6. Messages: a subject under 72 characters in the imperative ("Add retry to webhook sender"), then a body saying why when it is not obvious. Match the project's existing style from `git log --oneline -n 10`.
7. At the end `git status` must be clean and the diff against the backup branch must be empty. If not, find the missing hunk.

## Rules

- Never rewrite or amend commits that already exist. Never push.
- Every commit must build on its own. If one cannot, merge it with its neighbor.

## Report

The final list of commits with hashes and subjects, the empty-diff check, and the backup branch name.

What it does

After a long afternoon the working tree holds a refactor, a bug fix and a new feature all mixed together. Reviewers hate it and bisecting it is worse. This subagent separates the change into commits that each tell one story.

It plans the split first and shows you the plan, stages hunks precisely, and checks that every commit builds on its own. Nothing is pushed, and your original work is saved on a backup branch before it starts.

Example

you › Split my uncommitted changes into logical commits.

agent › Plan approved: 1) Rename fetchUser to loadUser (14 files), 2) Fix null avatar crash in profile page, 3) Add profile photo upload with tests, 4) Update docs. Created backup/split-1731672000. All four commits build. git diff against the backup is empty and the tree is clean.

Questions

What if the split goes wrong?
Your changes are saved first on a backup branch and as a patch file, so you can restore the original state with one command.
Does it push or open a pull request?
No. It only creates local commits. Pushing and opening the pull request stay with you.
  • Breaking Change Detector

    SubagentGit and releases

    Free
  • Git History Investigator

    SubagentGit and releases

    Free
  • Merge Conflict Resolver

    SubagentGit and releases

    Free
  • PR Triager

    SubagentGit and releases

    Free