Skip to content
Back to skills

Why

ASecurity

Explain why a piece of code exists by correlating it to the AI coding sessions behind it. Use when the user asks "why does this exist", "why did we write it this way", "what was the reasoning behind this line/file/commit", "who changed this and why", or points at a file, line, or commit and wants the rationale that git alone does not carry. Use PROACTIVELY before rewriting or removing code whose purpose is unclear — the deciding conversation may still be recoverable.

  • 38 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 10, 2026
ai-agentsrustgit

Security analysis

A100/100

Scanned October 10, 2026

npx -y skills add nicknisi/sessions --skill why --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Why?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Why
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nicknisi-why/badge)](https://www.skillsdirectory.com/skills/nicknisi-why)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: why
description: >-
  Explain why a piece of code exists by correlating it to the AI coding
  sessions behind it. Use when the user asks "why does this exist", "why
  did we write it this way", "what was the reasoning behind this
  line/file/commit", "who changed this and why", or points at a file,
  line, or commit and wants the rationale that git alone does not carry.
  Use PROACTIVELY before rewriting or removing code whose purpose is
  unclear — the deciding conversation may still be recoverable.
argument-hint: a file path, path:line, commit-ish, or topic
---

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.

## Guidelines

- Empty `sessions` is a real answer: say no session correlates, rather than guessing.
- A `time-only` match is a weak signal — present it as "around the same time", not as cause.
- Surface commit `trailers` (e.g. Co-Authored-By) when present; they annotate authorship.
- Lead with the why, then the citations. Keep it to a few sentences unless asked for more.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…