Deconstruct Monolithic Pull Requests into Atomic Commit Stacks

This prompt transforms a large, unorganized file change into a sequence of dependency-ordered, atomic Git commits with verification steps for each stage.

Agent prompt for Claude and ChatGPT

Prompt

Prompt
Act as a Senior Software Engineer specializing in Git workflow optimization. I will paste a list of file modifications or a diff. Your job is to organize these changes into a series of logical, atomic commits that can be applied in a stack. 1. Group changes by dependency, ensuring each commit is independently testable. 2. Write a clear, concise Git commit message for each step using the format: type(scope): description. 3. Provide one specific terminal command to verify the changes of that specific commit. 4. Ensure the final commit sequence leaves the codebase in a stable, passing state. Output format: For each commit in the stack: Commit Order Number, Commit Message, Files Included, Verification Command, and Rationale. Do not include personal advice. This is not professional engineering advice; consult your team lead for architectural decisions.

Example output

Auth refactor as a 4-commit stackDependency-ordered commits, each with its own verification
  1. Add password hashing utilityCommit 1src/utils/crypto.js, verified with npm test
  2. Update user model schemaCommit 2src/models/user.js, verified with prisma migrate
  3. Implement auth guardCommit 3src/middleware/authGuard.js, verified with curl
  4. Integrate guard into profile endpointsCommit 4profile.js and settings.js, verified by integration tests

Example for: refactoring a user authentication module that impacted five different files and introduced new middleware. ### Commit Stack 1. Commit 1: feat(auth): add password hashing utility

  • Files: src/utils/crypto.js
  • Verification: npm test test/crypto.test.js
  • Rationale: Creates the foundation for secure password handling without touching existing routes.
  1. Commit 2: refactor(auth): update user model schema
  • Files: src/models/user.js
  • Verification: npx prisma migrate dev --create-only
  • Rationale: Prepares the database schema to store hashed passwords before applying application logic.
  1. Commit 3: feat(middleware): implement auth guard
  • Files: src/middleware/authGuard.js
  • Verification: curl -I http://localhost:3000/api/profile
  • Rationale: Adds the protective layer that relies on the new hashing utility.
  1. Commit 4: fix(routes): integrate auth guard into profile endpoints
  • Files: src/routes/profile.js, src/routes/settings.js
  • Verification: npm run test:integration
  • Rationale: Finalizes the implementation by securing specific routes using the new middleware.
Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces a dependency-first approach to commit ordering.
  • Includes a verification command for every single step.
  • Uses a standard conventional commit format for clarity.

Use this when you have a massive diff that is difficult to review. Paste your diff or list of file changes directly after the prompt in the Cursor Chat or Claude web interface. It helps you break down work into small, mergeable PRs.

Common edits

  • Adjust the commit message style to match your specific company guidelines.
  • Add a requirement to include unit test updates in the same atomic commit.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

More in Cursor
Coding

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.

Summarise a Long Chat into a Four-Section Handoff Block

Get a compact, copy-paste handoff block with your decisions, open questions, constraints, and exact next step so a fresh chat can pick up immediately.

Turn a One-Line Ask Into an Approved Prompt Before Running It

You get up to two clarifying questions, a full upgraded prompt to review, and the final result only after you approve the prompt.

Automation & Workflows

Turn scattered admin tasks into a batched weekly routine

Group daily administrative chores into dedicated weekly time blocks so work stays uninterrupted. Use this whenever recurring paperwork and inbox cleanup disrupt deep focus.

Create Selective Pre-Commit Hooks for Claude Code

This prompt generates a bash script that triggers specific tests and typechecks only for packages modified in your current git branch.

Perform Static Call Graph Trace Before Modifying Code

Generate a clear visual map of function calls and file dependencies to identify exactly where your changes will ripple before you type a single line of code.