Generate release notes with AI from git log, in one command
Updated Fact-checked
To generate release notes with AI, list the commits since your last release with git log, pipe them into a coding agent in script mode, and ask for grouped Markdown. The agent only formats what git gives it, so it needs no access to your files and no permission to run anything.
git log --oneline --no-merges v1.4.0..HEAD | claude -p "Group these commits into release notes under ## Features, ## Fixes and ## Other. Rewrite each line for users, not developers. Omit empty sections. Output only Markdown." > RELEASE_NOTES.md
What it looks like#
The input, straight from git:
a41c9e2 fix(checkout): apply discount before tax
7d02b11 feat(export): add --json flag to export command
e5f8a30 chore: bump eslint to 9.x
1c77d0f feat: dark mode on settings page
The output:
## Features
- Export now supports JSON with the new `--json` flag.
- The settings page has a dark mode.
## Fixes
- Discounts are now applied before tax at checkout.
## Other
- Updated development tooling.
The commands for each agent#
| Agent | Script mode | Reads piped input |
|---|---|---|
| Claude Code | claude -p "..." |
Yes |
| Codex CLI | codex exec "..." |
Yes, as context for the prompt |
| OpenCode | opencode run "..." |
Pass a file with -f |
Claude Code
git log --oneline --no-merges v1.4.0..HEAD | claude -p "Group these commits into release notes under ## Features, ## Fixes and ## Other. Rewrite each line for users. Omit empty sections. Output only Markdown." > RELEASE_NOTES.md
Codex CLI
git log --oneline --no-merges v1.4.0..HEAD | codex exec "Group these commits into release notes under ## Features, ## Fixes and ## Other. Rewrite each line for users. Omit empty sections. Output only Markdown." -o RELEASE_NOTES.md
When you pipe input and give a prompt, Codex treats the piped text as context. -o writes only the final answer to the file. codex exec runs in a read-only sandbox by default, which is exactly right here.
OpenCode
git log --oneline --no-merges v1.4.0..HEAD > commits.txt
opencode run "Group the commits in this file into release notes under ## Features, ## Fixes and ## Other. Rewrite each line for users. Omit empty sections. Output only Markdown." -f commits.txt > RELEASE_NOTES.md
The PowerShell trap: in Windows PowerShell 5.1,
>writes the file as UTF-16, which many tools and GitHub render as garbage. Pipe toOut-File -Encoding utf8 RELEASE_NOTES.mdinstead, or use PowerShell 7, which writes UTF-8 by default.
A prompt that gives good notes#
The one-liner works. This version gives notes people actually read:
Write release notes from these commits.
- Group under ## Features, ## Fixes and ## Other. Omit empty sections.
- Write for users of the product, not for developers. Say what changed for them.
- Merge commits that describe the same change into one line.
- Put dependency bumps, refactors and CI changes under Other, in one line, or drop them.
- Never invent a change that isn't in the list. If a commit is unclear, keep its wording.
- Output only Markdown, no introduction.
The “never invent” line matters. Asked to make notes sound good, a model will happily describe a feature in more detail than the commit supports.
For the summary at the top of the notes, the part that says what a release adds up to, a two-pass method from monthly roadmap reviews carries over. First have the model write a neutral summary of what shipped: facts only, no judgments. Then run the analysis on that summary. For an outside view, open a fresh chat, frame it as a product manager who has just joined, ask “what is your task?” before pasting anything, and only then hand over the first analysis. The method, from Moving the Needle, needs complete input: every change, not a cherry-picked set of wins. An outside read that surprises is a sign the input was incomplete, so check the input before trusting either version.
Run it in CI#
The same command works in a release job. With GitHub’s CLI, create the release with the generated notes:
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^)
git log --oneline --no-merges "$PREV_TAG"..HEAD | claude -p "$(cat .github/release-notes-prompt.txt)" > RELEASE_NOTES.md
gh release create "$GITHUB_REF_NAME" --notes-file RELEASE_NOTES.md
- Keep the prompt in the repo, as above, so changes to it are reviewed like code.
- Give the job only the model key it needs. The agent never needs write access to the repository for this; the
ghstep does that. - Fetch the tags. CI checkouts are often shallow, and
git describefails without the history. In GitHub Actions, setfetch-depth: 0on the checkout step.
Pipe it, or let the agent look?#
You can also skip the pipe and ask an agent in a normal session: “Write release notes for everything since v1.4.0.” It will run git log itself, and can open the diffs to describe changes better than the commit messages do.
| Pipe the log | Let the agent explore | |
|---|---|---|
| Input | Exactly the commits you chose | Whatever the agent decides to read |
| Cost | One small request | Many requests, much more context |
| Permissions needed | None | Running git commands |
| Notes quality | As good as your commit messages | Better for vague commit messages |
For a release job, pipe. For a big release with messy commit history, let the agent look, and review the result.
Seen in production: on a repository that agents write, the log has nothing left to summarise. An early Contenox repository accumulated 957 commits, most of them named Checkpoint, Fix tests or Snapshot WiP; piped into a model, that log can only produce invented notes. There the input has to be the change itself,
git diff --stat v1.4.0..HEADplus the diffs of the files that matter, and the notes are written once, reviewed, and stored where they can’t drift: the project’s releases carry them in the signed tag’s annotation (git tag -s -F release-notes.md v1.0.0), and CI builds from that tag. The setup is described in AI Killed Git Commits.
You may not need a model at all#
- Your commit messages already follow a convention such as Conventional Commits. A plain tool that groups by prefix is free, fast and never invents anything.
- You release from pull requests on GitHub.
gh release create v1.5.0 --generate-notesbuilds notes from the merged pull request titles, no model involved.
Related guides#
Terminal coding agents: install Claude Code, Codex CLI or OpenCodeTerminal coding agents: what they are and which one to useTerminal coding agents explained: how Codex CLI, OpenCode and Claude Code's terminal mode work in a shell, why developers pick them over IDE agents, and when not to.
Git workflow with AI agents: commit habits that make good notes possibleGit workflow with AI agents: branches, worktrees and undoA git workflow with AI agents: start clean, one branch per task, commit checkpoints, undo safely, and run agents in parallel with worktrees. Commands to copy.
Keep secrets away from AI agents: what not to pass into a CI jobHow to keep secrets away from AI agents (and out of git)How to keep secrets away from AI agents: block .env reads in Claude Code, OpenCode and Codex, stop keys leaking through commands, and what to do if one leaked.
Coding agents on WindowsAI coding agents on Windows: native or WSL, agent by agentWhich AI coding agent runs natively on Windows and which needs WSL: install commands, shell, sandbox and config path for each, plus the Windows traps that bite.
Codex on WindowsCodex for Windows: install, desktop app and sandbox setupCodex for Windows, step by step: the desktop app, the CLI from PowerShell, npm or WSL, signing in, the Windows sandbox and its errors, and fixes for crashes.
Claude Code on WindowsClaude Code on Windows: install, setup and common fixesInstall Claude Code on Windows 11 from PowerShell, CMD or WinGet, pick Git Bash or PowerShell, decide on WSL, and fix PATH, proxy and duplicate-install errors.
OpenCode with local modelsOpenCode with local models: Ollama, LM Studio, llama.cpp, vLLMSet up an OpenCode local model: automatic discovery for Ollama, LM Studio and vLLM, plus a llama.cpp configuration, context limits and tool calls.