Skip to main content

diff

Compare findings between two analysis states (shows new, fixed, score delta).

Compares baseline (previous analyze) vs current (latest analyze). Each repotoire analyze auto-snapshots findings as the next diff baseline.

Usage: repotoire diff [OPTIONS] [BASE_REF] [PATH]

Options:
  -f, --format <FORMAT>      text|json|sarif|html|markdown  [default: text]
      --fail-on <FAIL_ON>    Exit with code 1 if new findings at this severity or above
                             [possible values: info, low, medium, high, critical]
      --no-emoji             Disable emoji in output
  -o, --output <OUTPUT>      Output file path (default: stdout)
      --all                  Show ALL new findings, not just those in changed hunks
      --changed              Show findings in changed files (hunks + non-hunk), hide unrelated files

Overview

repotoire diff answers a single question: what did this change introduce? It compares two analysis states — typically the prior analyze snapshot vs. the latest one — and reports new findings, fixed findings, and the score delta.

Each repotoire analyze run auto-snapshots its findings as the next diff baseline, so a typical loop is:

  1. repotoire analyze . (seed the baseline)
  2. Make changes
  3. repotoire analyze . (current state)
  4. repotoire diff (what your changes did)

Basic usage

# Diff latest analyze vs. previous analyze
repotoire diff

# Diff against a specific git ref (e.g., main)
repotoire diff main

# Diff against a ref, scoped to a path
repotoire diff main path/to/subdir

Hunk-level attribution (new in 0.7.0)

By default, diff parses git diff -U0 between the two states and only shows new findings inside changed hunks. Pre-existing issues in files you didn't touch — or even in lines you didn't touch within a file you did — are filtered out. This is what makes diff useful as a CI gate and as the engine behind repotoire claude-hook: it surfaces only the regressions your change actually introduced.

If you want a wider view, use --all or --changed:

FlagScope
(default)Only new findings inside changed hunks
--changedFindings in changed files (hunks + non-hunk lines), hide unrelated files
--allEvery new finding across the whole repo

Flags

--format

Choose the output format. Default is text.

repotoire diff --format text       # default, terminal-friendly
repotoire diff --format json       # machine-readable, for CI
repotoire diff --format sarif      # SARIF 2.1.0, GitHub Code Scanning compatible
repotoire diff --format html       # standalone HTML report
repotoire diff --format markdown   # PR comment friendly

--fail-on

Exit with code 1 if new findings at the given severity (or higher) appear. Pairs naturally with diff's default hunk-level scope: you fail the build only if your change introduces new high-severity issues.

repotoire diff --fail-on high
repotoire diff --fail-on critical

Possible values: info, low, medium, high, critical.

--all and --changed

Widen the scope from the hunk-level default:

repotoire diff --all       # everything new in the repo
repotoire diff --changed   # everything new in files you touched

--output

Write to a file instead of stdout. Useful with non-text formats.

repotoire diff --format sarif --output diff.sarif.json
repotoire diff --format html --output diff.html

--no-emoji

Disable emoji in the text reporter. Useful when piping to logs or terminals that don't render them well.

repotoire diff --no-emoji

Examples

repotoire diff                         # Diff latest vs previous analysis
repotoire diff main                    # Diff against main branch
repotoire diff --all                   # Show ALL new findings (not just your changes)
repotoire diff --changed               # Show findings in changed files only
repotoire diff --format json           # JSON output for CI
repotoire diff --fail-on high          # Exit 1 if new high+ findings in your hunks

Workflow

The canonical local loop:

# 1. Seed the baseline
repotoire analyze .

# 2. Make your changes
# ...edit, edit, edit...

# 3. Re-analyze
repotoire analyze .

# 4. See what your changes introduced
repotoire diff

Each analyze writes the next baseline, so you can repeat steps 2–4 as you iterate.

CI usage

Generate a SARIF report scoped to your changes and fail the build on new high-severity findings:

repotoire diff --fail-on high --format sarif --output diff.sarif.json

The SARIF output is GitHub Code Scanning compatible and can be uploaded with the standard github/codeql-action/upload-sarif action. Because diff defaults to hunk-level attribution, the CI gate will only trip on findings the PR actually introduced.

For a Markdown comment on a pull request:

repotoire diff --format markdown --output diff.md

See also