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

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 to the final safety validations in 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. The step first captures the exact changeset by invoking git diff through the abstraction layer in 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.

// 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 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. 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) and is reproduced in the generated 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, enabling seamless switching between providers without modifying core pipeline logic.

Configurable Agent Selection

Repository-specific configuration in .no-mistakes.yaml (the commands.agent field) determines which adapter handles the request. The available implementations include:

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

// 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 records token usage, model latency, and elapsed time—stored locally via 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.

// 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 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, then surfaced to developers via 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 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.

Summary

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, claude.go, copilot.go, and opencode.go respectively. The default agent is Open-Code, but you can configure any provider via the commands.agent field in .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 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. 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 and stored locally via 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.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →