You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An AI-powered GitHub Action that reviews pull requests with Z.ai
GLM models — with inline line-level review comments, deterministic
scanners, a walkthrough summary, and (optionally) interactive /zai
commands.
What it does
Inline review comments anchored to diff lines (like CodeRabbit / Copilot),
not just a summary block. Each finding carries severity, confidence, quoted
evidence, and a concrete suggestion.
Deterministic scanners beneath the LLM — secret detection (gitleaks +
regex fallback) and code-pattern analysis (ast-grep + regex fallback) run
BEFORE the model, catching what LLMs miss and suppressing hallucinations.
Structured findings with a noise cap (default 25/PR), severity ranking,
and anti-hallucination file validation.
Walkthrough summary — findings grouped into dependency-ordered cohorts
(database → API → logic → UI → tests) in collapsible sections.
Commit-status feedback — pending → success/failure so developers see
review progress instead of a silent PR.
.zai.yml repo config — per-path review instructions, tone, and scanner
toggles without editing your workflow (the .coderabbit.yaml pattern).
Incremental review — re-pushes only surface new/changed findings
(content-hash dedup), not the same resolved issues.
Interactive commands (/zai ask, review, explain, describe,
impact, help) — off by default, authorization-gated when on.
Security first. Every untrusted surface (diffs, .zai.yml, CODEOWNERS,
scanner output) flows through prompt-injection defenses and an output
sanitizer. Commands are gated by a workflow if: on author_associationand an in-code check. See SECURITY.md.
Setup
Create a Z.ai API key at z.ai.
Add it to your repo as a secret named ZAI_API_KEY.
Add a workflow (see below).
Quickstart: auto-review
name: Z.ai Reviewon:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]permissions:
pull-requests: writecontents: read # to load .zai.yml / .zai/learnings.yml from the PR headstatuses: write # for commit-status feedback (or set ZAI_COMMIT_STATUS: false)jobs:
review:
if: github.event.pull_request.draft == falseruns-on: ubuntu-lateststeps:
- uses: secondsky/z.ai-code-review-bot@4f2657c6b07b16ce1ca61557b05d620ea93333db # v2.0.0with:
ZAI_API_KEY: ${{ secrets.ZAI_API_KEY }}
Every non-draft PR gets a review with inline comments on findings + a
walkthrough summary. Prior reviews are dismissed on re-push (idempotent per
SHA). Bounded-concurrent batch fan-out handles large PRs.
Optional: .zai.yml repo config
Commit a .zai.yml to configure review behavior without editing the workflow:
reviews:
profile: chill # chill = only critical+high | assertive (default) = all severitieslanguage: en-US # respond in this language (additive; e.g. fr-FR, 日本語)max_findings: 8# can only LOWER the action's cappath_instructions:
- path: "src/auth/**"instructions: "Scrutinize auth flows; flag hardcoded secrets."
- path: "**/*.test.js"instructions: "Check edge-case coverage."path_filters:
- "!dist/**"tone_instructions: "Be terse. Cite line numbers."scanners:
gitleaks: true # can only DISABLE (false), never enableast_grep: false
The .zai.yml is treated as untrusted — it can only narrow behavior (add
excludes, lower caps, disable scanners). Action inputs always win on
security/cost knobs.
Optional: interactive /zai commands
Commands let collaborators ask questions by commenting /zai … on a PR.
Off by default; requires an authorization gate. See
SECURITY.md for why this matters, especially for fork PRs.
Command
Description
/zai ask <question>
Ask a question about the PR.
/zai review [file]
Review a specific file, or the whole PR.
/zai explain <start>-<end> [file]
Explain a line range.
/zai describe
Generate a PR description.
/zai impact
Assess change impact/risk.
/zai help
Show the command list.
Inputs
Core review
Input
Default
Description
ZAI_API_KEY
(required)
Z.ai API key. Use a secret.
ZAI_MODEL
glm-5.3
Z.ai model name. Use glm-5.3-flash for faster/cheaper runs.
npm install
npm test# vitest suite (2349 tests)
npm run test:coverage
npm run build # @vercel/ncc -> dist/index.js (commit the bundle)
npm audit # 0 vulnerabilities
dist/index.js is committed on purpose — it is what the runner executes. CI
fails if it drifts from src/. See ARCHITECTURE.md for
the module map and SECURITY.md for the authorization model.
Security
Pin the action to a full commit SHA. Tags are mutable, and force-pushed
tags were the propagation vector of the 2025–2026 GitHub Action supply-chain
compromises (tj-actions/changed-files, aqua Trivy). Reference the action as
<your-org>/z.ai-code-review-bot@<full-commit-sha> — not a floating tag —
and enable Dependabot's github-actions package ecosystem so it keeps the
pin current. The example workflows in
.github/workflows/ document the exact setup.
Keep the least-privilege permissions: blocks. The example workflows
grant each job only the scopes it needs (pull-requests: write,
contents: read, and optionally statuses: write); widening them is never
required.
Keep first-time contributor approvals on. By default, GitHub requires
maintainer approval before workflow runs from first-time fork contributors
execute — leave that default in place.
This repo dogfoods its own hardening. Every action reference is
SHA-pinned, and CI runs the zizmor + actionlint
(ci.yml), CodeQL
(codeql.yml), and OpenSSF Scorecard
(scorecard.yml) gates on every change.