CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/Claude Code
Claude Code/2026-04-22Intermediate

Auto-Generating Conventional Commits with Claude Code — Letting it Infer Type and Scope from the Diff

Are your commit messages starting to look like a wall of update and fix? Here's a small, stable setup that lets Claude Code read your staged diff and turn it into proper Conventional Commits.

claude-code129git16conventional-commitsworkflow37automation95

On heavy coding days, you can watch your git log slowly fill up with "update", "fix", and "wip" — nothing that tells you, a month later, what each commit was actually for. Running several projects solo, I hit this wall often enough that history archaeology started eating real time.

Claude Code lives right next to git diff, so writing commit messages should be one of its most natural tasks. But if you just ask it to "commit nicely", you'll get a polished subject line with an empty body, or a new format every time, depending on the mood of the prompt. The trick is to give it just enough structure to be predictable without turning the whole thing into a brittle template.

This post shares a small, concrete setup for getting Conventional Commits out of Claude Code reliably, plus a few tricks for cutting down on miscategorisation (like tagging a bug fix as a feature) that you'll otherwise hit again and again.

Why hand Conventional Commits to Claude Code at all

Conventional Commits prefix each message with the change type — feat:, fix:, refactor:, and so on. When you come back to the log weeks later, you can scan it in seconds instead of re-reading every diff. That payoff compounds: release notes write themselves, CI tooling can filter by type, and git log --oneline becomes legible again even on a chatty branch.

You could of course write these by hand. But picking a type and scope every single commit gets surprisingly tiring, and tired developers produce the "update"-flavoured history mentioned above. It's the kind of repetitive judgement call Claude Code is genuinely good at offloading — low creativity, high consistency. The rest of this post assumes you want that tradeoff.

If you want the bigger picture first — how commits fit into a broader automated Git flow — the Claude Code Git workflow automation guide is a good companion piece.

Start small — one prompt, one result

Before you reach for hooks or slash commands, I'd suggest testing the behaviour with a single prompt. Paste this straight into a Claude Code chat and see what comes back.

Please write a commit message using these steps:
 
1. Run `git diff --staged` and read the staged changes.
2. Summarise the changes in one or two sentences.
3. Output using the template below (the body can be omitted if unneeded).
 
<type>(<scope>): <subject>
 
<body>
<footer>
 
Choose type from: feat / fix / refactor / perf / docs / test / chore / build / ci.
Add a one-line note explaining why you picked that type.

The important line here is "add a one-line note explaining why you picked that type". Without it, you'll get clean-looking messages that quietly conflate feat and fix. With it, you can immediately reply "that's a refactor, rewrite it" and finish the interaction in a single round trip.

It's worth running this on three or four real commits before you invest in automation. Watch for patterns in where the model disagrees with you — those are the exact cases your later rubric needs to cover.

Grow it into a /commit slash command

Once you're happy with the behaviour, pasting the prompt every time gets old. Promote it to a slash command by dropping this file under .claude/commands/ in your project.

---
description: "Generate a commit message in Conventional Commits format"
allowed-tools: Bash(git diff:*), Bash(git status:*)
---
 
Run `git diff --staged` and propose a commit message in Conventional Commits format.
Follow these rules:
 
- Pick type from feat / fix / refactor / perf / docs / test / chore / build / ci.
- Keep subject under 50 characters and use imperative mood.
- Keep body to one paragraph, ordered as "what" then "why".
- When it's unclear whether something is a new feature or a behaviour change, pick feat (not fix) and explain why in the body.
 
At the end, also print a single line in `git commit -m "..."` form so it's easy to paste.

Restricting allowed-tools to git diff and git status keeps unrelated commands from sneaking in, which makes the behaviour noticeably more consistent. It also prevents a common failure mode where the model, mid-generation, decides it "needs" to look at the whole file tree and silently expands the scope of the task.

If you want to organise several commands like this, the Claude Code custom slash commands guide covers the design side in more detail, including how to share commands across a team via a committed .claude/commands/ directory.

Logging the staged diff with a PostToolUse hook

If you want to go one step further, you can have a hook capture a summary of each staging event. The pattern is: watch for git add via PostToolUse and append a tiny stats block to a session log.

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "bash -c 'echo \"$(date -Iseconds)\" >> .claude/last-stage.log && git diff --staged --stat >> .claude/last-stage.log'"
          }
        ]
      }
    ]
  }
}

