The Context Compiler for TypeScript. Supports: React · Next.js · Vue (TS/TSX) · Express · NestJS LogicStamp Context is a CLI that compiles TypeScript codebases into deterministic, diffable architectural contracts and dependency graphs - a compact, structured source of truth for AI coding workflows. Includes watch mode, strict, auditable diffs, and real-time breaking change detection. Use with logicstamp-mcp to feed…
LogicStamp Context is a CLI that compiles TypeScript codebases into deterministic, diffable architectural contracts and dependency graphs - a compact, structured source of truth for AI coding workflows.
Includes watch mode, strict, auditable diffs, and real-time breaking change detection.
Use with logicstamp-mcp to feed structured context into Claude, Cursor, and other MCP-compatible assistants.
AI coding assistants read your source code - but they don’t understand its structure.
They hallucinate props, miss dependencies, and can’t detect when a breaking change impacts consumers.
Example: your Button accepts variant and disabled, but the AI suggests isLoading because it saw that pattern elsewhere. Without a structured contract, there is no reliable source of truth.
LogicStamp Context derives that layer from your TypeScript - explicit interfaces and dependency structure for tools to consume instead of inferring from implementation.
Key Capabilities:
Contracts, not raw source code - Props, hooks, routes, and dependency edges extracted for tools
Deterministic & diffable - Same code → same bundles
Stays current - Watch mode keeps context aligned with your codebase
MCP-ready - Works with Claude, Cursor, and MCP-compatible assistants
Example workflow: stamp context --strict-watch generates context bundles that MCP-powered assistants use to explain component architecture (ThemeContext shown here).
Pre-parsed. Categorized. Stable. The AI reads contracts, not implementations.
On disk, each folder’s context.json is a LogicStampBundle: contracts live under graph.nodes, with graph.edges for dependencies. context_main.json indexes folders and metadata. Full JSON shape:docs/reference/schema.md.
⚡ Features
Under the hood: the TypeScript compiler API (via ts-morph). Analysis-only - it describes your codebase and emits context files. It does not transform or refactor your source.
Core:
Deterministic contracts - Same input = same output, auditable in version control
Watch mode - Auto-regenerate on file changes with incremental rebuilds
Per-folder bundles matching your project structure
Token estimates: GPT-4o via tiktoken when installed (o200k_base, same as gpt-5 in tiktoken’s bundled table). Not every OpenAI model uses that encoding, and very new model IDs may require a newer @dqbd/tiktoken. Claude via optional Anthropic tokenizer (approximate for Claude 3+ per vendor docs) or char fallback
Security-first: automatic secret detection and sanitization
Zero config required - sensible defaults, works out of the box
How it fits your stack
Works alongside tsc - Focuses on contract structure and change detection, not type-checking. Use tsc --noEmit for compiler errors. compare --strict and --strict-watch flag contract-level breaking changes.
Context, not control - Feeds structured context to assistants. Decisions stay with you.
📋 For detailed behavior, CLI options, and workflows, see the Usage guide.
Watch Mode
Strict watch mode in action: detecting violations and clearing them when resolved.
For development, run watch mode to keep context fresh as you code:
stamp context --watch # regenerate on changes
stamp context --strict-watch # also detect breaking changes (implies --watch)
Strict watch catches breaking changes that affect consumers:
Violation
Example
breaking_change_prop_removed
Removed disabled prop from Button
breaking_change_event_removed
Removed onSubmit callback
breaking_change_function_removed
Deleted exported formatDate()
contract_removed
Deleted entire component
Errors vs Warnings: Violations are classified by severity:
❌ Errors indicate breaking changes that will affect consumers (removed props, events, functions, or entire contracts).
⚠️ Warnings indicate less severe changes (type signature changes, removed internal state). Violations are tracked in real-time and automatically cleared when resolved.
Session Status Tracking: Strict watch mode displays a session status block showing cumulative statistics:
Errors/Warnings detected: Total violations detected during the session
Resolved: Number of times all violations were completely resolved
Active: Current number of active violations
The status block only appears when violations change (not on every file change), keeping terminal output clean.
Example terminal output showing violations and session status.
ℹ️ Note: Strict Watch currently detects breaking changes at the source. Next step: a symbol-level import/export reverse index to trace which consumer files will break. See docs/cli/watch.md for complete documentation.
One-time Comparison
Compare regenerated context against existing files:
Useful for reviewing changes before committing or validating context is up-to-date.
Git baseline comparison(v0.7.2): Compare against any git ref:
stamp context compare --baseline git:main # Compare against main branch
stamp context compare --baseline git:HEAD # Compare against HEAD
stamp context compare --baseline git:v1.0.0 # Compare against a tag
ℹ️ Note: Context files are gitignored by default. Git baseline comparison uses git worktrees to generate context for both the baseline ref and the current working tree, then performs a structural contract comparison. See docs/cli/compare.md for complete documentation.
How it Works
The compilation pipeline:
Scan - Discovers all .ts and .tsx source files
Parse - Builds AST (Abstract Syntax Tree) via ts-morph using the TypeScript compiler API
Extract - Compiles contracts with props, hooks, state, signatures
Graph - Resolves dependency relationships
Emit - Outputs context.json bundles per folder
Index - Generates context_main.json with metadata and statistics
One command. No build step required.
💡 Tip: Use stamp context for basic contracts. Use stamp context style when you need style metadata (Tailwind classes, SCSS selectors, layout patterns). Use --style-mode lean (default) for compact output or --style-mode full for detailed arrays.
MCP Server
For AI assistants with MCP support (Claude Desktop, Cursor, etc.):
npm install -g logicstamp-mcp
Then configure your AI assistant to use the LogicStamp MCP Server.
Routes, API signatures (middleware not extracted. see limitations)
NestJS
Full
Controllers, decorators, API signatures
UI Libraries
Full
Material UI, ShadCN, Radix, Tailwind, Styled Components, CSS/SCSS (modules & imports), Chakra UI, Ant Design
ℹ️ Note: LogicStamp Context analyzes .ts and .tsx files only (JavaScript is not analyzed). Styling (Tailwind, SCSS, CSS Modules, UI libraries) is extracted as structured style metadata, not raw CSS. See the Style command.
LLM evaluations (with vs without LogicStamp context)
Requirements
Node.js >= 20
ESM-only - This package is ESM-only ("type": "module"). CommonJS require() is not supported. In CommonJS environments, use dynamic import() or an ESM-compatible setup.
TypeScript codebase - .ts / .tsx only (JavaScript is not yet analyzed). Frameworks, UI libraries, and limits: Framework support.
评论