Verified context optimization.
32 MCP tools. 25+ CLI commands. 10 layers of verified context optimization — from tree-sitter code intelligence to session handoffs. Warden doesn't just compress context. It verifies the compression is safe, tracks whether outcomes held, and gives you a full audit trail of every decision.
Code intelligence
Tree-sitter indexing across 30+ languages. Structural queries that replace dozens of grep/read cycles with one call.
Project indexing
Indexes every function, class, import, and call site using tree-sitter WASM parsers. Incremental — only changed files are re-parsed. One index, six query types.
Call graph queries
Find every caller or callee of any function. See the full call chain — who calls it, what it calls, where each is defined. One structural query replaces reading 10 files.
Impact analysis
Change a file, see the blast radius. Direct dependents, transitive dependents (2 hops), affected callers, and risk assessment (low/medium/high) — all in one call.
Architecture overview
Project structure in one call: languages, packages, entry points, hotspots, total counts. Understand a codebase without reading 20 files first.
Symbol search
Search for functions, classes, and types by name pattern across the indexed project. Faster and more structured than grep — returns signatures, not just matches.
Dead code detection
Find functions with zero callers — potential dead code. Exports are excluded (they're API surface). Clean up safely with structural evidence.
Context selection
Before the agent starts work, Warden scans the project and extracts only the relevant code — not file lists, the actual content.
Task-aware file recommendation
Given a task description, Warden ranks every file in the project by relevance using name matching, path proximity, recency, test association, and directory proximity. The agent loads only what matters.
Relevant slice extraction
Doesn't just recommend files — reads them and extracts the relevant sections. Code blocks matching the task, markdown sections, JSON key windows. The agent gets verbatim content, not a reading list.
2-hop symbol expansion
newWhen the code index is available, Warden automatically includes the function and class signatures of each recommended file's direct dependencies. The agent sees login.ts plus the signatures of jwt.ts, config.ts, and db.ts — without reading them.
Tool output pruning
Every tool call goes through Warden's wrappers. Content-aware routing detects the output type and applies the optimal pruner. 50-90% reduction, every call.
Grep with deduplication
Searches via ripgrep, respects .gitignore, and prunes results to matches relevant to the current task. Duplicate matches across files are deduplicated. 200 matches become 12.
File read with slice + outline
Large files get a relevant slice (the function or block matching the task) plus a structural outline of the rest. Code is never rewritten — only included or excluded. The agent sees the relevant code and knows what else is in the file.
AST-aware read modes
newFive read modes beyond auto-pruning: signatures (symbol declarations only, 80-90% savings), symbol (one function by name), outline (structural headers), imports (import lines only), full (no pruning). Powered by tree-sitter. Every line verbatim — guard verified.
Test output pruning
Runs tests and keeps failures with context, collapses passing noise. Stack traces stay verbatim. 5000 lines of test output become the 3 failures and their context.
Command output pruning
Runs any shell command and strips low-signal lines, keeping errors, warnings, and relevant content. ANSI codes stripped, paths shortened, JSON cleaned up.
Manual pruning
For tools Warden doesn't wrap. Pass any output and Warden auto-detects the content type (JSON, grep, test log, source code) and routes to the optimal pruner.
MCP proxy mode + guard-verified response pruning
newWrap any upstream MCP server and compress its tool descriptions. Warden spawns the upstream, intercepts tools/list responses, and compresses description fields. Uniquely, --prune-responses also prunes tools/call response content behind the trust guard: removal-only, every retained line byte-for-byte verbatim from the raw. Description-only compressors deliberately never touch responses because rewriting is unsafe — Warden's guard makes it safe. Opt-in. Works with any MCP client.
Lazy-loading meta-tools + inputSchema compression
new--lazy replaces the full tool catalog with 3 meta-tools (warden_list_tools, warden_get_tool_schema, warden_invoke_tool). The client sees a tiny surface and loads schemas on demand. Measured 97.9% catalog token reduction on a 50-tool server (14105 → 297 tokens). Enabled by default. --compress-schema strips cosmetic JSON-Schema fields (title, default, examples) and compresses property descriptions — 21.5% additional reduction. Never touches validation constraints. Also enabled by default.
Reversible pruning
Every cut is reversible. The original output is cached in SQLite with a hash key. The agent can retrieve the full original — or a slice of it — at any time.
Full retrieval
Every pruned output includes a retrieval marker with a 12-char hash. The agent calls warden_retrieve with the hash and gets the complete original back. No guesswork, no re-running tools.
Slice-based retrieval
newInstead of retrieving the entire original, the agent can request a slice — lines around a symbol name, or an explicit line range. Get the 10 lines you need, not the 903 lines you don't.
Automatic TTL + cleanup
CCR entries auto-expire after 7 days (configurable). The cleanup command force-expires old entries. Disk usage is bounded — no unbounded growth.
Durable memory
Decisions persist across sessions in local SQLite with hybrid search: FTS5 keyword + semantic vector (all-MiniLM-L6-v2, local ONNX). 'login' finds 'authentication' with zero keyword overlap. The agent recalls relevant past decisions before starting work — no re-deriving context every time.
Decision persistence
When the agent makes a durable decision — architecture choice, library selection, convention, constraint — it persists to local SQLite. Categories: decision, finding, pattern, constraint, preference. Tagged for recall.
Hybrid search (FTS5 + semantic)
Recall uses two strategies merged via Reciprocal Rank Fusion (RRF): FTS5 keyword search (porter-stemmed) for exact term matching, and vector semantic search (all-MiniLM-L6-v2, 384-dim, local ONNX) for intent matching. 'login' finds 'authentication' — 'credit card' finds 'Stripe' — even with zero keyword overlap. Falls back to FTS5-only if the model is unavailable.
Conflict detection
When saving a new decision, Warden checks for conflicts with existing memories. 'Use PayPal' after 'Use Stripe' triggers a warning — the agent resolves the contradiction before it causes problems.
Auto-surface at session start
warden_status automatically surfaces recent memories at session start. The agent sees what Warden remembers without an explicit recall call.
Decision lifecycle — reaffirm, supersede, archive
newDecisions aren't static. Reaffirm boosts confidence when a decision is confirmed again. Supersede links an old decision to its replacement. Archive marks decisions as no longer relevant. Mark contested flags disagreement. Reject kills bad ideas. Full lifecycle, tracked in schema.
Failed approach tracking
newWhen something doesn't work, Warden remembers. Save a failed_approach memory with outcome='failure' and evidence. Later, when starting a similar task, warden_memory_failed_approaches surfaces warnings — don't repeat past mistakes.
Structured provenance
newEvery memory carries sourceType (documentation, commit, experiment, observation), evidence (array of citations), scope (e.g. 'order-service'), and outcome. Decisions are traceable — not just 'someone decided X' but 'decided X because of Y, confirmed by Z'.
Git context
File history, blame, and churn metrics — know if code is stable or volatile before you touch it. Integrates with git directly, no external services.
File history
newRecent commits that touched a file, with author, date, and message. See who changed what and why — without leaving the agent. Up to 10 recent commits, sorted newest first.
Change frequency & churn
newTotal commits, lines added, lines deleted, churn score (lines per commit). High churn = volatile file = expect recent changes, tread carefully. Low churn = stable = safe to build on.
Line-level blame
newOptional blame output for a line range. See which commit last touched each line, who wrote it, and when. Useful for understanding why code looks the way it does before changing it.
Sufficient context
One call. Everything the agent needs — file recommendations, past decisions, failed approach warnings, git volatility, and token budget trimming. The integration layer that combines all Warden layers into a single response.
Unified context package
newwarden_sufficient_context wraps context selection with memory recall, failed approach warnings, git churn metrics, and file categorization (direct, dependency, test, config, doc). One call replaces four. The agent gets the full picture before starting work.
Token budget trimming
newSet a token budget and Warden trims the package to fit — keeping the highest-relevance files first. Reports tokensUsed, tokensBudget, and whether trimming occurred. No more oversized context windows.
Volatility notes
newFiles with more than 5 commits are flagged as volatile. The agent sees a warning: 'auth.ts: 8 commits — volatile, expect recent changes'. Know which files are actively churned before you start editing.
Outcome tracking
Not just 'did we keep the right lines' — but 'did the agent still complete the task correctly after pruning.' Real evidence, not assumptions.
Task outcome recording
After completing a task, the agent reports success or failure. Warden correlates this with whether pruning was active. Over time, this builds a real dataset of pruning impact on agent performance.
Regression detection
Warden compares success rates: pruned vs. raw. If pruned success rate drops below raw by more than 5%, that's a regression signal. The agent is told to consider reverting. This is the evidence that compression didn't degrade outcomes.
Budget caps
Set per-seat or per-project token budgets. Warden tracks spend against the cap in real time. Prevents runaway costs on long sessions or expensive models.
Task reports with overhead timing
newPer-task or project-wide reports: prune calls, tokens saved, guard pass rate, per-rule breakdown, task outcomes, and CCR stats. Includes Warden's own overhead (processing time + estimated overhead tokens) — net tokens saved = gross minus overhead. Warden measures itself.
Response & file compression
Warden compresses what goes INTO the agent (tool outputs, file context) and what comes OUT (agent responses, memory files). Two layers of token savings.
Response compression rules
Warden writes rules to the agent's config (CLAUDE.md, AGENTS.md, .cursorrules, .devin/rules) that drop filler, pleasantries, and self-narration automatically. Code, commands, and errors stay verbatim. Max compression, always on — no config, no levels.
File compression
Memory files (CLAUDE.md, AGENTS.md) load into context every session. Verbose ones waste tokens forever. warden compress strips filler deterministically — no LLM call, free, instant, offline. Original backed up. Up to 32% reduction.
Auto-clarity for safety
When the situation is high-risk — security warnings, irreversible actions, breaking changes — compression automatically switches to full, clear sentences. Safety beats token savings. Built into the rules, not optional.
Session continuity
Sessions end. Context windows fill up. Warden generates a compact handoff document so the next session starts with the essential state — not from scratch. Automatic: the rules file tells the agent when to read and when to generate.
Read at session start
newwarden_handoff with read=true returns the previous session's handoff document. The rules file tells the agent to call this first thing — before warden_status, before memory recall. The next session picks up where the last left off: decisions made, tasks completed, files touched.
Generate at session end
newwarden_handoff (without read) generates a new handoff document: decisions made, task outcomes, files touched, pruning decisions. Under 300 words. Stored locally. The rules file tells the agent to call this at session end, before context compaction, or after significant multi-step tasks.
Incremental windowing
Handoff tracks the last generation timestamp. Each handoff covers only the window since the previous one — no duplication, no stale data. Pass --hours to override the window.
Trust guard & eval gate
The real problem Warden solves: developers can't tell whether context optimization silently degraded their agent. Warden provides compression with evidence, not assumptions.
Trust guard (line-level verification)
Every pruned output is verified: every non-annotation line must appear verbatim in the raw output, or the raw ships instead. No silent rewrites, ever. If a pruning module has a bug, the guard catches it and falls back to raw.
Eval gate (shadow → canary → active)
Every pruning rule starts in shadow mode. Warden runs it in parallel with raw output, scores parity, and only promotes once confidence is proven. Built-in rules are active by default — savings from first install. Enterprise mode starts in shadow.
Regression watchdog
A continuous watchdog re-runs canary tasks. If a model update, caching bug, or over-aggressive prune rule causes a regression, Warden auto-reverts to the last known-good config. You don't notice — Warden already fixed it.
Doctor health check
warden doctor runs 10 checks: MCP registration, rules files, pruning engine, memory system, FTS5 index, code index, CCR cache, outcome tracking, budget tracker, and database integrity. Clear pass/fail report.
Dashboard & audit
See every token saved, every pruning decision, every rule's confidence. Full audit trail in SQLite, exportable to JSON or CSV.
Live terminal HUD
warden hud runs a live, refreshing terminal dashboard — rules, stages, confidence bars, tokens saved, recent decisions. Updates every 2 seconds. Ctrl+C to exit.
Web dashboard
warden dashboard runs a real-time web UI at localhost:7878 — rule status, confidence bars, token savings charts, recent decisions, memory browser. Full visibility into what Warden is doing.
Status snapshot
One-shot snapshot of rules, confidence, tokens saved, and recent memories. The agent calls this at session start so you see Warden is working.
Audit trail export
Every pruning decision is logged in SQLite with timestamp, rule ID, tokens saved, and detail. Export the full trail to JSON or CSV for analysis or compliance.
Real-file benchmarks
warden benchmark runs actual benchmarks on real files — pruning, compression, response rules. See exact token savings per module, per file type, per content type.