Clean PRs by default. Fix issues at commit time.
GitPreflight is a staged-only, pre-commit code review gate designed for AI coding agents. It runs on git commit, reviews the staged diff only (git diff --cached), and prints stable Markdown your agent can apply before you push.
- Runs on
git commitvia a pre-commit hook. - Reviews the staged diff only (
git diff --cached). - Prints a stable, LLM-friendly Markdown report with actionable suggestion blocks.
- Blocks commits when it finds
minorormajorissues.
End users:
- Node.js (for the npm installer wrapper)
- Git
Contributors / source builds:
- Bun (repo package manager + CLI build/runtime for the interactive UI)
- Node.js (used by Next.js/Convex tooling)
Global install via npm (downloads a platform binary on install/first run):
npm i -g gitpreflight
gitpreflight --helpCurl install (OpenCode-style):
curl -fsSL https://gitpreflight.ai/install | bash
gitpreflight --helpbun dev- Web app: http://localhost:3000
- Run individually:
bun run dev:webbun run dev:convex
In a repo you want to protect:
gitpreflight setup
gitpreflight setup local-agentThe local-agent setup flow asks which local agent you use (Codex, Claude, or OpenCode), probes the command, then writes config to ~/.config/gitpreflight/config.json.
Check your installed version (and latest known release):
gitpreflight version
# shorthand:
gitpreflight -vIn a repo you want to protect:
gitpreflight setup
# or non-interactive:
# gitpreflight setup --scope local --hook pre-commit --yes
# gitpreflight setup --scope global --hook pre-commit --yes
# gitpreflight setup --scope repo --hook pre-commit --yesgitpreflight setup is interactive in a TTY and explains scope options:
global: enable across all repos on your machinelocal: enable for this repo only, without committed integration filesrepo: committed repo-owned setup for all contributors
Compatibility: gitpreflight init still works for repo-scoped Husky setup.
GitPreflight integrates via Husky:
- Adds/extends
package.json#scripts.prepareto includehusky install - Creates/appends
.husky/pre-committo rungitpreflight review --staged - Creates/appends
.husky/post-commitfor unchecked-commit capture
Optional push-gate mode:
gitpreflight setup --scope repo --hook pre-push --yescreates/appends.husky/pre-pushto rungitpreflight review --pushgitpreflight setup --scope repo --hook both --yesinstalls both commit + push hooks
Inspect or remove setup:
gitpreflight status --verbose
gitpreflight uninstall --scope local
# or
gitpreflight uninstall --scope globalPolicy overrides (optional):
# global default policy
git config --global gitpreflight.policy optional
# local repo override (for example, opt out in one repo)
git config --local gitpreflight.policy disabledRepo owners can commit policy in package.json:
{
"gitpreflight": {
"policy": "required"
}
}Policy precedence is: repo policy > local git config > global git config > default (optional).
After repo-scoped setup (gitpreflight setup --scope repo ... or gitpreflight init), run your package manager install so Husky activates:
npm install
# or: pnpm install / yarn install / bun installgitpreflight review --stagedHooks/CI output is always plain Markdown. In an interactive terminal, GitPreflight prefers a Bun-powered TUI (and falls back to a pager when needed).
Force plain Markdown output:
gitpreflight review --staged --plain
# or
GITPREFLIGHT_UI=plain gitpreflight review --stagedGitPreflight tracks two metric streams:
- Anonymous product telemetry (CLI + installer):
- Endpoints:
POST /api/v1/usage/installPOST /api/v1/usage/review
- Client payload:
{ "installId": "<random-id>" } - Not collected in payload: user identity, email, auth token, repository URL, file contents, patch/diff content.
- Server behavior: Convex HTTP endpoints forward each event to PostHog.
- Endpoints:
- Hosted review metrics (server-side):
- Daily usage quota counters are tracked per user and per org (
usageDaily) when reviews run through the hosted/api/v1/reviewpath. - Per-model aggregates (
modelStats) track runs, findings, and average latency for dashboard reporting.
- Daily usage quota counters are tracked per user and per org (
Local-agent mode note:
- Local reviews do not hit hosted usage quota or model-stat tracking.
- They still send the anonymous
usage/reviewevent (unless opted out below).
Opt out:
# disable anonymous analytics
export GITPREFLIGHT_ANON_TELEMETRY=0
# or
export GITPREFLIGHT_DISABLE_ANON_TELEMETRY=1Override usage endpoint host (CLI/installer):
export GITPREFLIGHT_TELEMETRY_BASE_URL="https://your-gitpreflight-host"Official release builds bake a default usage host at build/publish time (from GITPREFLIGHT_API_BASE_URL in release CI). Runtime env vars still take precedence.
Convex env required for forwarding events:
POSTHOG_API_KEY=phc_...
# optional override (default: https://us.i.posthog.com)
POSTHOG_HOST=https://us.i.posthog.comIf GitPreflight cannot complete a review (network/timeout/server issues):
- The commit is allowed.
- The commit is marked as
UNCHECKEDlocally under.git/gitpreflight/. - The next run on the same branch is blocked until the backlog is cleared or explicitly bypassed.
- One-shot bypass (preferred):
gitpreflight skip-next --reason "<why>"- Universal bypass:
git commit --no-verify
# or (if using pre-push mode):
git push --no-verifyRepo-scoped hooks are a strong local default, but true "required" enforcement needs protected branch checks in your git host.
- Recommended: require a GitPreflight CI status check for merges to protected branches.
- Client hooks alone are bypassable via
--no-verify.
GitPreflight avoids storing customer repo source code at rest.
- The server stores:
- instruction file contents (by hash) when configured (e.g.
AGENTS.md) - review outputs and aggregated usage/statistics
- anonymous usage events keyed by random install ID (forwarded to PostHog)
- instruction file contents (by hash) when configured (e.g.
- The server does not store arbitrary repo files.
To build/run from source:
cd code
bun installRun the CLI from source:
bun packages/cli/src/index.ts --help
bun packages/cli/src/index.ts review --stagedLocal-agent mode shells out to a configured local agent command and expects GitPreflight Markdown output.
Configure it once:
gitpreflight setup local-agentThe setup flow lets you choose a provider (Codex, Claude, or OpenCode), probes the command with a live check, and saves config under ~/.config/gitpreflight/config.json.
Provider default commands:
Codex->codexClaude->claudeOpenCode->opencode run
Probe success criteria before saving config:
- command spawn succeeds
- exit code is
0 - output is non-empty
Config files written:
~/.config/gitpreflight/config.json~/.config/gitpreflight/config.schema.json
Then run reviews with local-agent mode:
gitpreflight review --staged --local-agent