diff

A Git-aware command that lists changed files and adds related code symbols and dependencies.

In plain words
What is it for?
Use it to compare changes with a Git reference, narrow them by file patterns, inspect related code, or count files within an output limit.
Why use it?
It gives code review and pre-commit checks the surrounding context needed to understand what a change may affect.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/agentis-tools/ctx/diff
Clone the repo
git clone --depth 1 https://github.com/agentis-tools/ctx
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 950 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00950
Opus 5 $0.00000 $0.00475
Sonnet 5 $0.00000 $0.00190
Haiku 4.5 $0.00000 $0.00095

Measured 2d ago against content hash f4df04fa7103, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

diff scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/commands/diff.md · 142 lines

How it starts

The opening of the file, as written. The whole thing — 142 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ctx diff

Generate context for changed files with their related dependencies.

Synopsis

ctx diff [REF] [PATTERNS]... [OPTIONS]

Description

The diff command identifies changed files compared to a git reference and includes context about the symbols and dependencies affected by those changes. This is useful for:

  • Code review - Get context for reviewing a PR or commit
  • Change impact - Understand what's affected by your changes
  • Pre-commit - Verify changes before committing

Optional positional patterns restrict both changed files and graph-expanded context. Literal files, directories, and globs are ORed together. Renames match when either the old or new path is in scope; deletions remain visible in the change summary. With no patterns, . includes all changed paths.

Options

Option Description Default
REF Git reference to compare against HEAD
--max-tokens <N> Maximum tokens in output 8000
--depth <N> Depth for finding related symbols 2
--summary Include a change summary on stderr false
--count-only Count selected, budgeted files instead of streaming contents false
--encoding <ENCODING> Tokenizer used for budgeting and counting (cl100k_base, o200k_base, or p50k_base) cl100k_base
--stats Print count timing to stderr with --count-only false

Examples

Changes Since Last Commit

# See what changed since HEAD
ctx diff

Compare with Branch

# Changes compared to main branch
ctx diff main

# Changes in feature branch
ctx diff origin/main

# Review only Rust sources and the public configuration contract
ctx diff origin/main "src/**/*.rs" docs/configuration.md

Review a Specific Commit

# Changes in the last commit
ctx diff HEAD~1

Token-Limited Output

# Limit output for smaller context windows
ctx diff --max-tokens 4000

# Count the files selected by that budget without streaming them
ctx diff --max-tokens 4000 --count-only --encoding o200k_base

Read the full file on GitHub · 142 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 142 lines · 0 tokens per session scan A f4df04fa7103

Subscribe to this mod's changes

diff is a command published in the GitHub repository agentis-tools/ctx (11 stars, last pushed 15d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 950 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.