# Ship a small PR end-to-end

Web page: https://academy.memberpress.ai/courses/code-intro/l7/

Lesson 7 of 8 in [Claude Code — Getting Started](https://academy.memberpress.ai/courses/code-intro/), 15 min.

Video: https://www.youtube.com/watch?v=4keZCtJP9tg

Every workflow you have practiced so far — reading diffs, writing briefs, running tests — converges here. The deliverable is not a demonstration. It is a merged PR on a real ticket that you would have shipped anyway.

**Picking the ticket**

Start with something that already exists on your backlog. A bug fix is ideal: the expected behavior is specified, the failure is reproducible, and the success criterion is clear. A documentation update also works. A new feature is too open-ended for a first PR with Claude.

The ticket should be small enough that the full diff is reviewable in under five minutes. If you cannot describe the change in two sentences, the ticket is too large.

**Setting up the branch**

Ask Claude to create the branch before it writes any code. Confirm the name before proceeding.

```
> Create a branch named fix/settings-cancel-button-does-not-clear-form and check it out.
> Do not write any code yet.
```

```bash
git branch
# → * fix/settings-cancel-button-does-not-clear-form
# →   main
```

Confirm you are on the new branch before you continue.

**Giving Claude the task**

Hand Claude the ticket text, not your paraphrase of it. If the ticket says "the cancel button on the settings page doesn't clear the form state," give Claude that sentence. Paraphrasing introduces your assumptions. The original text is the specification.

```
> Ticket: The cancel button on the settings page doesn't clear the form state. 
> When a user edits their profile and clicks Cancel, the form should reset to 
> its last saved values. Currently it does not.
> 
> Fix this. Only touch the settings page component and its tests.
```

**Before you open the PR**

Three checks, in order:

1. `git diff main` — read the full diff against main, not just the last change.
2. `npm test` — all tests pass.
3. If the repo has a linter: `npm run lint` — no errors. Claude sometimes produces code that passes tests but fails the linter.

If any check fails, tell Claude what failed and what the error says. Do not describe the error in your own words — paste the exact error output.

**Writing the PR description**

Claude can write the PR description. Read it before you submit. The description should explain what changed and why, not list the files. If Claude produces a changelog ("Updated FormComponent.tsx, added test for cancel behavior"), ask it to revise:

```
> Rewrite the PR description as a narrative. Explain what the bug was, 
> what caused it, and what the fix does. One short paragraph.
```

**Opening the PR**

```bash
gh pr create --title "Fix: cancel button now resets form to saved state" \
  --body "$(cat pr-description.md)"
```

Or let Claude run that command. Either way, read the PR on GitHub before you mark it ready for review.

**If you get stuck**

- Claude starts writing code before creating the branch: interrupt, reset with `git checkout main && git checkout .`, and restart with an explicit instruction to create the branch first.
- The PR diff includes changes from a previous task: your branch diverged from main at the wrong point. Run `git log --oneline main..HEAD` to see what commits are on the branch and whether any should not be there.
- Claude's PR description is a list of file names: use the revision prompt above. If it produces a list again, write the description yourself — one paragraph, two minutes.
- The PR review catches something you missed: this is the system working. Fix it on the same branch, push, and the PR updates automatically.

**Cross-reference**

l3 ("Reading the diff") and l6 ("Tests as the safety rail") are the two habits this lesson depends on. If either of those feels uncertain, practice them on a throwaway change before running a real PR.

**Deliverable**

A merged PR with a URL. The branch was created before any code was written. The diff was read in full. All tests passed before the PR was opened.

## Try these prompts

- Write the Claude Code task message for a ticket that says the settings page cancel button does not reset the form. Include the boundary clause.
- Write the three pre-PR checks in order — diff, tests, linter — as a short numbered checklist with the exact command for each.
- Write a one-sentence revision prompt to send Claude when its PR description reads: "Updated FormComponent.tsx, added test for cancel behavior."

Next: [When Claude Code goes sideways](https://academy.memberpress.ai/courses/code-intro/l8/)
