PUBLICATION MESA-2026-003

REV. A — MARCH 2026

Open SourceApache-2.0

Saguaro

Open source AI code review for coding agents. Rules enforced inside Claude Code, Codex, Gemini CLI, and Cursor. Your agent fixes its own mistakes while context is hot.

$ npm install -g @mesadev/saguaro && sag init
1.0IN ACTION
claude
$ claude "add cleanup job for expired sessions"
Read 4 files
Update(src/jobs/cleanup.ts)
Ran stop hook
Saguaro review — fix valid issues, dismiss the rest.
[error] src/jobs/cleanup.ts:47Two sequential DELETEs (session_tokens then sessions) without a transaction. If the first succeeds but the second fails, tokens are removed but expired sessions remain — leaving dangling references. Wrap in db.transaction().
Valid. Wrapping both deletes in a transaction.
Update(src/jobs/cleanup.ts)

sag init sets this up automatically. The background reviewer looks at every change like a staff engineer. It catches bugs, security issues, and regressions without any configuration. The agent fixes findings while context is still hot.

For deterministic enforcement, Saguaro also supports rules: markdown files matched to changed files via globs:

.saguaro/rules/
no-raw-sql.md
require-error-boundary.md
use-server-functions.md
git diff main
M src/auth.ts
M src/api/users.ts
A src/components/Dashboard.tsx
codebase context
imports
dependents
related files
SAGUARO
1Match rules → files
2Gather context
3AI review per file
output
src/api/users.ts:42·no-raw-sql
Raw SQL string interpolation. Use parameterized queries.
2.0RULES

Rules are markdown files in .saguaro/rules/. Saguaro matches them to changed files via globs.

.saguaro/rules/no-raw-sql.md
1---
2id: no-raw-sql
3title: Use parameterized queries for all database calls
4severity: error
5globs:
6 - "src/api/**/*.ts"
7 - "src/db/**/*.ts"
8---
9
10Do not use string interpolation or concatenation to build SQL queries.
11Use parameterized queries or the ORM's query builder.
12
13### Violations
14
15```typescript
16const user = await db.query(`SELECT * FROM users WHERE id = ${id}`)
17```
18
19### Compliant
20
21```typescript
22const user = await db.query('SELECT * FROM users WHERE id = ?', [id])
23```

sag init generates rules from your codebase automatically, or write them by hand. sag rules generate adds more at any time.

3.0INTEGRATION

sag init wires everything automatically. Here's what it creates:

Claude Code

.claude/settings.json
1{
2 "hooks": {
3 "PreToolUse": [{
4 "matcher": "Edit|Write",
5 "hooks": [{
6 "type": "command",
7 "command": "sag hook pre-tool",
8 "timeout": 10
9 }]
10 }],
11 "Stop": [{
12 "hooks": [{
13 "type": "command",
14 "command": "sag hook run",
15 "timeout": 120
16 }]
17 }]
18 }
19}

PreToolUse injects relevant rules before the agent writes code. Stop reviews changes after each turn — blocks on violations.

Manual Review

terminal
$ sag review
src/api/users.ts:42·no-raw-sql[error]
Raw SQL string interpolation. Use parameterized queries.
| SELECT * FROM users WHERE id = ${id}
src/auth.ts:18·no-hardcoded-secrets[error]
Hardcoded API key. Use environment variables.
| const API_KEY = "sk-live-abc123..."
src/tracing.ts:31·otel-no-sensitive-params[warning]
Tracing credential object. Omit sensitive params from Tlm.trace.
| ['repoPath', 'credential']
3 violations: 2 errors, 1 warning
Files reviewed: 4 · Rules checked: 13 · Duration: 2.1s · Cost: $0.03

Run sag review on-demand to check your changes against all rules. JSON output available for CI.

Other Agents

Codex CLIsag review — run manually or in CI
Gemini CLIsag review — same CLI, same rules
Cursorsag review --output json — deeplinks to violations
CIsag review --output json — exit code 1 on errors

Background Daemon

For long sessions, sag daemon start reviews changes in parallel on localhost:7474 — findings surface as soft guidance, no blocking.

4.0SPECIFICATIONS
ExecutionFully local. Your code never leaves your machine.
AI ProvidersAnthropic, OpenAI, Google — uses your agent CLI subscription, no API key needed
AgentsClaude Code, Codex CLI, Gemini CLI, Cursor
Review ModesOn-demand CLI, automatic stop hook, background daemon
OutputConsole with file:line locations, JSON for CI, Cursor deeplinks
Rule FormatMarkdown with YAML frontmatter, glob-based file matching
LicenseApache-2.0 — fully open source
Package@mesadev/saguaro
Sourcegithub.com/mesa-dot-dev/saguaro
Full documentation