AIFlare
VisionDocs
Sign inStart free
Getting Started
  • Introduction
  • Quickstart
Features
  • Project Dashboard
  • Project Settings
  • Timeline
  • Team Collaboration
Skills
  • Skills Overview
  • Context Capture
  • Code Intent Lookup
  • Context Inject
  • Daily Digest
  • Weekly Digest
  • Session Compare
  • Session Summary
  • Prompt Evaluation
Administration
  • Members & Invitations
  • Account Settings
Features

Code Intent Lookup (why)

An MCP tool that recovers the timeline of intent behind a line (or file) of agent-written code — every commit that touched it, the intent recorded, the alternatives the agent rejected, and the original conversation. Invoke it from Claude Code with `/why <file>:<line>`, or let the agent call it automatically while debugging.

Overview

Commit messages tell you what changed; why tells you the reasoning behind it. It runs `git log -L` locally to find every commit that touched the target line (or file), then fetches each commit's AIFlare capture — intent, alternatives, diff metadata, conversation — and returns them as a timeline with the most recent commit on top. Commits without captures fall back to a plain commit list.

GranularityFile + line (`git log -L`) or whole file (`git log -- file`). Capped at the 5 most recent commits in either mode.
ScopeOnly captures inside the active project (the one the API key belongs to) are returned. Commit hashes from other projects are silently filtered out.
SafetyRead-only tool, no side effects. All git commands are quoted and run from the repo root to prevent shell injection.
Cap noticeWhen a target has more than 5 touching commits, the response explicitly says "5 most recent of N" so the cap is never mistaken for the full history.

When to use

Reach for it before changing AI-written code — debug and refactor on top of recorded intent instead of guesses.

01
Debugging a bug

When a line looks wrong, check whether it was an intentional workaround or an actual mistake using the commit's recorded intent and rejected alternatives.

02
Pre-refactor check

Before restructuring code you didn't write, surface the constraints and trade-offs that shaped its current form so you don't break invisible contracts.

03
Reading unfamiliar code

Trace how a single line came to exist in a module you didn't author, with the conversation snippets that led to each commit.

04
Agent reviewing its own code

An AI agent should call `why` before patching code that looks suspect — pull up its own (or another agent's) prior intent first, then decide whether to change anything.

Usage

Syntax

Invoke it as a slash command from Claude Code, or let the agent call the tool directly. Add `:<line>` after the file path to track a single line.

/why <file>[:<line>]

Parameters

NameTypeRequiredDefaultDescription
filestringRequired-File path to inspect (relative to the git root, or an absolute path).
linenumberOptional-Line number to explain. Omit to use the file's full history (still capped at the 5 most recent commits).

Flow

1User runs `/why <file>:<line>` → the skill splits the argument into `file` and `line`. With no argument, it infers them from the current debugging context.
2The MCP tool runs `git log -L` locally to list commits that touched the target line (or file). The list is capped at the 5 most recent.
3It calls the backend `/api/v1/captures/by-commits` to batch-fetch the AIFlare captures (intent, alternatives, conversation, diff metadata) for those hashes.
4The response is returned as a Markdown timeline with the newest commit on top. Commits with no capture fall through to a plain commit list.

Common errors

AIFlare not configured

When `aiflare.yml` is missing or has no `api_key`. Returns: "AIFlare is not configured. Place aiflare.yml in your project root."

Not a git repository

When the git root can't be located. Returns: "Not in a git repository."

Bad path or line number

When the file doesn't exist or the line is out of range. Returns: "git query failed — check the file path …"

Output format

Returned as a Markdown string. There are two shapes: one when captures exist, one when they don't.

TIMELINE
With captures — timeline

Each commit becomes a card with Title / Tag / Intent / Alternatives considered / Diff around this line / Conversation behind this commit. The newest commit sits on top; entries are labeled `only` (single capture) or `latest` / `earlier` / `oldest` when there are several.

FALLBACK
Without captures — fallback

Used when commits exist but none are captured in AIFlare. Shows "N commits touched this line, but none are captured in AIFlare." followed by a plain list of commit hash · date · subject. (Commits made before AIFlare was set up, or outside Claude Code.)

why output — timeline (excerpt)
## Intent history for this line
Showing the 5 most recent of 12 commits. 4 of them have AIFlare captures.
### 1. latest — e395786 (2026-05-12)
**Title**: Add JWT token issuance logic
**Tag**: FEATURE
#### Intent
Use HS256 with a short access token (15 min) and a refresh token to balance UX and revocation latency …
#### Alternatives considered
Considered RS256 with key rotation, rejected for ops overhead at the current scale.
5-commit cap notice

When more than 5 commits touched the target, the timeline adds "Showing the 5 most recent of N commits." and the fallback shows "Checked the 5 most recent of N commits, but none are captured in AIFlare."

Errors & fallbacks

Every error is returned as tool response text — never raised to halt the Claude Code session. The agent reads the message and continues with regular debugging.

SituationReturned text
AIFlare not configuredAIFlare is not configured. Place aiflare.yml in your project root.
Not a git repositoryNot in a git repository.
git log failed (bad path or line)git query failed — check the file path …
No commit historyNo commit history found for {file}:{line}. (or …for {file}.)
Backend timeout / network errorError querying AIFlare: {message}
git show failed for one commitOnly that commit's diff section is omitted; the rest of the timeline still renders.

Related features

`why` lives alongside the rest of the AIFlare capture stack.

context-capture

The skill that captures intent, alternatives, and conversation to AIFlare at commit time — it is the source of the data `why` reads back. Commits without a capture land in the fallback branch.

Timeline

Browse the same capture data visually in the web console. Where `why` pulls intent for a single line mid-debug, the timeline view shows the full work history in chronological order.

On this page

AIFlare
Made with ♥ in Seoul
© 2026 AIFlare. All rights reserved.
Product
SkillDocs
Company
Vision
Resources
PrivacyTerms
Connect
GitHub