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.
Watch mode. Strict, auditable diffs. Real-time breaking change detection. AST-based contract extraction.
Includes an MCP server. Works with Claude, Cursor, Copilot Chat, and any MCP-compatible agent.
π Table of Contents
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 compiles TypeScript into deterministic architectural contracts and dependency graphs - a machine-readable representation of your system that AI tools can consume instead of parsing raw implementation code.
These contracts:
- Stay in sync with your code (watch mode auto-regenerates)
- Expose interfaces (props, hooks, APIs) without implementation noise
- Are deterministic, diffable, and auditable
- Enable early detection of architectural drift and breaking changes
Example workflow: stamp context --strict-watch generates context bundles that MCP-powered assistants use to explain component architecture (ThemeContext shown here).
Same code β same context output. Contracts are diffable, so you can detect drift and breaking changes.
TypeScript Code β Compilation β Deterministic Contracts β AI Assistant
(.ts/.tsx) (ts-morph) (context.json bundles) (Claude, Cursor)
Try it in 30 seconds (no install required):
npx logicstamp-context contextScans your repo and writes context.json files + context_main.json for AI tools.
What you get:
- π
context.jsonfiles - one per folder with components, preserving your directory structure - π
context_main.json- index file with project overview and folder metadata
For a complete setup (recommended):
npm install -g logicstamp-context
stamp init # sets up .gitignore, scans for secrets
stamp contextβΉοΈ Note: With
npx, runnpx logicstamp-context context. After global install, usestamp context.
π For detailed setup instructions, see the Getting Started Guide.
| Without LogicStamp Context | With LogicStamp Context |
|---|---|
| AI parses 200 lines of implementation to infer a component's interface | AI reads a 20-line interface contract |
| Props/hooks inferred (often wrong) | Props/hooks explicit and verified |
| No way to know if context is stale | Watch mode catches changes in real-time |
| Different prompts = different understanding | Deterministic: same code = same contract |
| Manual context gathering: "Here's my Button component..." | Structured contracts: AI understands architecture automatically |
The key insight: AI assistants don't need your implementation - they need your interfaces. LogicStamp Context extracts what matters and discards the noise.
Instead of shipping raw source code to AI:
// Raw: AI must parse and infer
export const Button = ({ variant = 'primary', disabled, onClick, children }) => {
const [isHovered, setIsHovered] = useState(false);
// ... 150 more lines of implementation
}LogicStamp Context generates:
{
"kind": "react:component",
"interface": {
"props": {
"variant": { "type": "literal-union", "literals": ["primary", "secondary"] },
"disabled": { "type": "boolean" },
"onClick": { "type": "function", "signature": "() => void" }
}
},
"composition": { "hooks": ["useState"], "components": ["./Icon"] }
}Pre-parsed. Categorized. Stable. The AI reads contracts, not implementations.
Core:
- Deterministic contracts - Same input = same output, auditable in version control
- Watch mode - Auto-regenerate on file changes with incremental rebuilds
- Breaking change detection - Strict watch mode catches removed props, events, functions in real-time
- MCP-ready - AI agents consume context via standardized MCP interface
Analysis:
- React/Next.js/Vue component extraction (props, hooks, state, deps)
- Backend API extraction (Express.js, NestJS routes and controllers)
- Dependency graphs (handles circular dependencies)
- Style metadata extraction (Tailwind, SCSS, MUI, shadcn)
- Next.js App Router detection (client/server, layouts, pages)
Developer experience:
- Per-folder bundles matching your project structure
- Accurate token estimates (GPT/Claude)
- Security-first: automatic secret detection and sanitization
- Zero config required - sensible defaults, works out of the box
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).
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.
Compare regenerated context against existing files:
stamp context compare # detect changes
stamp context compare --approve # update (like jest -u)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.
The compilation pipeline:
- Scan - Discovers all
.tsand.tsxsource files - Parse - Builds AST (Abstract Syntax Tree) via
ts-morphusing the TypeScript compiler API - Extract - Compiles contracts with props, hooks, state, signatures
- Graph - Resolves dependency relationships
- Emit - Outputs
context.jsonbundles per folder - Index - Generates
context_main.jsonwith metadata and statistics
Why AST-based compilation matters: LogicStamp leverages the full TypeScript compiler (via ts-morph) for deterministic, type-aware contract extraction. Prop types, hooks, and composition patterns are resolved structurally - not inferred from text or retrieval.
One command. No build step required.
π‘Tip: Use
stamp contextfor basic contracts. Usestamp context stylewhen you need style metadata (Tailwind classes, SCSS selectors, layout patterns). Use--style-mode lean(default) for compact output or--style-mode fullfor detailed arrays.
π What LogicStamp Context Is (and Isn't)
LogicStamp Context IS:
β A context compiler - Uses the TypeScript compiler API (via ts-morph) to compile source code into deterministic architectural contracts.
β Deterministic - Same input always produces the same output. Contracts are auditable and diffable.
β Local execution - Runs entirely on your machine (no cloud services, no network calls).
β Framework-aware - Understands React, Next.js, Vue, Express, and NestJS patterns and extracts relevant metadata.
β Non-opinionated - Describes what exists without enforcing patterns or architectural decisions.
LogicStamp Context IS NOT:
β A code generator - It never writes or modifies your source code.
β A documentation generator - It produces structured contracts, not documentation.
β A build or runtime tool - It compiles contracts from static source code; it does not execute or bundle your application.
β A linter, formatter, or testing framework - It does not check code quality or run tests.
β An AI behavior controller - It provides structured context; it does not alter AI responses.
β A replacement for reading code - It accelerates understanding without replacing engineering judgment.
For AI assistants with MCP support (Claude Desktop, Cursor, etc.):
npm install -g logicstamp-mcpThen configure your AI assistant to use the LogicStamp MCP Server.
π See LogicStamp MCP Server Repository
π See MCP Getting Started Guide for setup instructions.
LogicStamp Context generates structured JSON bundles organized by folder:
{
"type": "LogicStampBundle",
"entryId": "src/components/Button.tsx",
"graph": {
"nodes": [
{
"entryId": "src/components/Button.tsx",
"contract": {
"kind": "react:component",
"interface": {
"props": {
"variant": { "type": "literal-union", "literals": ["primary", "secondary"] },
"onClick": { "type": "function", "signature": "() => void" }
}
},
"composition": {
"hooks": ["useState"],
"components": ["./Icon"]
}
}
}
],
"edges": [["src/components/Button.tsx", "./Icon"]]
}
}π See docs/schema.md for complete format documentation.
npm install -g logicstamp-contextAfter installation, the stamp command is available globally.
Automatic Secret Protection
LogicStamp Context protects sensitive data in generated context:
- Security scanning by default -
stamp initscans source files (.ts,.tsx,.js,.jsx) and.jsonfiles for hard-coded secrets before context compilation - Automatic sanitization - Detected secrets replaced with
"PRIVATE_DATA"in output - Manual exclusions - Use
stamp ignore <file>to exclude files via.stampignore - Safe by default - Only metadata included. Credentials only appear in
--include-code fullmode
β οΈ Seeing"PRIVATE_DATA"in output? Reviewstamp_security_report.json, remove hardcoded secrets from source, use environment variables instead.
π See SECURITY.md for complete security documentation.
π» CLI Usage Reference
stamp --version # Show version
stamp --help # Show help
stamp init [path] # Initialize project (security scan by default)
stamp ignore <path> # Add to .stampignore
stamp context [path] # Generate context bundles
stamp context style [path] # Generate with style metadata (lean mode by default)
stamp context style --style-mode full # Generate with full style details (verbose)
stamp context --watch # Watch mode
stamp context --strict-watch # Watch with breaking change detection (--watch optional)
stamp context compare # Detect changes vs existing context
stamp context validate [file] # Validate context files
stamp context clean [path] # Remove generated files| Option | Description |
|---|---|
--depth <n> |
Dependency traversal depth (default: 2) |
--include-code <mode> |
Code inclusion: none|header|full (default: header) |
--include-style |
Extract style metadata (Tailwind, SCSS, animations) |
--format <fmt> |
Output format: json|pretty|ndjson|toon (default: json) |
--max-nodes <n> |
Maximum nodes per bundle (default: 100) |
--profile <p> |
Preset: llm-chat, llm-safe, ci-strict, watch-fast |
--compare-modes |
Show token cost comparison across all modes |
--stats |
Emit JSON stats with token estimates |
--out <path> |
Output directory |
--quiet |
Suppress verbose output |
--strict-missing |
Exit with error if any missing dependencies found (CI-friendly) |
--debug |
Show detailed hash info (watch mode) |
--log-file |
Write change logs to .logicstamp/ (watch mode) |
π See docs/cli/commands.md for complete reference.
| Framework | Support Level | What's Extracted |
|---|---|---|
| React | Full | Components, hooks, props, styles |
| Next.js | Full | App Router roles, segment paths, metadata |
| Vue 3 | Partial | Composition API (TS/TSX only, not .vue SFC) |
| Express.js | Full | Routes, middleware, API signatures |
| NestJS | Full | Controllers, decorators, API signatures |
| UI Libraries | Full | Material UI, ShadCN, Radix, Tailwind, Styled Components, SCSS, Chakra UI, Ant Design (component usage, props, composition; not raw CSS) |
βΉοΈ Note: LogicStamp Context analyzes
.tsand.tsxfiles only. JavaScript files are not analyzed.
Full documentation at logicstamp.dev/docs
- Getting Started Guide
- Usage Guide
- Monorepo Support
- Output Schema
- UIF Contracts
- Watch Mode
- Troubleshooting
LogicStamp Context is in beta. Some edge cases are not fully supported.
π See docs/limitations.md for the full list.
- Node.js >= 20
- TypeScript codebase (React, Next.js, Vue (TS/TSX), Express, or NestJS)
- Issues - github.com/LogicStamp/logicstamp-context/issues
- Roadmap - logicstamp.dev/roadmap
Branding & Attribution
The LogicStamp Fox mascot and related brand assets are Β© 2025 Amit Levi. These assets may not be used for third-party branding without permission.
Contributing
Issues and PRs welcome! See CONTRIBUTING.md for guidelines.
This project follows a Code of Conduct.
Links: Website Β· GitHub Β· MCP Server Β· Changelog

