explain-changes-mental-model

A command that explains a code change by dividing it into smaller logical parts and ordering them by dependency.

In plain words
What is it for?
Use it with uncommitted work, commits, branches, ranges, or supplied custom changes to see what changed, why the parts belong together, and what depends on what.
Why use it?
It makes large or unfamiliar diffs easier to understand and review as a connected set of changes.

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/softaworks/agent-toolkit/explain-changes-mental-model
Clone the repo
git clone --depth 1 https://github.com/softaworks/agent-toolkit
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,647 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.00013 $0.01647
Opus 5 $0.00006 $0.00823
Sonnet 5 $0.00003 $0.00329
Haiku 4.5 $0.00001 $0.00165

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

Security

Grade A, and why

explain-changes-mental-model 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 yesterday.

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.

commands/explain-changes-mental-model.md · 215 lines

How it starts

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

Mental Model Builder

Analyze code changes and present them as a coherent mental model - breaking large diffs into logical chunks ordered by dependency so they can be understood incrementally.

What This Command Does

  1. Gather changes from the specified source (commit, branch, range, or custom input)
  2. Analyze and categorize changes into logical groups by theme/purpose
  3. Identify dependencies between change groups
  4. Present ordered explanation so changes can be reviewed in a sensible sequence

Usage

# Current working changes (staged + unstaged)
/mental-model

# Specific commit
/mental-model abc1234
/mental-model HEAD~3

# Branch comparison (vs main)
/mental-model feature/my-branch

# Explicit range
/mental-model main..HEAD
/mental-model origin/main...HEAD

# Custom - user will provide diff/changes in next message
/mental-model custom

Implementation Steps

When this command is invoked:

1. Determine Change Source

Parse the argument to determine what changes to analyze:

No argument provided:

  • Run git diff HEAD to get all uncommitted changes (staged + unstaged)
  • If no changes found, report "No uncommitted changes to analyze"

Argument looks like a commit hash (7-40 hex chars):

  • Run git show <hash> --stat first to verify it exists
  • Run git show <hash> to get the full diff

Argument looks like a branch name (contains letters, no ..):

  • Detect main branch: check if main or master exists
  • Run git diff <main-branch>...<argument> to compare

Argument contains .. (explicit range):

  • Use as-is: git diff <argument>

Argument is "custom":

  • Tell the user: "Please paste or describe the changes you want me to analyze in your next message."
  • Wait for user input before proceeding

2. Extract the Diff

Run the appropriate git command and capture the output:

# Example for commit
git show <hash> --no-color

# Example for range
git diff <range> --no-color

If the diff is very large (>5000 lines), use --stat first to get an overview, then selectively read the most important files.

Read the full file on GitHub · 215 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. yesterday First seen · 215 lines · 13 tokens per session scan A edb34aa61a66

Subscribe to this mod's changes

explain-changes-mental-model is a command published in the GitHub repository softaworks/agent-toolkit (2,401 stars, last pushed 5mo ago), licensed MIT. It adds 13 tokens to every session and 1,647 once invoked, about $0.0001 per session on Opus 5. 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.