Split a large pull request into reviewable commits

Break down overwhelming pull requests into clean, sequential, logically isolated commits. Use it when code reviews stall due to sprawling diffs.

You getCommit Strategy Overview, commit Breakdown and suggested Branch Execution

Prompt

Prompt
Act as a senior software architect specializing in git hygiene. Analyze the provided list of changed files, commits, or broad code diff to break it down into small, isolated, independently deployable units.
- Group changes by clean boundaries: infrastructure/config, database migrations, backend logic, frontend UI, and tests.
- Order the commits logically so dependencies are introduced before their consumers.
- Ensure each suggested commit maintains a working, buildable state without broken dependencies.
- Provide exact git commands where relevant to stage or branch the work safely.
Output format:
- Commit Strategy Overview: 1-2 sentences on the recommended sequencing.
- Commit Breakdown: numbered list where each item contains Commit Title, Target Files/Changes, and Why It Stands Alone.
- Suggested Branch Execution: step-by-step git branching commands to produce these commits cleanly.

Here is the list of changes:

Example output

Example for: git diff --stat showing auth rework, database migrations, and UI updates

Commit Strategy Overview

Isolate the schema changes and dependencies first, followed by the core backend service logic, and finish with user-facing interface adjustments so each stage builds cleanly.

Commit Breakdown
  1. feat(db): add organization_id to accounts schema

    • Target Files: migrations/20250214_add_org.sql, src/db/schema.ts
    • Why It Stands Alone: Adds the required nullable database column without breaking any active consumers or existing queries.
  2. feat(auth): update authentication service to inject organization context

    • Target Files: src/services/auth.ts, src/middleware/tenant.ts, tests/auth.test.ts
    • Why It Stands Alone: Implements backend multi-tenancy verification against the new column with complete test coverage while leaving routes untouched.
  3. feat(ui): display organization switcher in user settings

    • Target Files: src/components/OrgSelector.tsx, src/pages/Settings.tsx
    • Why It Stands Alone: Connects the front-end interface to the now-functional backend endpoints without mixing UI diffs with database migration code.
Suggested Branch Execution
git checkout -b refactor/db-migration
git add migrations/ src/db/schema.ts
git commit -m "feat(db): add organization_id to accounts schema"

git checkout -b refactor/auth-service
git add src/services/auth.ts src/middleware/tenant.ts tests/auth.test.ts
git commit -m "feat(auth): update authentication service to inject organization context"

git checkout -b refactor/org-ui
git add src/components/OrgSelector.tsx src/pages/Settings.tsx
git commit -m "feat(ui): display organization switcher in user settings"
Written by AI from this prompt. Your results will vary.

Paste the output of git status or git diff --stat after the prompt in ChatGPT, Claude, or Gemini. Follow up by asking how to use git rebase -i or git add -p to extract one specific slice.

Make it repeatable

Keep using this prompt without pasting it in every time.

Keep exploring

More in Coding