Auto-generating pull request documentation with Claude Code and GitHub Actions
Anthropic has just released a GitHub Action for integrating Claude Code into your GitHub repo. This lets you do very cool things, like automatically generating documentation for your pull requests after you merge them. Skip to the next section to learn how to install it in your repo.
Since Claude Code is envisioned to be a basic Unix utility, albeit a very smart one, it is very easy to use it in GitHub Actions. The action is very simple:
- It runs after a pull request is merged.
- It uses Claude Code to generate a documentation for the pull request.
- It creates a new pull request with the documentation.
This is super useful, because it saves context about the repo into the repo itself. The documentation generated this way is very useful for not only humans, but also for AI agents. A future AI can then learn about what was done in a certain PR, without looking at Git history, issues or PRs. In other words, it lets you automatically break GitHub’s walled garden, using GitHub’s native features 1.
Installation
- Save your
ANTHROPIC_API_KEY
as a secret in the repo you want to install this action. You can find this page inhttps://github.com/<your-username-or-org-name>/<your-repo-name>/settings/secrets
. If you have already installed Claude Code in your repo by running/install-github-app
in Claude Code, you can skip this step. - Save the following as
.github/workflows/claude-code-pr-autodoc.yml
in your repo:
name: Auto-generate PR Documentation
on:
pull_request:
types: [closed]
branches:
- main
jobs:
generate-documentation:
# Only run when PR is merged and not created by bots
# This prevents infinite loops and saves compute resources
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.user.type != 'Bot' &&
!startsWith(github.event.pull_request.title, 'docs: Add documentation for PR')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- uses: textcortex/claude-code-pr-autodoc-action@v1
with:
anthropic_api_key: $
There are bunch of parameters you can configure, like minimum number of diff lines that will trigger the action, or the directory where the documentation will be saved. To learn about how to configure these parameters, visit the GitHub Action repo itself: textcortex/claude-code-pr-autodoc-action.
Usage
After you merge a PR, the action will automatically generate documentation for it and open a new PR with the documentation. You can then simply merge this PR, and the documentation will be added to the repo, by default in the docs/prs
directory.
Thoughts on Claude Code
I was curious why Anthropic had not released an agentic coding app on Claude.ai, and this might be the reason why.
The main Claude Code action is not limited to creating PR documentation. You tag @claude
, in any comment, and Claude Code will answer questions or implement the changes you ask for.
While OpenAI and Google is busy creating sloppy chat UXs for agentic coding (Codex and Jules) and forcing developers to work on their site, Anthropic is taking Claude directly to the developers’ feet and integrate Claude Code into GitHub.
Ask any question in a GitHub PR, and Claude Code will answer your questions, implement requested changes, fix bugs, typos, styling issues.
You don’t need to go to code Codex or Jules website to follow up on your task. Why should you? Developer UX is already “solved” (well yes but no).
Anthropic bets on GitHub, what already works. That’s why they have probably already won developers.
The only problem is that it costs a little bit too much for now.
In the long run, I am not sure if GitHub will be enough for following up async agentic coding tasks in parallel. Anthropic might soon launch their own agentic coding app. GitHub itself might evolve and create a better real-time chat UX. But unless that UX really blows my mind, I will most likely just hang out at GitHub. If you are an insider, or you know what Anthropic is planning to do, please let us know in the HN comment section.
claude-code-pr-autodoc-action was developed by me, 80% using Claude Code and 20% using Cursor with Claude Opus 4.