Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Why CodeNew to Visual Studio Code? Get it now.
Why Code

Why Code

Ullas Js

|
2 installs
| (0) | Free
Explains in plain words why a piece of code exists and what it is connected to, using git history and (optionally) your Claude Code sessions.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Why Code

AI writes a lot of our code now, and much of it slips past us. When you come back to it later, you can't tell why it is there or what it is connected to.

Why Code tells you, in plain words.

How it works

  1. Git history. It finds the commits that last changed the code (git blame), along with their messages, the other files changed in the same commit, and the diff.
  2. Claude Code sessions (optional, off by default). If the code was written by Claude Code, it finds the prompt you gave and what Claude said right before writing it. That is usually the real "why".
  3. A plain-words summary. It sends that evidence to Claude, which explains why the code exists, what it connects to, and anything to watch out for.

Where you see it

  • Hover over any line to see the commit behind it, with an Explain why link.
  • "Why?" above functions and classes (CodeLens) explains the whole block.
  • Why Code panel in the Explorer sidebar shows the full explanation, the original request and the commits.
  • Right-click → Why Code: Explain Why This Code Exists works on any selection.

AI setup

Why Code works without any AI and shows git history only. For plain-words explanations, it uses the first of these it finds:

  1. Claude Code CLI. If claude is installed, it is used automatically. If VS Code can't find it, set whyCode.claudeCli.path to its full path (run which claude in a terminal).
  2. Your Anthropic API key. Run Why Code: Set Anthropic API Key. The key is kept in VS Code's secret storage. You pay for your own usage.

Privacy

  • Session reading is off by default. Turn it on with whyCode.claudeSessions.enabled.
  • Session logs are read on your machine. Only the matched prompt, the code, and its git history are sent to the AI you set up.
  • Nothing is sent anywhere when whyCode.ai.provider is off.

Settings

Setting Default What it does
whyCode.ai.provider auto auto, claudeCli, apiKey or off
whyCode.ai.model claude-opus-5-5 Model used with your API key
whyCode.claudeCli.path claude Path to the Claude Code CLI
whyCode.claudeSessions.enabled false Read local Claude Code sessions
whyCode.hover.enabled true Show the hover
whyCode.codeLens.enabled true Show "Why?" above functions

Development

npm install
npm run build      # bundle to dist/
npm run typecheck
npm run package    # build a .vsix

Press F5 in VS Code to open an Extension Development Host with the extension loaded.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft