# How AI-Powered Code Review Works in no-mistakes: A Technical Deep Dive

> Discover how AI-powered code review in no-mistakes inspects git diffs using configurable LLM agents for precise, safe findings that respect user intent.

- Repository: [Kun Chen/no-mistakes](https://github.com/kunchenguid/no-mistakes)
- Tags: deep-dive
- Published: 2026-07-14

---

**The no-mistakes engine implements an AI-powered code review pipeline that automatically inspects every push by extracting precise git diffs, routing them through configurable LLM agents, and returning structured findings that respect user intent while enforcing strict safety boundaries.**

The `no-mistakes` open-source project delivers automated code quality enforcement through a daemon-driven pipeline architecture. At its core sits an **AI-powered code review** system that integrates with multiple LLM backends—including OpenAI Codex, Anthropic Claude, and GitHub Copilot—to analyze changes without ever exposing telemetry data externally. This guide dissects the end-to-end flow from the initial `git diff` invocation in [`internal/git/git.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/git/git.go) to the final safety validations in [`internal/types/findings.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/types/findings.go).

## Pipeline Initialization and Diff Extraction

When the daemon detects a push, it initiates a new run record and enters the **review step** defined in [`internal/pipeline/steps/review.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/review.go). The step first captures the exact changeset by invoking `git diff` through the abstraction layer in [`internal/git/git.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/git/git.go), obtaining both the modified file list and the precise hunk text.

This diff extraction isolates the review surface to only added or modified lines, establishing the **focused verification** guarantee that prevents the LLM from wandering into unchanged codebase areas.

```go
// internal/pipeline/steps/review.go – core of the review step
func (s *ReviewStep) Run(ctx context.Context, run *db.Run) error {
    diff, err := git.Diff(run.Worktree, run.HeadSHA)
    if err != nil { return err }

    prompt := reviewPrompt{
        Diff:      diff,
        Intent:    run.Intent, // may be nil
        Contract:  "Only suggest fixes for the changed area",
    }

    // Choose the configured agent (default: opencode)
    agent := agents.NewConfiguredAgent(run.Config.Agent)
    resp, err := agent.Invoke(ctx, prompt.String())
    if err != nil { return err }

    findings, err := types.ParseFindings(resp)
    if err != nil { return err }

    return db.SaveFindings(run.ID, findings)
}

```

## Intent Handling and Prompt Construction

The system supports explicit developer intent through the `axi run --intent` flag, which persists in the database via [`internal/db/run_intent.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/db/run_intent.go) and attaches to the review context.

### Provenance Tracking

Before prompt generation, the pipeline loads any stored intent and tracks its provenance through [`internal/pipeline/steps/intent_prompt.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/intent_prompt.go). This allows the review step to detect when an LLM suggestion contradicts the stated intent, automatically converting such conflicts into `ask-user` findings rather than silent overrides.

### The Review-Fix Contract

The `ReviewStep` constructs a structured prompt containing:
- A concise change description
- The full diff output
- Any explicit intent metadata
- The **review-fix contract** instructing the LLM to suggest fixes only within the changed area

The prompt template resides in the skill body ([`internal/skill/skill.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/skill/skill.go)) and is reproduced in the generated [`SKILL.md`](https://github.com/kunchenguid/no-mistakes/blob/main/SKILL.md) documentation.

## Agent Architecture and LLM Invocation

no-mistakes decouples LLM communication through a common **agent adapter** interface defined in [`internal/agent/agent.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/agent.go), enabling seamless switching between providers without modifying core pipeline logic.

### Configurable Agent Selection

Repository-specific configuration in [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) (the `commands.agent` field) determines which adapter handles the request. The available implementations include:
- **[`internal/agent/opencode.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/opencode.go)** — The default Open-Code agent
- **[`internal/agent/codex.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/codex.go)** — OpenAI Codex integration
- **[`internal/agent/claude.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/claude.go)** — Anthropic Claude backend
- **[`internal/agent/copilot.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/copilot.go)** — GitHub Copilot adapter

Each adapter implements the same contract: receive a prompt string, invoke the remote LLM, and return a JSON response conforming to `types.Findings`.

```go
// internal/agent/opencode.go – the default agent implementation
func (a *OpencodeAgent) Invoke(ctx context.Context, prompt string) (string, error) {
    // Build the HTTP request to the opencode service
    req := opencode.NewRequest(prompt).WithMetrics()
    resp, err := a.client.Do(req.WithContext(ctx))
    if err != nil { return "", err }
    return resp.BodyAsString(), nil
}

```

### Privacy-Preserving Metrics

During invocation, [`internal/agent/invocationmetrics.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/invocationmetrics.go) records token usage, model latency, and elapsed time—stored locally via [`internal/agent/codex_metrics.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/codex_metrics.go) and never transmitted to external services. This satisfies the project's privacy guarantees by keeping all telemetry data on-host.

```go
// internal/agent/codex_metrics.go – collecting invocation metrics
func (m *CodexMetrics) Record(start time.Time, tokens int, modelTimeMS int) {
    m.FreshInputTokens = tokens
    m.ModelTimeMS = modelTimeMS
    m.Elapsed = time.Since(start).Milliseconds()
}

```

## Response Parsing and Safety Enforcement

Once the LLM returns output, the pipeline converts raw text into actionable data structures with rigorous safety checks.

### Structured Finding Parsing

The [`internal/types/findings.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/types/findings.go) parser validates the JSON schema and ensures every finding contains a safe `action` field. Findings lacking an explicit action default to `ask-user`, preventing unintended automated modifications. Valid entries include `ask-user`, `auto-fix`, and other gated statuses.

### Persistence and UI Display

Validated findings are written to the run database through [`internal/db/run_findings.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/db/run_findings.go), then surfaced to developers via [`internal/tui/cli_review.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/tui/cli_review.go). If a finding carries the `AutoFixable` flag, the pipeline may apply the fix automatically; otherwise, it blocks for manual resolution.

## Session Isolation and Re-Review Logic

To prevent rationale contamination, [`internal/pipeline/sessions.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/sessions.go) guarantees that the reviewer and fixer each receive independent sessions. After a fix is applied, the pipeline may trigger a *re-review* cycle, but it never runs a full test suite during the fix round—honoring the **focused verification contract** verified in [`internal/pipeline/steps/review_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/review_test.go).

## Summary

- The **review step** in [`internal/pipeline/steps/review.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/review.go) orchestrates AI-powered code review by extracting diffs, building structured prompts, and delegating to LLM agents.
- Intent handling via [`internal/db/run_intent.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/db/run_intent.go) and [`internal/pipeline/steps/intent_prompt.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/intent_prompt.go) ensures LLM suggestions respect explicit developer direction or escalate to manual review.
- Four **agent adapters** ([`internal/agent/opencode.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/opencode.go), [`codex.go`](https://github.com/kunchenguid/no-mistakes/blob/main/codex.go), [`claude.go`](https://github.com/kunchenguid/no-mistakes/blob/main/claude.go), [`copilot.go`](https://github.com/kunchenguid/no-mistakes/blob/main/copilot.go)) implement a common interface for multi-provider LLM support.
- Privacy-preserving metrics in [`internal/agent/invocationmetrics.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/invocationmetrics.go) keep all performance data local.
- Safety defaults in [`internal/types/findings.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/types/findings.go) require explicit `ask-user` action for any ambiguous finding, preventing blind auto-fixes.
- Session isolation in [`internal/pipeline/sessions.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/sessions.go) maintains clean separation between review and fix contexts.

## Frequently Asked Questions

### What LLM providers does no-mistakes support for code review?

no-mistakes supports OpenAI Codex, Anthropic Claude, GitHub Copilot, and Open-Code through dedicated adapter implementations in [`internal/agent/codex.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/codex.go), [`claude.go`](https://github.com/kunchenguid/no-mistakes/blob/main/claude.go), [`copilot.go`](https://github.com/kunchenguid/no-mistakes/blob/main/copilot.go), and [`opencode.go`](https://github.com/kunchenguid/no-mistakes/blob/main/opencode.go) respectively. The default agent is Open-Code, but you can configure any provider via the `commands.agent` field in [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml).

### How does no-mistakes ensure the AI only reviews changed code?

The review step enforces a **focused verification** contract by including only the `git diff` output in the prompt and explicitly instructing the LLM to limit suggestions to the changed area. This contract is tested in [`internal/pipeline/steps/review_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/review_test.go) and ensures the pipeline never triggers full test suites during fix rounds.

### Can I prevent the AI from overriding my specific coding intent?

When you provide an explicit intent via `axi run --intent`, the system tracks provenance in [`internal/pipeline/steps/intent_prompt.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/intent_prompt.go). Any LLM suggestion that contradicts this intent is automatically converted into an `ask-user` finding rather than being applied or suggested as an auto-fix.

### How does no-mistakes handle privacy when calling external LLM APIs?

Invocation metrics—including token counts and latency—are captured in [`internal/agent/invocationmetrics.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/invocationmetrics.go) and stored locally via [`internal/agent/codex_metrics.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/codex_metrics.go). According to the source code, these metrics remain on-host and are never sent to external services, satisfying the project's privacy guarantees while still allowing performance monitoring.