Safely split changes from the current branch into a separate pull request...
Safely extracts a subset of changes from your current branch into a separate, focused pull request.
git stash, git checkout -- ., or git reset --hard when there are staged or unstaged changesgit checkout <ref> -- <path> to investigate other branches - this modifies the working treegit show, git diff, git logCheck current state
git status
git branch --show-current
Understand what's in the PR (compare to target branch, usually development or main)
git log origin/development..HEAD --oneline
git diff origin/development --stat
Identify split candidates - Look for:
Investigate specific changes (READ-ONLY - use git show, not git checkout)
# View a file from another branch without modifying working tree
git show origin/development:path/to/file.ts
# Compare specific files
git diff origin/development -- path/to/file.ts
Present the user with:
Get user approval before proceeding.
Ensure clean state on source branch
git status # Must be clean or committed
Create new branch from target base
git checkout -b <new-feature-branch> origin/development
Apply changes using git checkout from source branch
# Now safe because we're on a new branch with no uncommitted work
git checkout <source-branch> -- path/to/file1.ts path/to/file2.ts
Handle renames/deletions
# For files that were renamed: delete old, add new
git rm path/to/old-name.js
git checkout <source-branch> -- path/to/new-name.ts
Make necessary adjustments for independence
Check TypeScript compiles
npx tsc --noEmit
Check linting passes
yarn lint:eslint:fix # or project equivalent
Run tests
yarn test # or project equivalent
Review the diff
git diff origin/development --stat
git diff origin/development # Full diff for review
Commit with clear message
git commit -m "refactor: descriptive message about the split changes"
Push and create draft PR
git push -u origin <new-feature-branch>
gh pr create --draft --base development --title "..." --body "..."
Report back with:
# If on new branch with uncommitted changes you want to discard:
git checkout <original-branch>
git branch -D <new-feature-branch>
# Find lost commits
git reflog
# Recover to a previous state
git reset --soft <commit-hash>
User: This PR is too big. Can we split out the TypeScript controller changes?
Claude: Let me analyze the PR to identify what can be split...
[Uses git diff origin/development --stat to see all changes]
[Uses git log to understand commit structure]
[Identifies controller files as independent]
Claude: I found 12 controller files that can be split. They have no
dependencies on the other 300+ component files. Want me to proceed?
User: Yes
Claude: Creating new branch and applying changes...
[Creates branch, applies changes safely, verifies compilation]
Claude: Done! Draft PR created: https://github.com/...
- 12 files, +459/-161 lines
- TypeScript compiles ✓
- Tests pass ✓