Fix a bug and ship the pull request with Claude Code
Job to be done — Fix a software bug and open a pull request without leaving the terminal
What you’ll get
A repeatable loop for fixing bugs with an AI coding agent: you hand it the error, it finds the cause, proposes fixes, applies the one you pick, verifies with tests, and opens the pull request. The whole cycle happens in your terminal.
Tools you need
- Claude Code — Anthropic’s terminal coding agent. Requires a Claude Pro/Max plan or API credits (paid).
- Git — free; the PR step assumes your project is on GitHub.
Steps
- Open your project and start the agent:
cd /path/to/project
claude
- Share the error exactly as you see it. Tell it the command that reproduces the issue so it can get a stack trace itself:
I'm seeing an error when I run npm test
- Ask for options before letting it edit anything:
suggest a few ways to fix the @ts-ignore in user.ts
- Apply the fix you prefer:
update user.ts to add the null check you suggested
- Verify — make the agent prove the fix:
run the new tests and fix any failures
- Ship it:
create a pr
Original source
This workflow comes straight from Anthropic’s official “Common workflows” documentation for Claude Code (living document, accessed June 2026). The source covers more recipes: understanding new codebases, refactoring, writing tests, and generating docs.
Notes & variations
- Mention whether the error is intermittent or consistent — it changes how the agent investigates.
- Free-tier variation: Gemini CLI (free) and other open-source agents accept the same prompt pattern: reproduce, suggest fixes, apply, verify, PR.
- For changes you want to review before they touch disk, run in plan mode first (
claude --permission-mode plan).