{"id":45245487,"url":"https://github.com/spylogsster/git-ai-review","last_synced_at":"2026-02-20T22:05:17.710Z","repository":{"id":339566766,"uuid":"1162400237","full_name":"spylogsster/git-ai-review","owner":"spylogsster","description":"Review your git diff with local Codex CLI or Copilot CLI — run manually in one command or automatically as a git hook","archived":false,"fork":false,"pushed_at":"2026-02-20T13:49:45.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-20T16:52:18.384Z","etag":null,"topics":["ai-code-review","cli","code-review","codex-cli","copilot-cli","developer-tools","diff-review","git-hooks","npm-package","pre-commit"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spylogsster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-02-20T08:05:37.000Z","updated_at":"2026-02-20T13:49:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/spylogsster/git-ai-review","commit_stats":null,"previous_names":["spylogsster/ai-review","spylogsster/ai-diff-review"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/spylogsster/git-ai-review","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spylogsster%2Fgit-ai-review","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spylogsster%2Fgit-ai-review/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spylogsster%2Fgit-ai-review/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spylogsster%2Fgit-ai-review/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spylogsster","download_url":"https://codeload.github.com/spylogsster/git-ai-review/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spylogsster%2Fgit-ai-review/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29666470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T19:49:36.704Z","status":"ssl_error","status_checked_at":"2026-02-20T19:44:05.372Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-code-review","cli","code-review","codex-cli","copilot-cli","developer-tools","diff-review","git-hooks","npm-package","pre-commit"],"created_at":"2026-02-20T22:05:17.140Z","updated_at":"2026-02-20T22:05:17.702Z","avatar_url":"https://github.com/spylogsster.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- SPDX-License-Identifier: MPL-2.0 --\u003e\n# git-ai-review\n\n[![npm](https://img.shields.io/npm/v/git-ai-review)](https://www.npmjs.com/package/git-ai-review)\n\nReview your git diff with your locally installed **Codex CLI**, **Copilot CLI**, or **Claude CLI** — run it manually in one command or automatically as a git pre-commit hook.\n\n## Quick start\n\nInstall and set up the git hook:\n\n```bash\nnpm i -D git-ai-review\nnpx git-ai-review install\n```\n\nThat's it. Every `git commit` will now run an AI review of your staged changes automatically.\n\nYou can also run reviews manually:\n\n```bash\nnpx git-ai-review review\nnpx git-ai-review review --verbose\nnpx git-ai-review review --codex\nnpx git-ai-review review --copilot\nnpx git-ai-review review --claude\n```\n\nOr review the diff between two branches:\n\n```bash\nnpx git-ai-review diff main\nnpx git-ai-review diff main feature-branch\n```\n\nRequirements for the target repo:\n- An `AGENTS.md` file must exist in the repo root (it's used as policy context for the review)\n- At least one reviewer CLI must be installed and authenticated: **Codex CLI** (`codex login`), **Copilot CLI** (`copilot auth`), or **Claude CLI** (`claude`)\n\n## License\n\nThis package is licensed under **MPL-2.0**.\n\n## What it does\n\n`git-ai-review` uses your locally installed AI CLIs to review staged changes before they are committed. You can run it on demand with a single command (`npx git-ai-review review`), review the diff between two branches (`npx git-ai-review diff main feature-branch`), or install it as a git hook so every commit is reviewed automatically.\n\n- Uses your local **Codex CLI** as the primary reviewer.\n- Falls back to **Copilot CLI**, then **Claude CLI** when the previous reviewer is unavailable.\n- Blocks commit when:\n  - any reviewer returns `status: fail`, or\n  - any findings are returned (even with `status: pass`), or\n  - all reviewers are unavailable.\n- Tracks consecutive failures and enables a hard lock after a limit (default `10`).\n- Builds prompt context from:\n  - full `AGENTS.md`,\n  - tracked markdown files referenced by `AGENTS.md` (including wildcard refs like `deploy*.md`).\n- Resolves binaries via environment variables or system PATH, with macOS app-bundle fallback for Codex (`/Applications/Codex.app/Contents/Resources/codex`).\n\n## Prerequisites\n\nAt least one reviewer CLI must be installed and authenticated on each developer machine.\nRecommended: install multiple for resilient fallback behavior.\n\n- Codex CLI (`codex`) with active login (`codex login`) or `OPENAI_API_KEY` env var — primary reviewer\n- Copilot CLI (`copilot`) with active login (`copilot auth`) or `GITHUB_TOKEN` env var\n- Claude CLI (`claude`) with `ANTHROPIC_API_KEY` env var or OAuth login\n\nWhen an API token env var is set, the network preflight check for that reviewer is skipped — this is useful in CI environments or when interactive OAuth login is not available.\n\nDefault fallback chain: Codex → Copilot → Claude. If all are unavailable, review fails.\n\n## Install in another repository\n\n```bash\nnpm i -D git-ai-review\n```\n\nInstall hook files and configure Git:\n\n```bash\nnpx git-ai-review install\n```\n\nThis creates/updates `.githooks/pre-commit` and sets:\n\n```bash\ngit config core.hooksPath .githooks\n```\n\n## Commands\n\nVia `npx`:\n\n```bash\nnpx git-ai-review review\nnpx git-ai-review review --verbose\nnpx git-ai-review review --codex\nnpx git-ai-review review --copilot\nnpx git-ai-review review --claude\nnpx git-ai-review diff main\nnpx git-ai-review diff main feature-branch\nnpx git-ai-review diff main feature-branch --verbose\nnpx git-ai-review diff main feature-branch --codex\nnpx git-ai-review pre-commit\nnpx git-ai-review pre-commit --verbose\nnpx git-ai-review install\n```\n\nVia npm scripts (pass flags after `--`):\n\n```bash\nnpm run git-ai-review -- review\nnpm run git-ai-review -- review --verbose\nnpm run git-ai-review -- review --codex\nnpm run git-ai-review -- review --copilot\nnpm run git-ai-review -- review --claude\nnpm run git-ai-review -- diff main\nnpm run git-ai-review -- diff main feature-branch\nnpm run git-ai-review -- diff main feature-branch --verbose\nnpm run git-ai-review -- pre-commit\nnpm run git-ai-review -- pre-commit --verbose\nnpm run git-ai-review -- install\n```\n\n`npm run ai-review` is an alias for `npm run git-ai-review` — both accept the same commands and flags.\n\n- `review`: run AI review against staged diff.\n- `review --verbose`: print full prompt plus raw model outputs to stdout.\n- `review --codex`: force Codex reviewer only (skip Copilot/Claude fallback).\n- `review --copilot`: force Copilot reviewer only (skip Codex/Claude).\n- `review --claude`: force Claude reviewer only (skip Codex/Copilot).\n- `diff \u003cbase\u003e [head]`: run AI review for the diff between two branches/refs. Uses three-dot diff (`base...head`) to show changes introduced on `head` since it diverged from `base`. If `head` is omitted, defaults to `HEAD`. Supports the same `--verbose` and reviewer flags as `review`.\n- `pre-commit`: run lock-aware pre-commit flow (recommended for hooks).\n- `pre-commit --verbose`: same as pre-commit, but with detailed prompt/raw model logs.\n- `install`: install hook script and set `core.hooksPath`.\n\nThe `--claude`, `--codex`, and `--copilot` flags are mutually exclusive and can be combined with `--verbose`.\n\n## Repository requirements\n\nIn each target repository:\n\n- `AGENTS.md` must exist in repo root.\n- Optional referenced markdown docs (from `AGENTS.md`) should be tracked in git to be included in prompt context.\n- Commits should be made with staged changes (`git add ...`) so diff is reviewable.\n\n## Runtime behavior\n\n- In CI (`CI=true|1|yes`) pre-commit review is skipped.\n- Report is written to `.git/ai-review-last.json` by default.\n- Failure counter file: `.git/ai-review-fail-count`.\n- Lock file after repeated failures: `.git/ai-review.lock`.\n- Unlock manually by removing lock and fail-count files.\n\n## Environment variables\n\n- `ANTHROPIC_API_KEY`: Anthropic API token for Claude — skips network preflight when set.\n- `OPENAI_API_KEY`: OpenAI API token for Codex — skips network preflight when set.\n- `GITHUB_TOKEN`: GitHub token for Copilot — skips network preflight when set.\n- `CODEX_BIN`: custom Codex executable path/name.\n- `COPILOT_BIN`: custom Copilot executable path/name.\n- `CLAUDE_BIN`: custom Claude executable path/name.\n- `COPILOT_REVIEW_MODEL`: default `gpt-5.3-codex`.\n- `AI_REVIEW_TIMEOUT_MS`: default `300000` (5 min).\n- `AI_REVIEW_PREFLIGHT_TIMEOUT_SEC`: default `8`.\n- `AI_REVIEW_FAIL_LIMIT`: default `10`.\n- `AI_REVIEW_REPORT_PATH`: custom report location.\n- `AI_REVIEW_PROMPT_HEADER`: optional prompt-header override.\n  - JSON array format example: `[\"Line 1\",\"Line 2\"]`\n  - Multiline string format example: `Line 1\\nLine 2`\n  - If unset/empty, built-in default header lines are used.\n\n## Verbose logging\n\nUse `--verbose` to print:\n\n- full generated review prompt\n- raw Codex stdout/stderr and structured response file\n- raw Copilot stdout/stderr\n- raw Claude stdout/stderr\n\nThis is useful for debugging prompt behavior and model integration issues.\n\n## Example setup in a target repo\n\n```bash\nnpm i -D git-ai-review\nnpx git-ai-review install\n```\n\nThen commit as usual:\n\n```bash\ngit add .\ngit commit -m \"Your change\"\n```\n\nThe hook will run automatically.\n\n## Publishing\n\nTypical release flow:\n\n```bash\nnpm version patch\nnpm publish\n```\n\nRecommended checks before publish:\n\n```bash\nnpm run typecheck\nnpm test\nnpm run build\nnpm publish --dry-run\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspylogsster%2Fgit-ai-review","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspylogsster%2Fgit-ai-review","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspylogsster%2Fgit-ai-review/lists"}