Deterministic AI Context for IDE AI agents.
Foldwork indexes your codebase once and gives AI agents fast, dependency-aware context through MCP.
Stop wasting tokens scanning thousands of files. Give your AI the exact code context it needs.
Works With
Why traditional AI workflows fail
Naive retrieval dumps entire files, overflowing context limits and causing hallucinations.
When working with large enterprise codebases, sequential file exploration fundamentally breaks the AI context window. Naive tools like grep or basic AST tree-sitters retrieve raw files blindly. When an agent traces a single bug, it often pulls in 50+ files containing thousands of irrelevant lines of boilerplate, imports, and disconnected logic.
This rapid context bloat guarantees two failure modes. First, the LLM exceeds its context limit and crashes the session. Second, even if the prompt fits, the sheer volume of noise dilutes the attention mechanism. This leads to severe hallucinations where the model invents dependencies or confidently suggests calling methods that do not actually exist in your architecture.
Without Foldwork
With Foldwork
Ask your repository.
- `UserEventConsumer` (src/events/user.go)
- `BillingConsumer` (src/events/billing.go)
- `NotificationConsumer` (src/events/notify.go)
2. Token validation via `ValidateJWT()` (src/auth/token.go)
3. User lookup hits `FindUserByID()` (src/db/users.go)
4. Rate limiting applied by `CheckRateLimit()` (src/redis/limit.go)
sequenceDiagram
participant API
participant Parser
participant SQLite
API->>Parser: ParseAST(file)
Parser->>SQLite: UpsertSymbol(sym)
```
`UserService` (src/services/user.go) -> `BillingService` (src/services/billing.go) -> `UserService`
Recommendation: Extract common interface into `src/interfaces/user.go` to break the cycle.
How it works
A transparent mental model. No black-box embeddings.
Incremental Parsing
Foldwork scans your repository instantly using a single-pass AST parser, identifying all interfaces, classes, and function signatures without blocking.
Graph Generation
It deterministically builds two structures: a Symbol Graph for precise definitions, and a Dependency Graph tracking outbound caller/callee relationships.
Local Catalog
The graphs are durably stored in a local SQLite FTS5 catalog. Indexing happens exactly once per file change, meaning zero overhead during AI prompts.
MCP Serving
Your AI agent securely communicates with Foldwork via the Model Context Protocol, fetching sub-graphs in milliseconds without the code ever leaving your machine.
Foldwork replaces black-box vector embeddings with a deterministic, graph-based ingestion pipeline. It uses an incremental AST parser to read your codebase, immediately mapping out two distinct structures: a Symbol Graph containing every interface, class, and function signature, and a Dependency Graph tracking outbound caller/callee relationships.
These graphs are durably stored in a local SQLite catalog. We chose SQLite because it offers robust ACID guarantees, requires zero external dependencies, and supports sub-millisecond querying via FTS5. This local-first catalog means indexing happens exactly once per file change, not on every AI prompt.
When an AI agent requests context, it communicates with the Foldwork Retriever via the Model Context Protocol (MCP). The transport layer securely bridges the gap to the LLM, enabling the agent to fetch precisely the right sub-graphs without the repository ever leaving your machine.
Why engineers trust Foldwork
Trust in developer tools is earned through predictability. Foldwork is built around canonical determinism: by alphabetically sorting directory trees, stripping non-semantic metadata, and applying consistent formatters before cataloging, we ensure that the same repository state always produces the exact same byte-for-byte retrieval output.
This strict determinism is not just an architectural purity goalβit has massive financial implications. Because Anthropic's KV prompt cache requires identical prefix matching, Foldwork's predictable outputs guarantee that subsequent Claude sessions hit the cache 100% of the time, reducing API costs by up to 90% while dramatically accelerating response times. Furthermore, the local-first, air-gapped architecture ensures that your proprietary intellectual property never leaves your machine for indexing.
Deterministic Outputs
Same repository state produces the same retrieval results.
Local-First Architecture
Your repository never leaves your machine.
Incremental Indexing
Only changed files are reprocessed.
Observable Behavior
Transparent retrieval and indexing.
Reproducible Results
Canonical outputs improve prompt cache efficiency and debugging.
Graceful Failure
Recover from real developer workflows instead of failing unexpectedly.
Core Features
Repository Intelligence
Understand repositories as connected graphs rather than disconnected files.
Foldwork maps cross-module boundaries by extracting semantic links between interfaces, implementations, and their callers. Instead of just grepping for a function name, the agent can traverse the call stack up or down, ensuring it understands the entire data flow before attempting a refactor.
Using the injector_diagram tool, Foldwork can autonomously generate crisp Mermaid sequence diagrams of your architecture. An algorithmic layout engine actively prunes language primitives (like String or boolean) and internal framework bounds to keep diagrams focused purely on business logic.
AI Context Engine
Deliver only the context an AI actually needs.
The engine automatically prunes massive files using our Compress-Cache-Retrieve (CCR) algorithm. By stripping out function bodies and leaving only the structural signatures and imports (Folded Maps), we can deliver the blueprint of a 10,000-line file in under 500 tokens, giving the LLM the "shape" of the code without the bloat.
Enterprise Scale
Remain responsive on repositories containing millions of lines of code.
Engineered for 5M+ LOC monorepos, Foldwork implements strict OOM-prevention circuit breakers and uses a stream-oriented JSON-RPC pipeline to handle massive payloads. Background indexing is throttled to respect developer workloads, idling at <45MB of RAM even on massive Java and Go enterprise architectures.
Developer Safety
Protect repositories from unsafe AI-generated edits.
AI agents make mistakes. Foldwork acts as a strict hypervisor that statically analyzes AI write operations. If an LLM hallucinates and tries to overwrite a file using our compressed "Fold Markers", the daemon hard-rejects the payload before it ever touches the disk, mathematically guaranteeing that the AI cannot accidentally delete your business logic.
Additionally, our Shannon entropy filters dynamically redact AWS and SSH keys from the AST before they leave your machine.
The Tools
A full command palette for your AI assistant.
Benchmarks
Real numbers. Reproducible locally.
A tool that takes 5 minutes to index your codebase is useless for a developer in the middle of a debugging session. Foldwork is engineered for instantaneous feedback. By utilizing a highly optimized, single-pass AST parser combined with the zero-overhead FTS5 indexing of SQLite, we achieve indexing speeds that feel entirely synchronous.
Memory footprint is equally critical. Heavy IDE plugins and language servers often consume gigabytes of RAM, starving the host machine. Foldwork's daemon idles at approximately 45MB, ensuring your local environment remains snappy even when working inside massive legacy monorepos.
However, FTS5 tokenizers are notoriously bad at searching for hardcoded punctuation or exact regex patterns. Foldwork solves this with the injector_regex_search tool, which acts as a hybrid engine that gracefully bridges into native git grep -nE/-nF, giving the AI agent flawless literal and regex matching capabilities when semantic search isn't enough.
* Measured locally using the Foldwork benchmarking suite. Results are reproducible by running the benchmark tool against the same repository and environment.
Enterprise Readiness
Foldwork is not a weekend prototype; it is an enterprise-grade daemon designed to survive the chaos of real-world development environments. When you switch Git branches containing thousands of file changes, Foldwork gracefully handles the churn through a robust event-debouncing mechanism that prevents redundant re-indexing operations.
When indexing massive 100,000+ file monorepos, hitting Linux inotify file-watcher limits (ENOSPC) is guaranteed. Foldwork doesn't just crash; it safely pauses, opens a direct /dev/tty interactive bridge to prompt the developer to scale their OS limits (via sysctl), and dynamically resumes indexing without requiring a restart.
We've also implemented strict OOM (Out Of Memory) protections that abort operations on pathological files (e.g., a 5MB minified JSON file) rather than crashing the daemon. Automatic schema versioning ensures that when you upgrade the Foldwork binary, the local SQLite catalog is seamlessly migrated without requiring manual cache purges.
Reliability
- Crash recovery on malformed files
- Graceful degradation for API limits
- Complete workspace isolation
Performance
- Event debouncing
- Sub-millisecond FTS5 retrieval
- Zero-OOM streaming architecture
Operations
- Automatic schema versioning
- Interactive ENOSPC remediation
- Local durable cache
Supported Languages
Use Cases
Zero Configuration
No cloud account.
No API keys.
No indexing server.
Install it. Point it at a repository. Start coding.
curl -fsSL foldwork.dev/install | sh