Lesson 9 of 9 · about 45 minutes

Capstone: the full loop

Issue → agent branch → pull request → green CI → main. On your own, start to finish.

You will take one real task in penguins-lab from a GitHub issue to a merged, CI-tested pull request, with Claude Code doing the work in its own worktree. That is the workflow you'll use from now on.

Part 1 — Warm up from memory

These questions mix all eight lessons on purpose. Switching between topics is harder than drilling one, and that difficulty is what builds long-term memory. Don't scroll back. Guess, then read the explanation.

On main you run git switch -c add-summary-stats. Where do the two branches point?

A branch is a movable pointer. A new one starts at the commit you're on, and nothing moves until you commit (Lesson 1).1

main hasn't moved since you branched. What does git merge add-summary-stats on main do?

No divergent work means a fast-forward: Git just moves the pointer (Lesson 3).2

git branch -d old-idea answers "not fully merged". What does that tell you?

-d only deletes a branch "fully merged in its upstream branch, or in HEAD". -D forces it and throws the work away (Lesson 3).3

Why use git push -u origin add-summary-stats the first time you push?

-u records the upstream, "used by argument-less git-pull and other commands" (Lesson 4).4

What does git diff main...add-summary-stats show?

The three-dot form diffs from the merge base to the branch. That's exactly what a pull request shows (Lessons 2 and 4).5

Claude made nine small commits on an agent branch. Which merge method gives main one tidy commit?

Squash suits a PR that "represents one logical change, especially if the branch includes many small fixup commits" (Lesson 4).6

A workflow triggered by pull_request runs your tests against which code?

actions/checkout checks out the PR merge ref, so "CI tests run against the merged result, not just the head branch alone" (Lesson 5).7

Claude deleted a data file with rm through Bash. Will /rewind bring it back?

"Checkpointing does not track files modified by Bash commands." Checkpoints are "not a replacement for version control." Commit often (Lesson 6).8

git worktree add ../b feature-x refuses because feature-x is checked out in your main folder. Why?

By default add refuses a branch that's already checked out in another worktree (Lesson 7).9

In Claude Code, what does /branch experiment create?

It's a naming trap: /branch branches the conversation, not git (Lesson 6).10

Type it, don't pick it

Create add-summary-stats and switch to it in one command.

You're on add-summary-stats. Show only the changes this branch made since it left main.

Publish add-summary-stats to GitHub for the first time and set its upstream.

Squash-merge the current branch's pull request and delete the branch, using the GitHub CLI.

Start Claude Code in a new isolated worktree named add-summary-stats.

List every worktree attached to this repository.

Part 2 — The lab: one task, the whole loop

The task: add a summarize_by_species(df) function to clean.py that returns mean bill length and body mass per species, plus a test. Claude writes it. You run the process.

If a leftover local branch survives step 9, git branch -d may say "not fully merged". A squash merge puts a new commit on main, so the branch's original commits aren't reachable from it. Once you've confirmed the PR merged, git branch -D is the right call.36

Stretch: two agents at once

Open two terminals in penguins-lab. Run claude -w add-species-plot in one and claude -w add-island-counts in the other. Brief both, then run each through steps 4–9. If both touch README.md or clean.py, the second PR will hit a merge conflict once the first merges. CI won't even start: "Workflows will not run on pull_request activity if the pull request has a merge conflict."7 Resolve it inside the second worktree:

$ git fetch origin
$ git merge origin/main        # conflict markers appear
# edit the files: keep both changes, delete <<<<<<< ======= >>>>>>>
$ git add README.md
$ git commit                   # seals the merge
$ git push                     # CI re-runs on the PR

Git's docs describe this exact sequence: "Edit the files into shape and git add them… Use git commit… to seal the deal."2 You can also ask the agent in that worktree to do the merge and explain each conflict before resolving it.

Part 3 — Where to go next

You now have the skills. Wisdom comes from using them with other people.

Re-read GitHub flow (5 minutes). Every step of today's lab is one of its six steps, with Claude Code and CI added.
Stuck at any step? Paste the exact error into Claude and ask "What state is my repo in, and what's the safest next command?" Try "Review my last PR as if you were a strict teammate" for a second opinion before you merge.

Sources

  1. Chacon & Straub, Pro Git, §3.1 Branches in a Nutshell.
  2. Pro Git, §3.2 Basic Branching and Merging; Git reference, git-merge — how to resolve conflicts.
  3. Git reference, git-branch -d / -D.
  4. Git reference, git-push --set-upstream.
  5. Git reference, git-diff (three-dot form); GitHub Docs, three-dot diffs in pull requests.
  6. GitHub Docs, About pull request merges; Deleting and restoring branches in a pull request.
  7. GitHub Docs, Events that trigger workflows — pull_request.
  8. Claude Code docs, Checkpointing (limitations; not a replacement for version control).
  9. Git reference, git-worktree.
  10. Claude Code docs, Commands (/branch).
  11. Claude Code docs, Run parallel sessions with worktrees.
  12. GitHub CLI manual, gh issue create.
  13. Claude Code docs, Best practices — explore, plan, code.
  14. Claude Code docs, Common workflows — create pull requests; Settings — attribution.
  15. GitHub Docs, Linking a pull request to an issue.
  16. GitHub Docs, GitHub flow.