A documentation auto-update pipeline powered by Claude Code and GitHub Actions. When code merges to your repositories, the pipeline detects which documentation files are affected, runs an AI agent to update them, and opens a pull request for human review.
Source Repo (merge to main)
--> docs-notify.yml
--> repository_dispatch to your-org/your-docs-repo
--> auto-docs-update.yml
|-- checkout docs + source repo
|-- match changed paths to affected doc files
|-- run Claude Code to regenerate docs
--> open PR with "auto-docs" label
- An engineer merges code to a source repository.
- A lightweight sender workflow (
docs-notify.yml) fires, collects the changed file paths and commit reference, and dispatches arepository_dispatchevent to your central documentation repository. - The receiver workflow (
auto-docs-update.yml) picks up the event and consultsdocs-config.ymlto determine which documentation files could be affected by the change, using glob-basedwatch_paths. - For each affected doc, Claude Code reads the existing documentation, explores the source repository at the exact triggering commit, compares the two, and proposes targeted edits.
- If changes are needed, a PR is opened for human review. If nothing meaningful changed, the pipeline closes cleanly (
NO_CHANGES_NEEDED).
- An Anthropic API key for Claude Code
- A GitHub Personal Access Token (PAT) with
reposcope, used to dispatch events and check out private source repos
- Copy
auto-docs-update.ymlinto your docs repo at.github/workflows/auto-docs-update.yml. - Copy
docs-config.example.ymlto.github/docs-config.ymland customise it for your repositories (see Configuration below). - Copy
auto-docs-prompt.example.mdto.github/auto-docs-prompt.mdand adjust the rules to match your team's conventions. - Add the following secrets to your docs repo:
CLAUDE_API_KEY— your Anthropic API keyDOCS_DISPATCH_TOKEN— the GitHub PAT
- Create an
auto-docslabel in your docs repo (used to tag auto-generated PRs).
For each repo you want to participate:
- Copy
docs-notify.ymlinto the repo at.github/workflows/docs-notify.yml. - Update the
branchestrigger if your default branch isn'tmain. - Update the
repositoryfield in the dispatch step to point at your docs repo. - Add the
DOCS_DISPATCH_TOKENsecret (the same GitHub PAT). - Add an entry in your docs repo's
docs-config.ymlfor this source repo.
The docs-config.yml file maps source repositories to the documentation files they affect:
repositories:
org/backend:
branch: main # Branch that triggers updates
checkout_path: source/backend # Where to clone the source repo
docs:
- file: standards/go.md # Doc file in the docs repo
scope: "Go coding standards, conventions, and tooling"
watch_paths: # Globs matched against changed files
- "**/*.go"
- "go.mod"
- ".golangci.yml"branch— the source repo branch that triggers docs updates.checkout_path— a temporary directory for cloning the source repo during the workflow run.docs[].file— path to the documentation file in your docs repo.docs[].scope— a natural-language description of what this doc covers, passed to Claude as context.docs[].watch_paths— glob patterns matched against the changed file paths. Only docs whose watch_paths intersect with actual changes are regenerated.
Wildcard entries (e.g., org/*) act as a fallback for repositories without an explicit entry.
The auto-docs-prompt.md template supports these variables, substituted at runtime:
| Variable | Description |
|---|---|
$DOC_FILE |
Path to the documentation file being updated |
$SOURCE_PATH |
Path to the checked-out source repository |
$REPOSITORY |
Full org/repo name of the source repository |
$SCOPE |
The scope string from docs-config.yml |
$CHANGED_PATHS |
Comma-separated list of files changed in the triggering commit |
$SHA / $SHA_SHORT |
Full and abbreviated commit SHA |
$BRANCH |
Source branch name |
$COMPONENT |
Derived from the doc filename (e.g., standards/go.md yields go) |
- Event-driven, not scheduled. Source repos push events when changes happen. No polling, no cron. Any new repository can participate by adding the sender workflow and a config entry.
- Concurrency queuing. Only one documentation update per source repository runs at a time. If two PRs merge in quick succession, the second update queues rather than being discarded.
NO_CHANGES_NEEDEDexit. Not every code change affects documented conventions. Claude can determine that no docs update is required, and the pipeline closes cleanly without opening a PR.- Human review required. Auto-merge is deliberately not included. Every change opens a PR for engineers to review, maintaining human ownership of the knowledge base.
- Major version history (optional). When a major semver bump is detected, an additional step can update an architecture history log. Remove this step if you don't need it.
This pipeline was built at Popsa to keep engineering documentation in sync with a multi-repo codebase. You can read the full story in I'd Rather Build the System.