How ZAR works
ZAR is an event-driven pipeline. A GitHub webhook comes in, and a series of gates decides whether — and how — to propose a documentation change. This page walks the whole path so you can predict ZAR’s behavior and tune it with confidence.The pipeline at a glance
Step by step
1. Webhook arrives and is verified
GitHub sends a signedPOST to /github/webhook. ZAR verifies the X-Hub-Signature-256 HMAC against the configured webhook secret. Anything that fails verification is rejected with 401 and never processed. See Safety & guarantees.
2. Fast acknowledgement, background work
ZAR returns202 Accepted right away and does the real work in a background task. GitHub gets a fast response; analysis (which calls Claude) happens off the request path.
3. Routing by event type
Only three event types do work:issue_comment(actioncreated) → routed to the command handler. Code analysis does not run here.push→ analyze the commits between thebeforeandafterSHAs.pull_request(opened,synchronize,ready_for_review, and merges) → analyze the PR’s changed files.
4. Effective configuration
ZAR loads the repository’s settings from its database and merges them with a.zar.yml file from the repo root, if present. Dashboard/database values take precedence over .zar.yml where both are set. The result is the effective config — trigger mode, watched branch, confidence threshold, style guide, and feature flags — used for the rest of the run. See Configuration overview.
5. Fetch and summarize the diff
ZAR fetches the changed files (GitHub’s compare endpoint for pushes, the PR files endpoint for PRs) and runs tree-sitter over the code. tree-sitter extracts public symbols — functions, classes, methods — and notes added/removed/renamed ones. Lock files, build output, and minified assets are filtered out. Code files are recognized by extension across Python, TypeScript/TSX, JavaScript/JSX, Go, Java, Kotlin, and Rust; symbol-level extraction (functions, classes, methods) is deepest for Python and TypeScript/TSX. Documentation files are recognized by extension:.md, .mdx, .markdown.
6. Is the change doc-worthy?
ZAR applies a significance check so it doesn’t nag on noise. A change is treated as significant if it includes any of:- A new public function, class, method, or API route.
- A deleted or renamed file.
- A signature change (symbols both removed and added in the same file).
- A “meaningful” diff of at least ~10 lines (whitespace-only changes don’t count).
zar/docs status and stops. Details and tuning: Trigger modes.
7. Trigger policy
Even a significant change might not open a PR right now. The trigger mode decides:every_commit— act on every analyzed commit.on_significant_change(default) — act when the change is significant and confident.daily— batch changes and open a PR once perbatch_hourswindow.on_merge— act only when a PR is merged.
@docagent update docs now overrides all of this and forces a run.
8. CI gate (pull requests only, optional)
If you’ve enabled the CI gate, ZAR asks Claude whether the docs are still accurate for this PR. If they’re not, ZAR:- comments on the PR with the proposed edits,
- adds the
docs-neededandci-blockedlabels, - creates a failing
docagent/ci-gatecheck run,
9. Claude proposes minimal patches
ZAR builds a prompt containing the repo’s relevant docs, the unified diff, and the tree-sitter symbol summary, then asks Claude for a structured response: a list of files to update, each with a minimal unified diff and a short explanation. The system prompt constrains Claude hard:- Only edit when the code change made the docs inaccurate or incomplete.
- Make the smallest surgical edit; never append filler at the end of a file.
- Never invent facts; never document internal/private details.
- Write in the doc’s existing language; preserve structure and frontmatter.
10. Deliver the result
ZAR applies the patches to a working copy and then:- Opens or updates a single docs PR on a
zar-updates/…branch targeting your base branch. ZAR keeps at most one open docs PR per base, superseding older ones. - Comments on the source PR (when enabled) showing what changed and why.
- Sets the
zar/docscommit status to reflect the outcome. - Commits directly only when you’ve enabled auto-commit and the operator allows writes. See Auto-commit.
.mdx files, ZAR runs an integrity check and rejects any edit that would strip frontmatter keys or imports — a broken Nextra build is worse than a stale doc. For multilingual sites, it mirrors an edit across sibling language variants. See MDX & multilingual.
Every run is recorded
Each webhook delivery becomes one run in the dashboard, identified by GitHub’s delivery ID. A run stores the event, the changed/code/doc files, how many doc changes were suggested versus applied, the feature flags in effect, and a step-by-step timeline. See Dashboard.Where to go next
- Safety & guarantees — the promises this pipeline keeps.
- Trigger modes — control steps 6 and 7.
- CI gate — turn step 8 into a merge gate.