why

why is a skill for Claude Code, Codex from nicknisi/sessions. It costs 105 tokens per session (797 once invoked), scanned A, original, MIT.

A read-only tool workflow that explains why code exists by linking files, lines, commits, or topics to the AI coding sessions that produced them.

In plain words
What is it for?
It is for investigating implementation choices, identifying who changed code and why, and checking for abandoned attempts.
Why use it?
It helps recover the reasoning behind code when the commit message or surrounding code does not explain the decision.

Skill for Claude CodeCodex

Part of the sessions plugin — 7 skills, 1 MCP server shipped together

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 skills/nicknisi/sessions/why
Any agent
npx skills add nicknisi/sessions --skill why
Clone the repo
git clone --depth 1 https://github.com/nicknisi/sessions

Made for: Claude Code, Codex.

Or install sessions, the plugin that ships this one along with the rest of its 7 skills, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for why

README.md
[![agentmods](https://agentmods.dev/badge/skills/nicknisi/sessions/why.svg)](https://agentmods.dev/skills/nicknisi/sessions/why)
Your own site
<a href="https://agentmods.dev/skills/nicknisi/sessions/why"><img src="https://agentmods.dev/badge/skills/nicknisi/sessions/why.svg" alt="Measured on agentmods" height="20"></a>
Per session 105 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 797 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.00105 $0.00797
Opus 5 $0.00053 $0.00398
Sonnet 5 $0.00021 $0.00159
Haiku 4.5 $0.00011 $0.00080

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

Security

Grade A, and why

why 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 4d 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.

plugin/skills/why/SKILL.md · 59 lines

How it starts

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

Explain why code exists by finding the session that produced it.

Steps

  1. Call why_did_this_change with the user's target as target:

    • A file → src/cache.ts
    • A specific line → src/cache.ts:142 (pins the commit via git blame)
    • A commit → a sha, tag, or HEAD~2
    • A topic → free text (searches sessions in this repo, no git)

    The tool is read-only: it never writes to the repository.

  2. Read the evidence. The result carries the resolved commit (subject, author time, files, trailers; null for the free-text form) and ranked sessions. Trust confidence: files+time (the session edited the committed files inside its window) is stronger than time-only (same repo and window, no file overlap). Two flags change how you read the commit: commit.merge: true means this is the merge that landed the change, not the commit that wrote it — the reasoning lives in the sessions, not the merge subject. A non-empty unlandedAttempts (file form only) means sessions touched this file but no commit ever landed from them — a possible abandoned attempt.

  3. Synthesize a short answer from each session's excerpts and headline. Explain the reasoning and any abandoned approaches — the part git does not record. Do not invent rationale the excerpts do not support.

  4. Cite each session you used: its tool, date (startedAt), and headline. Distinguish files+time matches from time-only matches so the user can weigh them.

  5. Check closed PRs before concluding "fixed". When the question is "was this fixed" or "does this bug still exist", git history alone is not proof: a fix may have been tried and rejected without leaving a commit. If the repo has a GitHub remote and gh is available, run gh search prs --state closed -- <terms> (or gh pr list --search "<file>" --state closed) and report a closed-unmerged attempt alongside any merged fix. Skip silently when gh or a GitHub remote is absent.

  6. Offer a deep-dive. If the user wants more, call get_session_messages with a session's filePath (use an excerpts[].msgIndex as the offset) to read the full exchange.

Read the full file on GitHub · 59 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. 4d ago First seen · 59 lines · 105 tokens per session scan A 640383b6e911

Subscribe to this mod's changes

why is a skill published in the GitHub repository nicknisi/sessions (30 stars, last pushed 3d ago), licensed MIT. It adds 105 tokens to every session and 797 once invoked, about $0.0005 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.

Related

Other skills, from other repositories

code-review

Review seekdb pull requests and diffs for high-signal correctness, resource-lifetime, concurrency, current-version state-consistency, credential-exposure, workflow-security, performance, and test-evidence defects. Use when reviewing changes to seekdb C++, Rust, build, CI, or test code; report only actionable Blocker…

oceanbase/seekdb · 82 tokens

ygrep

IMPORTANT: Try ygrep FIRST for all code and file searches before using Grep, Glob, or Task explore. ygrep uses a pre-built full-text index and returns results in milliseconds. Fall back to built-in tools only if ygrep returns no results.

yetidevworks/ygrep · 55 tokens

mikke

ノートフォルダ (Markdown KB) を mikke CLI で検索する。「○○について調べて」「過去のメモは?」「以前どう解決したか」等、過去の知見・記録を引き出す時に起動。最新仕様・時事・バージョン依存の質問では起動しない (Web が真)。.

kimushun1101/mikke · 87 tokens

dowse

Search the user's local files with dowse, a Windows full-text search index (Chinese + English, PDF/txt/md/code). Use this when the user asks you to find something on their disk — a note, a doc, a config, "that file about X" — instead of grepping the whole filesystem.

ltspace/dowse · 67 tokens

docingest-docs

Find, search, and read approved documentation snapshots through DocIngest.

Amal-David/docingest · 20 tokens

session-recall

Recall past AI coding sessions as long-term memory. Use at the START of any non-trivial task, and whenever the user references earlier work ("like we did before", "the X we set up", "last time", "that bug fix"), asks who/when a file was changed, or you need context that predates this conversation. Runs the local…

youdie006/sessionwiki · 103 tokens