The point is to give you something to glance at just before you commit: "ah yes, these are the files I staged in this session". It also turns out to be useful when you accidentally work for an hour without committing — the log shows exactly when each staging step happened, so you can split the work into two or three sensible commits afterwards.

If you want the whole map of hook events first, the Claude Code hooks automation guide is the best place to start.

One note of caution — avoid designs where the hook itself triggers Claude to write a message. Keeping the hook to logging only, and generating the message when the user explicitly runs /commit, makes accidental commits much less likely. Automation that makes its own decisions about what to commit is exactly the kind of thing you'll regret at 11 PM on a Friday.

Reducing chore / refactor / fix mistakes

The stickiest part of running Conventional Commits is choosing a type, and Claude Code is no exception. Left unguided, you'll typically see these patterns:

  • Bug fix labelled as feat: It reads the diff and interprets the fix as "adding" the missing behaviour.
  • Refactor labelled as fix: Nothing about user-visible behaviour changed, but the diff looks like it "corrected something broken".
  • Config change labelled as chore: Dependency bumps get folded under chore, burying build and ci changes that should be more visible in the log.

The fix is to put a short decision rubric in your project's CLAUDE.md. Here's the version I use across my four sites:

## Commit message policy
 
- User-visible new/changed behaviour: feat
- Returning broken behaviour back to the intended state: fix
- Internal structure change with no behaviour change: refactor
- Dependency updates: build when the package name is known, otherwise chore
- Changes only under `.github/workflows/`: ci
- When in doubt, prefer feat or refactor — do not use fix

"When in doubt, do not use fix" is the single most effective line here. The reason is practical: fix carries extra weight in downstream tooling like CHANGELOG generators, so misusing it creates a log full of fixes for things that were never broken. If you care about clean release notes, this one rule pays for itself within a release or two.

A second rule I've added over time is about scope. If the model tries to invent a new scope on every commit, you end up with 40 scopes and no consistency. I usually tell it to pick scopes from an explicit list that matches the top-level directories of the repo — api, web, docs, infra — and only invent a new one if nothing fits. That small constraint keeps the log browsable.

For broader CLAUDE.md design patterns, the CLAUDE.md and memory management guide covers several layouts worth borrowing.

A real before/after on one of my own commits

To make this concrete, here's a commit I made last week, the way it would have come out if I'd just typed something off the top of my head, and the way /commit produced it after reading the diff.

Before (hand-written, tired):

fix article slug

After (generated from the diff):

fix(articles): correct category path for newly-migrated MDX files

Two MDX files were moved from api-sdk/ to claude-code/ but their
internal links still pointed at the old category, causing 404s in
production. Update the links to match the new category.

The hand-written message needs me to open the commit just to remember what was wrong. The generated one tells future-me exactly what incident this resolved. Every time I generate a commit, I recover a bit of time I'd otherwise spend on history archaeology — and over a few hundred commits, that adds up.

A five-minute first step

Trying to install every piece at once is the fastest way to give up on the whole setup. Today, I'd just add .claude/commands/commit.md and try /commit once. It takes five minutes, and the quality of your git log changes immediately.

You can layer in hooks and CLAUDE.md guardrails later, once /commit feels natural. Tools that last are the ones you add in the order you actually need them — not the ones you build up front because the blog post you read happened to list them in a particular order.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Claude Code2026-07-14
One Day My Push Had an Extra Destination — Guarding Against /commit-push-pr Pushing to Remotes Beyond origin
The July 14 update made /commit-push-pr push to configured push remotes in addition to origin. Convenient, but if you keep a mirror or backup as a second remote, unintended pushes quietly multiply. Here is how to inventory which remotes you can push to, block anything off the allowlist with a pre-push hook, and keep unattended runs safe — with working code.
Claude Code2026-06-18
Claude Code Adds /cd — Carrying Your Warm Cache Across Repositories
Claude Code's new /cd moves a running session to another working directory without rebuilding the prompt cache. Here are the design calls and pitfalls when you sweep across several repositories in one sitting.
Claude Code2026-06-10
When git add -A Sweeps Up .bak Backups — The Quiet Trap of In-Place Fix Scripts
How .bak backups left by sed -i and homegrown --fix scripts get silently swept into production by git add -A, why it is so easy to miss, and how scoped adds and .gitignore close the gap for good.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →