See also: MCP Integration Guide for MCP server architecture | CLI Commands Reference for CLI usage | Quick Start for getting started
LogicStamp Context is a zero-configuration CLI tool that analyzes TypeScript codebases and generates machine-readable context bundles optimized for AI assistants and CI/CD pipelines. It extracts comprehensive component metadata, builds dependency graphs, and produces structured JSON documentation that captures the complete architecture of your application.
Note: This document describes LogicStamp Context CLI capabilities. For MCP server usage, see the MCP Integration Guide and README.
For each component in your codebase, LogicStamp Context generates a detailed contract that includes:
- Component name - Extracted from function/class declarations and file names
- File path - Both relative (
entryPathRel) and absolute (entryPathAbs) paths - Entry ID - Normalized identifier used for dependency tracking
- Kind detection - Automatically classifies components as:
react:component- React functional or class componentsts:module- TypeScript utility modulesnode:cli- CLI entry points
- Next.js framework detection:
- Page/Layout identification - Detects files in Next.js App Router (
/appdirectory) - Client component - Identifies
'use client'directive - Server component - Identifies Server Components (in
/appwithout'use client') - Server action - Detects
'use server'directive
- Page/Layout identification - Detects files in Next.js App Router (
- TypeScript type inference - Extracts prop types from:
- Interfaces ending with
Props(e.g.,ButtonProps) - Type aliases ending with
Props - Inferred from function parameters
- Interfaces ending with
- Rich type descriptors:
- Simple types:
string,number,boolean - Literal unions:
"primary" | "secondary" | "tertiary" - Function types:
(data: FormData) => Promise<void> - Optional properties: Marked with
optional: true - Complex types: Objects, arrays, generics
- Simple types:
- useState extraction - Captures all
useStatehooks with:- State variable names
- Inferred types (from generics or initial values)
- State shape documentation
- useReducer detection - Identifies reducer patterns and state management
- Context usage - Detects
useContexthooks and identifies consumed contexts
- Default exports - Identifies default-exported components
- Named exports - Lists all named exports from the file
- Export patterns - Documents export structure for proper import usage
LogicStamp Context builds a comprehensive dependency graph showing how components relate to each other:
- Component dependencies - Lists all React components rendered within each component
- Dependency resolution - Resolves relative imports and tracks component relationships
- Used by / Uses relationships:
dependencies- Components this component uses (outgoing edges)usedBy- Components that use this component (incoming edges)
- Dependency depth - Configurable traversal depth (default: 1, supports deeper analysis)
- Import tracking - Captures all import statements:
- React ecosystem:
react,react-dom,next/router, etc. - State management:
react-query,zustand,redux, etc. - Design systems:
@mui/material,@chakra-ui/react, etc. - Utility libraries:
lodash,date-fns, etc.
- React ecosystem:
- External package identification - Distinguishes between:
- Internal components (analyzed and included)
- External packages (documented but not analyzed)
- Missing dependencies (tracked in
meta.missing)
- Root components - Entry points not used by other components
- Leaf components - Primitive components with no dependencies
- Circular dependency detection - Identifies and reports circular import patterns
- Missing dependency tracking - Documents unresolved imports with reasons
LogicStamp Context analyzes component behavior patterns and provides semantic hints:
- State management hooks:
useState,useReducer - Effect hooks:
useEffect,useLayoutEffect - Performance hooks:
useMemo,useCallback - Context hooks:
useContext - Ref hooks:
useRef,useImperativeHandle - Custom hooks: Any hook matching
use[A-Z]pattern
- Data fetching - Detects patterns like:
- React Query hooks (
useQuery,useMutation) - Fetch API usage
- Async data loading functions
- React Query hooks (
- Navigation - Identifies routing patterns:
- Next.js router usage (
next/router,next/navigation) - React Router patterns
- Route string literals in JSX
- Next.js router usage (
- Event handlers - Extracts event handler signatures:
onClick,onSubmit,onChange, etc.- Function signatures for each handler
- Event propagation patterns
Automatically infers component roles based on patterns:
- Form - Components with form validation,
onSubmithandlers - Layout - Components in layout directories or with layout patterns
- List - Components rendering arrays or collections
- API route - Next.js API route handlers
- Page - Next.js page components
- Presentational - Pure display components with no state/events
- Interactive - Components with state and event handlers
- Utility - Helper modules and utility functions
When enabled with --predict-behavior, adds semantic predictions:
- Form validation logic detection
- Side effect management patterns
- Data fetching/mutation indicators
- Memoization usage hints
- Loading/error state handling
- Performance optimization patterns
When using stamp context style or stamp context --include-style, LogicStamp Context analyzes and extracts visual and layout information:
- Tailwind CSS - Categorized classes (layout, spacing, colors, typography, borders, effects)
- SCSS/CSS Modules - Module imports, selectors, properties, SCSS features (variables, nesting, mixins)
- Inline Styles - Detects
style={{...}}usage - styled-components/Emotion - Styled component declarations, theme usage
- framer-motion - Motion components, animation variants, gesture handlers, viewport animations
- Layout Type - Identifies flex or grid layouts
- Grid Patterns - Column configurations (e.g., "grid-cols-2 md:grid-cols-3")
- Hero Patterns - Detects hero sections (large text + CTA buttons)
- Feature Cards - Identifies grid layouts with card-like elements
- Responsive Breakpoints - Lists all breakpoints used (sm, md, lg, etc.)
- Color Palette - Extracts color classes (bg-, text-, border-*)
- Spacing Patterns - Identifies padding and margin utilities used
- Border Radius - Detects rounded corner patterns
- Typography - Extracts text size and font weight classes
- Animation Library - framer-motion or CSS
- Animation Type - fade-in, slide, etc.
- Trigger Type - inView, hover, click, etc.
Style metadata appears in the style field of component contracts (UIFContract) when style information is detected. Components without style usage will not have a style field.
LogicStamp Context extracts and preserves existing documentation:
- JSDoc blocks - Extracts
@param,@returns,@exampletags - Component comments - Preserves comments attached to components
- Prop documentation - Captures prop descriptions from JSDoc
- Code headers - Generates structured
@uifcontract headers with:- Component description
- Version (composition breakdown)
- Logic signature summary
- Behavioral predictions
- Semantic and file hashes
- Auto-generated descriptions - Infers component purpose from:
- File name patterns (e.g.,
Button.tsx→ "Interactive button component") - Component structure (state, events, props)
- Framework context (Next.js, React Router)
- File name patterns (e.g.,
- Context-aware labels:
- "Form component with validation" for form components
- "Modal/dialog component" for modal patterns
- "Navigation component" for nav/menu files
- "Utility module" for helper files
- Custom descriptions - Supports manual description override in contracts
The main index file provides a high-level overview of the entire codebase:
- Project metadata:
- Project root path (relative and absolute)
- Generation timestamp
- Tool version information
- Summary statistics:
- Total components analyzed
- Total bundles generated
- Total folders with context files
- Total token estimate (for AI cost planning)
- Per-folder entries - One entry per directory containing components:
path- Relative path from project rootcontextFile- Path to folder'scontext.jsonfilebundles- Number of bundles in this foldercomponents- List of component filesisRoot- Whether this is an application entry pointrootLabel- Human-readable label (e.g., "Next.js App", "Project Root")tokenEstimate- Estimated token count for this folder
- Component relationships - Overview of how folders relate
- Root identification - Marks entry point folders
- Token budgeting - Per-folder token estimates for selective loading
LogicStamp Context generates a folder-organized structure that mirrors your project:
project-root/
├── context_main.json # Main index with folder metadata
├── context.json # Root folder bundles (if any)
├── src/
│ └── context.json # Bundles from src/ folder
├── src/components/
│ └── context.json # Bundles from src/components/
└── src/utils/
└── context.json # Bundles from src/utils/
Each context.json file contains an array of bundles. Each bundle represents:
- Root component - The entry point component
- Dependency graph - All components used by the root (up to configured depth)
- Complete contracts - Full UIFContract for each component in the bundle
- Code snippets - Optional source code (none/header/full modes)
- Metadata - Missing dependencies, generation info
Each component contract (UIFContract) includes:
{
type: 'UIFContract',
schemaVersion: '0.3',
kind: 'react:component' | 'ts:module' | 'node:cli',
entryId: string, // Normalized component path
entryPathAbs: string, // Absolute file path
entryPathRel: string, // Relative POSIX path
description: string, // Natural language summary
version: {
variables: string[], // Variable declarations
hooks: string[], // React hooks used
components: string[], // Components rendered
functions: string[], // Function declarations
imports: string[] // Import statements
},
logicSignature: {
props: Record<string, PropType>, // Props with types
emits: Record<string, EventType>, // Event handlers
state?: Record<string, string> // useState shapes
},
exports?: ExportMetadata, // Default/named exports
prediction?: string[], // Behavioral hints
nextjs?: { // Next.js metadata
directive?: 'client' | 'server',
isInAppDir?: boolean
},
semanticHash: string, // Content-based hash
fileHash: string, // File-based hash
style?: { // Style metadata (when includeStyle: true)
styleSources: {
tailwind?: {
categories: {
layout: string[],
spacing: string[],
colors: string[],
typography: string[],
borders: string[],
effects: string[]
},
breakpoints: string[],
classCount: number
},
scssModule?: string,
scssDetails?: {
selectors: string[],
properties: string[],
features: {
variables: boolean,
nesting: boolean
}
},
motion?: {
components: string[],
variants: string[],
features: {
gestures: boolean,
viewportAnimations: boolean
}
}
},
layout: {
type: "flex" | "grid",
cols?: string,
hasHeroPattern?: boolean,
hasFeatureCards?: boolean
},
visual: {
colors: string[],
spacing: string[],
radius?: string,
typography: string[]
},
animation?: {
library: "framer-motion" | "css",
type: string,
trigger: string
}
}
}- Works out of the box on any TypeScript project
- No build step required - analyzes source files directly
- Automatic component detection and classification
- Three code inclusion modes:
none- Contracts only (smallest, ~79% savings)header- Contracts + JSDoc headers (balanced, ~65% savings)full- Complete source code (largest, no savings)
- Automatic token estimates - GPT-4o-mini and Claude token counts
- Mode comparison - See token costs across all modes
- Per-folder token estimates - Budget-aware context loading
- Semantic hashing - Content-based hashes for change detection
- File hashing - File-based hashes for integrity checking
- Reproducible builds - Same input produces same output
- Next.js App Router - Detects pages, layouts, client/server components
- React patterns - Recognizes hooks, context, refs
- TypeScript types - Full type inference from interfaces and types
- Strict validation -
--strict-missingflag for dependency checking - Drift detection - Compare context versions to detect changes (works against disk snapshots; git baseline comparison not yet implemented)
- JSON stats output - Machine-readable metrics for CI pipelines
- Exit codes - CI-friendly success/failure indicators
⚠️ Note: Git baseline comparison (git:main,git:HEAD~1) is not yet implemented. Current CI/CD workflows require committing context files (not recommended) or manual baseline generation. See the roadmap for planned features.
Share context bundles with AI assistants to get:
- Architecture suggestions based on complete dependency graph
- Refactoring recommendations understanding component relationships
- Bug fixes with full context of component behavior
- Code generation that respects existing patterns
- API contracts - Automatic prop/event documentation
- Dependency trees - Visualize component relationships
- Component catalog - Searchable index of all components
- Architecture diagrams - Data for generating visual graphs
- Impact analysis - See what components depend on changed code
- Circular dependency detection - Identify problematic import patterns
- Unused component detection - Find components not used by others
- Complexity metrics - Track component dependency counts
- Contract verification - Ensure components match expected contracts (works against disk snapshots)
- Dependency validation - Catch missing or broken imports
- Change detection - Monitor component contract drift (works against disk snapshots; git baseline comparison not yet implemented)
- Token budgeting - Track context size for AI workflows
- Uses
ts-morphfor robust TypeScript AST parsing - No pre-compilation required - works directly with source files
- Handles JSX, TypeScript, and modern React patterns
- Resolves relative imports (
./Component,../utils) - Tracks component usage across directories
- Handles circular dependencies gracefully
- Reports missing dependencies with reasons
- Generates per-folder
context.jsonfiles - Maintains project directory structure
- Creates
context_main.jsonindex for navigation - Supports incremental updates per folder
- Fast analysis - typically completes in seconds
- Configurable depth limits prevent excessive traversal
- Max nodes per bundle prevents oversized outputs
- Efficient hashing for change detection
stamp context [path] [options]--depth <n>- Dependency traversal depth (default: 1)--include-code <mode>- Code inclusion:none|header|full(default:header)--include-style- Include style metadata (Tailwind, SCSS, animations, etc.) - equivalent tostamp context style--profile <profile>- Preset:llm-safe|llm-chat|ci-strict--predict-behavior- Enable behavioral predictions--strict-missing- Fail on missing dependencies (CI-friendly)--compare-modes- Show token cost comparison--stats- Output JSON stats for CI
stamp context style- Generate context with style metadata (equivalent tostamp context --include-style)stamp context compare- Multi-file drift detectionstamp context validate- Schema validationstamp context clean- Remove generated filesstamp init- Project initialization
LogicStamp Context is a comprehensive codebase analysis tool that generates AI-ready documentation by:
- Extracting complete component contracts - Name, path, type, props, state, exports
- Building dependency graphs - Internal components, external packages, used-by relationships
- Analyzing behavior patterns - Hooks, side effects, role tags, predictions
- Preserving documentation - JSDoc, comments, natural language summaries
- Organizing output - Folder-based structure with main index and statistics
The tool produces structured, machine-readable context that enables AI assistants to understand your codebase architecture, component relationships, and behavioral patterns without requiring access to the full source code. This makes it ideal for AI-assisted development, automated documentation, code review, and CI/CD validation workflows.