codegenie 🧞
AI code review harness. codegenie is a TypeScript CLI that reviews PR-style diffs at a staff-engineer level — real bugs, logic errors, security issues, architectural risks, and missing tests — and avoids wasting your attention on nitpicks. It prefers no comments over weak comments. codegenie supports all popular LLM providers.
It is not a chatbot pointed at a diff. It is a multi-staged code review harness: a staged pipeline where deterministic code owns the guarantees (coverage, anchoring, verification, dedup, budgets, telemetry) and LLM agents do the judgment work inside each stage. codegenie is built on pi AI library and tree-sitter language parser to offer the harness more powerful tools to traverse code more efficiently.
Install
npm install -g @0xsequence/codegenie # or: bun install -g @0xsequence/codegenie
Or run without installing: npx @0xsequence/codegenie --help
Run codegenie skill to print a SKILL.md guide for agents running and interpreting reviews.
Note: the npm package will move out of the @0xsequence scope in the future.
Quick start
# 1. Connect a model provider (pick one)
codegenie provider login anthropic --api-key # Anthropic API key
codegenie provider login openai-codex # ChatGPT plan (browser OAuth)
codegenie provider login openai --api-key # OpenAI API key
codegenie provider login openrouter --api-key # OpenRouter API key setup
# 2. Pick your default model (fuzzy-matched)
codegenie provider use luna:xhigh # -> openai/gpt-6-luna
codegenie provider use opus # -> anthropic/claude-opus-5-5
codegenie provider use gpt-5.5 # -> openai-codex/gpt-5.5
codegenie provider use deepseek-v4.1-flash:max # -> openrouter/deepseek/deepseek-v4.1-flash
codegenie provider use glm-5.3:max # -> openrouter/z-ai/glm-5.3
# 3. Review your current branch
codegenie review
Codegenie's built-in model overrides pin all OpenRouter models with IDs starting with deepseek/ to the deepseek, fireworks, and together upstreams (in that order) with only/order and allow_fallbacks: false. For this pinned model family, submit calls expose only the submit tool and use tool_choice: "auto", to accommodate the named forced-tool rejection observed on DeepSeek V4.1 Flash. Returned submissions still undergo strict validation, and missing submissions have bounded retries. Anthropic models whose thinking cannot be turned off (Pi catalog thinkingLevelMap.off: null: Claude Opus 5.5, Sonnet 5.5 and Fable 5.1/5.2, which reject a forced tool_choice, and Fable 5) submit the same way, with tool_choice: "auto" and their configured reasoning. These OpenRouter routing preferences apply to every stage, including repairs; Codegenie's stage-specific reasoning levels still apply. Requests cannot fall back to upstreams outside that list. Routing is included in debug request traces and local model-call cache keys. The overrides live in src/provider/models-override.ts.
OpenRouter models with IDs starting with z-ai/ use only: ["together", "fireworks", "cloudflare"], order: ["together", "fireworks", "cloudflare"], and allow_fallbacks: false. This routing override applies across stages, including repairs, and preserves the model's reasoning and tool-choice behavior. It does not add require_parameters.
In our trails-api eval, pinning OpenRouter to DeepSeek's own upstream together with the automatic submit-tool compatibility setting produced significantly better completion and performance: DeepSeek V4.1 Flash at max finished run 79 in 8m23s, reviewed all 10/10 hunks, found the expected bug, and passed with zero timeouts. Before these changes, run 77 took 42m19s and failed completeness with seven unreviewed hunks. Composition dropped from almost six minutes (including a timed-out attempt) to 20 seconds. Recorded cost rose from about $0.14 to $0.26; timed-out calls in run 77 had incomplete usage reporting. This is one eval comparison, not a guarantee for every DeepSeek model or workload: run 79 also used the fallback planner with normal coverage rather than run 77's mostly deep coverage, and still needed schema repairs. The override targets the deepseek/ model namespace on OpenRouter; it does not call DeepSeek's API directly or change other model families.
The report prints to stdout as Markdown. A review with findings is a successful review: the exit code is 0 either way.
Reviewing
codegenie review # current branch vs its base (merge-base semantics)
codegenie review --pr 123 # a GitHub PR — no checkout needed, fork PRs included
codegenie review feat # branch vs resolved base
codegenie review --branch feat --base main
codegenie review master...49f4645b # shorthand for --base master --head 49f4645b
codegenie review abc1234 # one commit
codegenie review abc1234 def5678 # a commit range
codegenie review --staged # HEAD vs the Git index
codegenie review --uncommitted # HEAD vs tracked working-tree files
A single positional target is branch-first: if it resolves as a branch, codegenie reviews it against its base; otherwise it is treated as a single commit.
Use --staged to review the next commit, or --uncommitted to review staged and unstaged tracked changes together. Both options capture the code in a temporary Git snapshot and prohibit GitHub posting. On an unborn branch the base is empty. These reviews have no commit messages for inferring intent.
--uncommitted reports the number of omitted untracked files and skips ignored files. Run git add -N <path> to include a new file without staging its contents. Git applies configured clean filters when capturing tracked working-tree files.
First-class syntax context and default language guidance currently cover Go, TypeScript, JavaScript, Rust, Python, and Solidity. JavaScript has its own lang/javascript guidance for runtime semantics; .js, .jsx, .mjs, and .cjs share the proven ECMAScript adapter implementation without inheriting TypeScript-only checks. JavaScript CommonJS export inference, Flow/JSDoc semantic typing, unsupported proposal syntax, and framework/bundler semantics remain deferred. Solidity packets include contract-owned methods/types/events/errors/state values, source-only imports, overload-safe declaration identity, and deterministic default Foundry test links only when a nearest foundry.toml exists. File-level constants are not value symbols. Solidity storage-layout, generated-getter, ABI/export analysis, custom Foundry directories, and Hardhat TypeScript linking remain deferred; Solidity symbols intentionally leave exported unset. Python .pyi stubs/custom collection and Rust same-file/arbitrary integration-test discovery also remain deferred.
Rust, Python, and Solidity form one language-inventory unit. Their three default-enabled skills intentionally change the global Stage-5 skill inventory, registry hash, and model-call cache identity. That single external measurement boundary occurred when the complete Phase 1-4 inventory reached origin/next at eb20533; measurements from before and after that revision are not comparable as the same cache/prompt regime. The later Phase-5 gate at 40b87b0 changes validation, packaging policy, fixtures, tests, and documentation but not the bundled-skill inventory or registry hash. A branch push is not an npm/tagged release: master, the latest tag, and npm latest remain at v0.4.2 until an explicit release occurs.
The dedicated JavaScript skill and narrowed TypeScript skill create a second intentional Stage-5 inventory/registry/cache boundary at the revision where this complete Phase-6 unit first becomes externally visible. Measurements across that landing are non-comparable prompt/cache regimes. A local implementation or branch push remains distinct from a master merge, tag, npm publication, or GitHub release.
Common options:
codegenie review --lens lang/go --lens core/tests # restrict lenses for this run
codegenie review --provider anthropic --model claude-opus-5 # one-run model override
codegenie review --model claude-opus-5:max # model[:reasoning] shorthand
codegenie review --reasoning high # minimal | low | medium | high | xhigh | max | auto
codegenie review --format json # machine-readable review object
codegenie review --pr 123 --post-github-comments # publish inline comments (explicit flag, never config)
Posting to GitHub is a single COMMENT-type review with inline comments anchored to changed lines — it never approves or requests changes, and only happens when you pass the flag. Interactive runs show a stderr progress spinner (auto-disabled in CI; --no-progress disables it explicitly). Non-posting Markdown/JSON runs emit the full report to stdout; posting runs emit a concise posting summary instead. Action mode separately renders the full report into the status comment, step summary, and report artifact.
For prose files (.md, .mdx, .rst, .txt), unchanged inline comment content is deduplicated across shifted anchors on the same file and diff side. Matching uses the complete sanitized body before truncation; changed wording remains eligible for posting. Executable examples under docs/ retain code fingerprint matching. Separate findings are not merged merely because they occur in the same document.
GitHub Action
codegenie ships as a reusable GitHub Action: reviews run automatically on PR open/update, or on demand when a collaborator comments codegenie review on a PR. The run posts a single status comment ("Reviewing ...") that live-updates through the pipeline stages and finishes as the full markdown report; inline finding comments post as a PR review alongside it (on by default, post-inline-comments: "false" disables).
# .github/workflows/codegenie.yml
name: codegenie review
on:
pull_request:
types: [opened, synchronize, ready_for_review]
permissions:
contents: read
pull-requests: write
issues: write
concurrency:
group: codegenie-review-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true # newest event wins; a push supersedes the stale review
jobs:
review:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.base.sha }} # trusted base; PR head is fetched as review data
fetch-depth: 0
- uses: 0xPolygon/codegenie@v0.9.3
with:
# Works with any model!
model: "openrouter/openai/gpt-6-luna:xhigh"
# model: "openrouter/deepseek/deepseek-v4.1-flash:max"
# model: "openrouter/z-ai/glm-5.3:max"
# model: "anthropic/claude-opus-5:high"
# Set the llm-api-key to the api key for the respective model provider.
# for example, for Claude, pass an Anthropic key, for OpenRouter models
# pass the OpenRouter API Key.
llm-api-key: ${{ secrets.LLM_API_KEY }}
The model input is one spec: provider/model[:reasoning] — any model in models.md works (openai/gpt-5.5:xhigh, google/gemini-3-pro, ...), with reasoning defaulting to high. llm-api-key is provider-generic: codegenie routes it to whatever variable the named provider reads. When llm-api-key is set it is the only model key — it overrides that provider's env vars. Without it, codegenie reads the provider's own env vars (see Credentials).
Several models, picked per comment
List named models once. model stays the default for automatic reviews and a bare codegenie review. A collaborator can comment codegenie review opus to run that one review with the opus entry instead.
- uses: 0xPolygon/codegenie@v0.9.3
env:
# one credential env var per provider in the list (see Credentials below)
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
with:
model: luna # default: an alias below, or a full spec
models: |
luna: openrouter/openai/gpt-6-luna:xhigh
deepseek: openrouter/deepseek/deepseek-v4.1-flash:max
glm: openrouter/z-ai/glm-5.3:max
opus: anthropic/claude-opus-5:high
- Grammar. The first word after the trigger phrase, on the same line, is looked up in
models (case-insensitive; surrounding quotes or backticks and trailing punctuation are ignored, so `opus` and opus. both work). Nothing else in the comment is read. Comments cannot supply a model spec, a reasoning level or any other option; to offer a reasoning variant, add an alias for it (opus-max: anthropic/claude-opus-5:max). Without models, text after the trigger phrase is ignored exactly as before.
- Unknown names.
codegenie review opsu runs no review. codegenie replies with the configured names (Unknown model. Available: luna (default), deepseek, …), and only to collaborators who pass the permission check.
- Keys.
models holds model specs only — never put keys in it. With several providers, set each provider's env var on the step, as above. If every configured model uses one provider, a single llm-api-key covers them all. When llm-api-key is set and the models span several providers, every run fails with a configuration error instead of sending one provider's key to another. On a self-hosted runner where someone ran codegenie provider login for that provider, the stored login would take precedence, so the run fails and says to log out there or drop llm-api-key.
- Precedence change.
llm-api-key now wins over a provider env var for the same provider. Older releases preferred the env var. A workflow that sets both, with different values, now uses llm-api-key.
- One status comment. A
codegenie review opus comment supersedes an in-flight run on the same PR (newest event wins), and the PR's single status comment shows the newest report.
- A mistyped name still cancels.
codegenie review opsu starts a run that supersedes the running review, then only posts the reply — the same "any comment supersedes" trade-off described below.
- Inline comments accumulate across models. A
codegenie review opus run after an automatic review posts its own inline findings. Duplicate suppression only matches unchanged wording, so two models reporting the same issue both appear. That is expected for a second opinion.
Advanced: per-stage Action models
Use stage-models with the Action's global model on a release that documents this input. Each of plan, review, verify, and compose can set model (a provider/model ID) or reasoning. Omitted fields inherit the global choice independently.
with:
model: openrouter/openai/gpt-6-luna:high
stage-models: |
plan:
reasoning: medium
compose:
reasoning: low
llm-api-key: ${{ secrets.OPENROUTER_API_KEY }}
The workflow map supplies the stage settings for automatic reviews and bare trigger comments. A comment that explicitly selects a configured alias applies that choice across all stages and logs that the workflow map was skipped. Explicit compose.reasoning disables the usual composition step-down.
Models, credentials, and reasoning support are checked before model calls. With llm-api-key, the global model, every alias, and every explicit stage model must read the same credential variable. Use native provider credentials for a workflow that needs different keys.
Mixed-model review quality is unmeasured. There is no recommended mix.
Credentials
Each provider reads its key from its own env var. The common ones: