contextsnap
Reuse, don't reimplement · ~4× fewer tokens · Works in chat, MCP & CI

Your AI finally knows what you've already built.

contextsnap snapshots your codebase exports in one command. Paste into Claude, ChatGPT, or Gemini and get code that actually reuses what you have.

or try it now: npx contextsnap src/utils

contextsnap

The problem

You prompt. Your AI reimplements.

Every time you open a new chat, your LLM starts from scratch. It writes a formatDate function even though you have one in src/utils/date.ts. Duplicate logic, subtle differences, hours of debugging.

The fix

One command. Full codebase awareness.

contextsnap reads your exports, strips function bodies, and hands the AI a compact map of everything available. No wasted tokens on implementation detail — just the contract your AI needs to make the right call.

What's inside

Everything you need, nothing you don't.

Zero config

Run contextsnap with no arguments. It auto-detects src/utils, lib, or src and scans everything.

MCP Server

contextsnap --mcp starts a Model Context Protocol server. Claude, Cursor, and Windsurf call it automatically — no clipboard needed.

Watch mode

contextsnap --watch re-runs every time you save a file. Your context snapshot stays fresh without lifting a finger.

Smart parsing

Extracts signatures only — function names, params, return types, JSDoc. Bodies stripped. ~4× fewer tokens than pasting raw source.

Line numbers

Every signature carries a // :N source line. AI agents jump straight to an implementation instead of reading the whole file.

Validated extraction

Every file is cross-checked against es-module-lexer. An export the fast parser misses still shows up as a stub with a warning — never a silent gap.

Config file

Set default dirs, ignore patterns, and output format in .contextsnaprc.json. CLI flags always override.

GitHub Action

uses: myothuko98/contextsnap@v2 auto-commits .ai-context.md on every push so your whole team benefits.

MCP query tools

search_exports finds a utility by name or JSDoc and answers with file:line. get_file_context returns one file's contract — far cheaper than a full snapshot.

CLAUDE.md inject

contextsnap --inject writes the snapshot between markers in CLAUDE.md or AGENTS.md. Every AI session picks it up — no clipboard, no setup.

CI drift check

contextsnap --check exits 1 when the committed snapshot is stale. Version-stamped, so a generator mismatch is reported clearly. Runs in CI like a lint step.

Token budget

--budget=2000 trims the least-imported exports until the snapshot fits your ceiling. Usage ranking ignores npm-package name collisions.

Duplicate detector

--dupes flags formatDate vs dateFormat style duplicates across files with file:line pairs, and exits 1 for CI. Stop duplication before your AI adds more.

Monorepo aware

npm, yarn, and pnpm workspaces auto-detected. Cross-package import hints say '@acme/ui' — never a brittle ../../packages path.

v2 headline feature

Claude sees your codebase automatically.

contextsnap --mcp starts a Model Context Protocol server. Add it to Claude Desktop, Claude Code, or Cursor once — and from then on your AI calls it on its own. No clipboard. No copy-paste. Just context, on demand.

Works with Claude Desktop & Claude Code
Works with Cursor and Windsurf
Any MCP-compatible host
claude_desktop_config.json
{
  "mcpServers": {
    "contextsnap": {
      "command": "contextsnap",
      "args": ["--mcp"]
    }
  }
}

Get started

Up and running in seconds.

npx (no install)
npx contextsnap src/utils
Global install
npm install -g contextsnap
MCP (Claude Desktop)
{
  "mcpServers": {
    "contextsnap": {
      "command": "contextsnap",
      "args": ["--mcp"]
    }
  }
}

Zero config to start. Drop a .contextsnaprc.json in your project root to set default directories, ignore patterns, and output format. Commit it so your whole team uses the same settings.

How it works

The pipeline, in four steps.

01Scan

Walks your target directories for .js, .ts, .jsx, .tsx files. Respects .contextsnapignore and --ignore patterns.

02Parse

Extracts exported names, signatures, source lines, and JSDoc. Handles ESM and CommonJS — and cross-checks every file against es-module-lexer so nothing is silently missed.

03Compile

Builds a markdown (or JSON) snapshot with per-file import hints and an AI reuse preamble. Contracts only — no bodies.

04Deliver

Copies to clipboard, writes .ai-context.md, streams to stdout, or serves via MCP — depending on how you invoked it.

Stop teaching your AI what you've built.

One command and your LLM knows your entire utility layer. Your stack. Your contracts. Your code.