Code Guru
A CLI tool that leverages AI (Claude Code CLI or OpenAI API) to automatically review pull requests across GitHub and Azure DevOps, enforcing coding standards from configurable rule files.
Features
- Multi-provider support via gitforge: GitHub and Azure DevOps
- Dual AI backend: Claude Code CLI (
claude --print) or OpenAI Chat Completions API
- Rule-based reviews using Markdown files from guide (or any directory)
- YAML
frontmatter in rules for file-glob-based filtering (e.g., paths: ["**/*.go"])
- Inline and general PR comments posted back via gitforge
- Three modes: single PR review, batch review-all, and discover (list open PRs)
Installation
go install github.com/rios0rios0/codeguru/cmd/code-guru@latest
Or build from source:
git clone https://github.com/rios0rios0/code-guru.git
cd code-guru
go build -o code-guru ./cmd/code-guru/
Configuration
Create a .code-guru.yaml file (searched in ., .config, configs, ~, ~/.config):
providers:
- type: 'github'
token: '${GITHUB_TOKEN}'
organizations:
- 'rios0rios0'
- type: 'azuredevops'
token: '${AZURE_DEVOPS_PAT}'
organizations:
- 'MyOrg'
ai:
backend: 'claude'
claude:
binary_path: 'claude'
model: 'sonnet'
max_turns: 1
openai:
api_key: '${OPENAI_API_KEY}'
model: 'gpt-4o'
rules:
path: '${HOME}/Development/github.com/rios0rios0/guide/.ai/claude/rules'
categories: []
Token Resolution
Tokens support three resolution strategies:
- Environment variable:
${GITHUB_TOKEN} expands from the environment
- File path: if the resolved string is a file path, its contents are read
- Inline: literal token string
Usage
Discover open PRs
code-guru discover -c .code-guru.yaml
Review all open PRs (batch mode)
code-guru review-all -c .code-guru.yaml --dry-run
code-guru review-all -c .code-guru.yaml
Review a single PR
code-guru review https://github.com/org/repo/pull/123
code-guru review https://dev.azure.com/org/project/_git/repo/pullrequest/456
Flags
| Flag |
Description |
-c, --config |
Path to config file (default: auto-discover) |
--backend |
AI backend: openai, claude, or anthropic |
--rules-path |
Path to rules directory |
--dry-run |
Run review without posting comments |
-v, --verbose |
Enable debug logging |
Supported Providers
| Provider |
Type Key |
PR Comments |
Inline Comments |
| GitHub |
github |
Yes |
Yes |
| Azure DevOps |
azuredevops |
Yes |
Yes |
AI Backends
| Backend |
Key |
How It Works |
| Anthropic |
anthropic |
Calls the Anthropic Messages API directly via Go SDK |
| Claude Code |
claude |
Invokes claude --print CLI as a subprocess |
| OpenAI |
openai |
Calls the Chat Completions API with JSON response format |
AI Verdict
Each review returns a verdict alongside comments:
| Verdict |
Meaning |
approve |
No blocking issues, safe to merge |
request_changes |
Error-level issues that must be fixed |
comment |
Informational feedback only, not blocking |
The verdict is printed as VERDICT:<value> for machine parsing.
Trivial PR Detection
When trivial detection is enabled and CI has passed, PRs matching built-in adapters are handled without calling the LLM, saving tokens. In webhook mode, CI status is provided by the webhook event. In CLI mode, CI status detection is planned via gitforge's GetPullRequestCheckStatus() (not yet available).
There are two categories of trivial adapters:
Update Adapters (Dependency Updates)
These detect dependency update PRs and auto-approve them.
| Adapter |
Matches When |
update-go |
Only go.mod, go.sum, CHANGELOG.md changed |
update-node |
Only package.json, lock files, CHANGELOG.md changed |
update-python |
Only pyproject.toml, requirements*.txt, CHANGELOG.md |
Bump Adapters (Version Bumps / Releases)
These detect version bump (release ceremony) PRs. If the repo contains an .autobump.yaml config file, the adapter validates that all version files declared in the config are present in the PR. Missing files result in a reject verdict.
| Adapter |
Default Files |
AutoBump Language Key |
bump-go |
CHANGELOG.md |
go |
bump-node |
package.json, CHANGELOG.md |
typescript |
bump-python |
*/__init__.py, CHANGELOG.md |
python |
Other Adapters
| Adapter |
Matches When |
docs-only |
Only *.md files changed |
Configuration
Configure in .code-guru.yaml:
trivial:
enabled: true
adapters:
- 'update-go'
- 'bump-go'
- 'docs-only'
Or via environment variables: CODE_GURU_TRIVIAL_ADAPTERS=update-go,bump-go,docs-only
Environment Variable Configuration
For CI/CD environments without a config file, all settings can be provided via CODE_GURU_* environment variables:
| Variable |
Description |
Default |
CODE_GURU_BACKEND |
AI backend |
openai |
CODE_GURU_OPENAI_API_KEY |
OpenAI API key |
|
CODE_GURU_ANTHROPIC_API_KEY |
Anthropic API key |
|
CODE_GURU_RULES_PATH |
Path to rules directory |
|
CODE_GURU_PROVIDER_TOKEN |
Git provider token |
|
CODE_GURU_TRIVIAL_ADAPTERS |
Comma-separated adapter names |
|
Rules
Rules are Markdown files loaded from the configured rules.path. Each file represents a rule category (e.g., security.md, golang.md, testing.md).
Rules can include YAML frontmatter with paths globs for file-specific filtering:
---
paths:
- "**/*.go"
---
# Go Conventions
Use `gofmt` for formatting...
Universal categories (always included): architecture, ci-cd, code-style, design-patterns, documentation, git-flow, security, testing.
Contributing
Contributions are welcome. See CONTRIBUTING.md for guidelines.
License
See LICENSE for details.