CH 42 / 86Chapter 5: Claude Code (The Core of Development)

Git, Pull Requests and Code Review

On this page8 items

In 10 seconds

You can delegate commits and PRs. But making it stick to one purpose per commit is your job.
Don’t let review happen in the same place the implementation was done.

In No.39 I wrote that “rewinding is no substitute for Git”. This page is about Git itself.

Claude Code works with Git directly#

Staging, writing commit messages, creating branches, creating PRs. It can do all of it.

text2 lines
Commit the current changes. One purpose per commit;
if several purposes are mixed together, split them.

The trick is to write “one purpose per commit” every time. If you don’t, everything you did that day ends up in a single commit.

This guide’s own repository runs on this convention too, written in CLAUDE.md. And it actually gets followed. That’s because it’s the kind of rule where “probably follows it” is good enough (No.41).

Delegating commit messages#

When you have it read the diff and write the message, it’s often more accurate than what you’d write yourself, because it sees the whole change.

However, it can’t write why you did it. The reason isn’t captured in the diff.

So you ask like this:

text3 lines
Write a commit message.
In the body, write "why it was changed", not "what was changed".
The reason is as follows: (write it here)

Claude can read what was done. A person supplies why. In practice, this division of labor works best.

Delegating review#

In Chapter 3, No.22, I wrote that “the doer and the reviewer should be separate”. With Git, you can do this concretely.

Don’t have it review in the same conversation. If you ask the one who implemented something “is this right?”, it will usually say yes.

There are three ways.

Show it in a different conversation. Run /clear and then have it read the diff. It reads without knowing the backstory.

Use the built-in skill. /code-review reads the diff and reviews it.

Delegate to a subagent. This is the pattern from No.23. If you create a reviewer given only reading tools, it can’t accidentally fix things either.

text12 lines
---
name: reviewer
description: Reviews the diff. Use after implementation is done
tools: Read, Grep, Glob
---

Read the diff and point out issues from these angles:
・Missing error handling
・Changes that need tests but don't have them added
・Names that are inconsistent with the surrounding code

Don't fix anything. Return only the findings, in order of priority.

The key is limiting tools to reading only. “Define the scope first”, consistent since Chapter 3, works here as well.

Building it into CI#

According to the official documentation, you can automate PR reviews and issue triage with GitHub Actions or GitLab CI/CD. There’s also a mechanism for automatically adding a review to each PR.

It can also be used from Slack, letting you set up a flow where you post a bug report in Slack and get a PR back.

At this point, it’s the same picture as Cowork’s scheduled runs in Chapter 4. Things that run while you’re not watching should produce reports, not actions. Creating PRs automatically is fine, but a person should press merge.

The quotation task is completed here#

The example followed since Chapter 2 takes its final form in this chapter.

  • Chapter 2: paste PDFs into the conversation one at a time
  • Chapter 4: hand over a folder and get an Excel file
  • Chapter 5: turn the procedure into a skill and run it weekly in CI

In the final form, you can get to the point where a summary table is automatically created every Monday and the differences are reported. But a person presses send and confirm. That hasn’t changed since No.31.

Try it: create a review-only subagent (5 minutes)

Prompt
“`
Create a reviewer subagent for this project.

・Put it in .claude/agents/
・Limit tools to reading only
・Pick three review angles likely to catch real issues in this repository
・Include “Don’t fix. Only point out issues” in the instructions
・Show me the contents before creating it
“`

Once it’s created, make some change and then call it.

Expected result: A reviewer is created that reads the diff and returns only findings.

If it doesn’t work: If the angles are generic, first ask about “the kinds of problems that have actually occurred in this repository”, then have it create the reviewer. Specific angles are more useful.

Common pitfalls#

Not instructing one purpose per commit. If you don’t write it, things get mixed. Put it in CLAUDE.md.

Having it review in the conversation where it implemented. That’s grading its own work. Keep them separate.

Submitting a PR without checking its description. It’s visible to people outside. In particular, check that reasons you didn’t give haven’t been filled in by guesswork.

Relying on rewinding. Edits made by subagents can’t be rewound (No.39). Commit before starting work.

Summary#

  • You can delegate commits and PRs. Write “one purpose per commit” every time
  • Claude can read what was done. A person supplies why
  • Review in a separate conversation, or with a subagent that has only reading tools
  • CI can automate it, but a person presses merge

Read next#

Web, Remote and Scheduled Runs