The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Smart Context MCP listing page.
MCP server that reduces AI agent token usage by up to 90% through intelligent context compression (measured on this project).
An MCP (Model Context Protocol) server that provides specialized tools for reading, searching, and managing code context efficiently. Instead of loading full files or returning massive search results, it compresses information while preserving what matters for the task.
Real metrics from production use:
Workflow-level savings:
Real adoption in non-trivial tasks:
smart_read (850+ uses), smart_search (280+ uses), smart_shell (220+ uses)See Workflow Metrics and Adoption Metrics for details.
1.21.0Minor release built around a semantic engine. MCP grows from 20 → 22 tools (smart_code + smart_output). SQLite schema bumps 8 → 9 (new outputs table; auto-migrates on first run). Zero new runtime dependencies — the TypeScript LanguageService comes from the typescript package you already have, and degrades to a fallback provider when it isn't there.
smart_code (new tool). Semantic code navigation for JS/TS via the TypeScript LanguageService, resolving by symbol name (plus optional filePath) instead of forcing you to know a line and column. Actions: definition, references, implementations, diagnostics, impact, rename. Returns compact locations (file + 1-based start/end), never full file bodies. includeTests=false drops test paths; maxResults caps the payload.
Impact analysis. smart_code(action='impact') splits direct hits (semantic: definitions, references, implementations) from transitive files (import graph, maxHops default 2) and related tests, plus coverage flags. risk.level is labelled basis: 'heuristic' and says so in its own note — it is a ranking aid, not semantic certainty.
Scope-aware rename, dry run by default. smart_code(action='rename') uses findRenameLocations and dryRun: true is the default: the first call returns the planned per-file diff hunks (before/after per line) and writes nothing. Error conflicts (invalid or reserved newName, same name, unresolved target, path escape, missing file, blast radius over maxFiles) always block the write. name-collision is a heuristic warning that only blocks with strict: true, because the check doesn't verify scope overlap. After a real write, diagnosticsAfter reports remaining TypeScript errors in the touched files. smart_edit remains the tool for non-semantic textual replacements.
smart_output (new tool). Persistent output/artifact store (shell, test, build, lint, diff) so a stack trace from twenty turns ago is recoverable without rerunning the command. Actions: save, search, excerpt, summary, list, stats, prune. Content is scrubbed for likely secrets before persistence and truncated head+tail above DEVCTX_OUTPUT_MAX_BYTES (256KB) so the failing tail always survives. Retention via DEVCTX_OUTPUT_RETENTION_DAYS (14) and DEVCTX_OUTPUT_MAX_PER_KIND (50). Identical output for the same kind+command is deduped into repeat_count. Automatic capture from smart_shell/smart_test is opt-in via DEVCTX_OUTPUT_STORE=true (then smart_shell returns an outputRef); explicit save/search always work. Degrades with degraded: true instead of throwing when SQLite is unavailable or locked.
Opt-in semantic expansion in smart_context. include: ['semantic'] expands context through real definitions, references and implementations rather than text similarity, and every item gains a whyIncluded explanation. Off by default until the precision@5 benchmark justifies otherwise.
Richer ADR/spec awareness and graph paths carried over from the same roadmap: ADR sections are indexed as kind='adr' / 'adr-section', and smart_context can return graph paths between two files or symbols.
Shared tokenBudget across tools. smart_read, smart_read_batch, smart_context, smart_turn (start + end) and smart_resume now accept tokenBudget: number | { id?, maxTokens, shared? }. When shared:true (or id set), the budget is reused across calls inside the same task — so a multi-step agent flow can stay under a hard token ceiling without per-call bookkeeping. Responses include taskBudget, remainingBudget, and budgetDetails (scope, actions, degraded mode) when the budget actually changed the output.
smart_search search modes. New mode: 'needle' | 'balanced' | 'semantic' (default balanced). needle = literal exact only (no regex / no term expansion) — kills noise on debug queries. balanced = exact + regex + term expansion. semantic = exact-first plus the local semantic block only when exact signal is weak. The previous semantic: true flag remains as a legacy alias for mode: 'semantic'. Default maxFiles tightened 15 → 5. New maxTokens caps the whole response and compacts intelligently (matches first, then diagnostics, then semantic block). Per-file ranking is now inspectable via matchedBy, boostSource, scoreBreakdown, whyRanked. Response also returns hasMore / totalFiles / nextSuggestedMaxFiles and actionable suggestions when the query is too broad or empty.
smart_read persistent cache + budget-aware full degradation. New SQLite read_cache table keyed by (filePath, mode, selector, content_hash). Second read of an unchanged file is virtually free. Mode full is now an explicit last resort: if a tokenBudget/maxTokens is set, it degrades to lighter modes first (outline → signatures → truncated) and reports the real mode used in fullMode + budgetDetails. New clearReadCachePersistent + GC integration in runStorageMaintenance.
smart_turn simple-task skip heuristic. When the prompt is short (≤ 40 chars after normalization), classified as a simple task, and no session/task is pinned, smart_turn(start) now returns skipSmartTurn: true with recommendedPath.mode='simple_task_skip' instead of paying the full orchestration cost. Saves continuity-resolution overhead on trivial prompts. minimal verbosity additionally compacts summary/refreshedContext to the fields agents actually consume.
global_memory noise hints. Per-project, scrubbed noise telemetry persisted to ~/.devctx/global.db (noise_hints table). New actions noise_stats and noise_reset (full or via query). Lets smart_search learn which queries the agent already discovered to be noisy in a given repo and adjust ranking, without ever leaking content.
KPI baseline infrastructure. New scripts evals/kpi-baseline.js + evals/kpi-utils.js aggregate harness.js and realworld-eval.js runs into a single JSON snapshot with top-5 precision, recall, reread task/call rate, and per-task-size buckets (short / long). Persists kpi-baseline-latest.json for regression detection across releases. New test suite tests/eval-kpis.test.js.
1.20.0 (still current)Same tool count as 1.19.0, but several tools gained hard token-budget control, search-mode discipline and second-read cache reuse.
tokenBudget across tools. smart_read, smart_read_batch, smart_context, smart_turn and smart_resume accept tokenBudget: number | { id?, maxTokens, shared? }, reusable across calls inside one task so a multi-step flow stays under a hard ceiling.smart_search modes. mode: 'needle' | 'balanced' | 'semantic' (default balanced), maxTokens capping the whole response, and inspectable ranking via matchedBy / scoreBreakdown / whyRanked.smart_read persistent cache. SQLite read_cache keyed by (filePath, mode, selector, content_hash); a second read of an unchanged file is virtually free. Mode full degrades to lighter modes under a budget and reports the real mode used.smart_turn simple-task skip on short trivial prompts, and global_memory noise hints that let smart_search learn which queries proved noisy per repo.evals/kpi-baseline.js) snapshotting precision@5, recall, reread rate and latency for regression detection.1.19.0Five-step quality jump executed as sequential commits with full dogfooding. MCP grew from 18 → 20 tools, +68 tests, zero new dependencies.
smart_playbook (new tool). Declarative composite workflows that run multiple smart_* tools in a single MCP call. Five built-in playbooks ship with the package: preflight-merge (review + affected tests + checkpoint), debug-flake (last failure + curated debug context + affected), refactor-safe (curated context + affected + checkpoint), doc-sync (ADR search + docs context), ramp-up (status + doctor + ADR overview). Project-level overrides via .devctx/playbooks/*.{yaml,json} with {{args.X}} interpolation, when / label / stopOnFail / dryRun. Tool allowlist restricted to smart_*. Zero deps: built-in minimal YAML parser.fs.watch (native, recursive, debounced 600ms + batch flush every 2s) keeps the symbol index hot between calls. Filters .git, node_modules, .devctx, dist, build, lockfiles, .min.*, .map, .snap, and non-indexable extensions. Stats surface in smart_status (enabled, flushes, eventsObserved, filesReindexed, filesRemoved, errors, lastFlushAt, pending). Opt-out via DEVCTX_WATCH_INDEX=false. Wired to MCP shutdown for clean close + final flush.decorators: ["dataclass", ...]), async def (kinds async-function / async-method), TypeAlias and TypeVar / NewType / ParamSpec / TypeVarTuple as kind="type", and respects class indent for accurate scope. Go now captures methods with receiver type as parent, interfaces as kind="interface", top-level const / var. src/parsers/registry.js exposes registerParser / getParser so future tree-sitter parsers can plug in without touching index.js. INDEX_VERSION bumped 6 → 7 (auto-reindex).smart_search. Opt-in semantic: true (with semanticLimit) returns a semantic: { embedder, symbols[], files[] } block ranked by hashing/TF-IDF embeddings (256-dim, FNV-1a buckets, L2-normalized, cosine similarity, <5ms). Default behavior unchanged. Pluggable embedder interface (id, dimensions, embed, similarity) ready to swap in ONNX/transformers without touching callers.global_memory (new tool, opt-in). Cross-project memory persisted to ~/.devctx/global.db (override via DEVCTX_GLOBAL_DB, gated by DEVCTX_GLOBAL_MEMORY=true). Stores canonical decisions, recurring patterns, playbook drafts, and notes across repos. Content scrubbed for likely API keys / bearer tokens / JWT / PEM private keys / AWS / OpenAI / GitHub / Slack / Google API / DB URLs / emails / home paths before persistence. Project paths stored as FNV-1a hash, not raw path. Recall uses the local hashing/TF-IDF embedder for semantic ranking.See CHANGELOG.md for the full v1.21.0 + v1.20.0 entries.
See CHANGELOG.md for full release history.
Use devctx when:
Skip devctx when:
Honest verdict from real users:
"The MCP shines in long, multi-session tasks or when you don't know the codebase. For contained refactors where you already know what to touch, native tools are just as fast or faster. The real value was
smart_read(outline)for the initial analysis and checkpoints to not lose the thread between sessions."
The 90% token savings are real, but they require the right task type to materialize.
AI agents waste tokens in three ways:
This MCP solves all three by providing tools that return compressed, ranked, and cached context.
📋 Official Prompt (Copy & Paste)⚡ Ultra-Short Version |
When to use: Agent read large files with Read, used Grep repeatedly, or you see no devctx tools in a complex task.
Why this happens: Task seemed simple, no index built, native tools appeared more direct, or rules weren't strong enough.
Use if: You work in Cursor IDE and want the best balance of guidance and flexibility.
Workflow:
Automaticity: Medium by default. Medium-High if you use the assisted launcher ./.devctx/bin/cursor-devctx for task-runner workflows.
Use if: You want highest session continuity with automatic context recovery.
Workflow:
Automaticity: High (with hooks) - Can auto-trigger smart_turn on session start/end.
Use if: You prefer terminal-based workflows or scripting.
Workflow:
Automaticity: Low-Medium - Rules are visible but require explicit prompting.
| Client | Automaticity | Best For |
|---|---|---|
| Cursor | Medium | Complex IDE tasks |
| Claude Desktop | High (hooks) | Session continuity |
| Codex CLI | Low-Medium | Terminal workflows |
| Qwen Code | Low-Medium | Alternative to Cursor |
Important: Agent always decides whether to use devctx. Rules increase probability, but don't guarantee it.
If you want a more repeatable path: use the task runner or the assisted launcher instead of relying on rules alone. See Task Runner Workflows.
📖 Full setup: Client Compatibility
Key point: The MCP doesn't intercept prompts automatically. You need to tell the agent to use it.
Other prompts:
/prompt devctx-workflow - Full workflow/prompt devctx-preflight - Build index + start sessionFor a more guided CLI path:
Agent should use devctx for complex tasks if rules are active:
.cursorrulesCLAUDE.mdAGENTS.mdBut: Agent decides based on task complexity.
| Scenario | Command |
|---|---|
| Start new task | /prompt devctx-workflow |
| Guided terminal workflow | smart-context-task task --prompt "..." |
| Guided implementation | smart-context-task implement --prompt "..." |
| Continue previous task | smart_turn(start) and continue |
| Continue via runner | smart-context-task continue --session-id <id> |
| Force MCP usage | /prompt use-devctx |
| First time in project | /prompt devctx-preflight |
| Trust automatic rules | Just describe your task normally |
Before starting complex tasks, ensure:
Copy-paste to agent (first time):
Without index:
smart_search returns unranked resultssmart_context can't build optimal contextWith index:
smart_search ranks by relevancesmart_context includes related filesWhen to rebuild:
.devctx/)smart_turn(start)For non-trivial tasks (debugging, review, refactor, testing, architecture), the optimal flow is:
Why start with smart_turn?
When to skip smart_turn:
smart-context-taskIf you want the same lifecycle packaged into named workflows, use the task runner:
This layer runs the same smart_turn(start) / context / checkpoint flow, but adds:
smart_context or smart_search)smart_doctortask_runner quality signalsFor the full command set and client-specific usage, see Task Runner Workflows.
This MCP does not intercept your prompts magically. Here's what actually happens:
smart_turn(start)"smart_turn({ phase: 'start', userPrompt: '...', ensureSession: true })smart_search(intent=debug) for error locationsmart_read(mode=symbol) for specific functionsmart_shell('npm test')smart_turn(end) to persist progressKey points:
smart_turn(start) is recommended entry point for non-trivial tasksTools (22): Efficient alternatives to built-in operations
smart_read / smart_read_batch - Compressed file reading (outline, signatures, symbol, explain)smart_search - Intent-aware code search with ranking, ADR filtering, and opt-in semantic re-ranksmart_context - One-call context builder with graph + paths: { from, to } traversalsmart_test - Affected tests via graph + sandboxed runner + persisted last_failuresmart_review - Code review preflight: diff + callers + heuristic findingssmart_code - Semantic navigation by symbol name: definition, references, implementations, diagnostics, impact, dry-run renamesmart_output - Persistent output store (shell/test/build/lint/diff): search, excerpt, summary without rerunningsmart_playbook - Declarative composite workflows (5 built-in: preflight-merge, debug-flake, refactor-safe, doc-sync, ramp-up)smart_shell - Safe diagnostic commands (TAP/git-log/diff compression)smart_turn / smart_resume - Session persistence + nextActions[] machine-readable plansmart_summary / smart_status / smart_doctor / smart_metrics / smart_editglobal_memory - Opt-in cross-project memory in ~/.devctx/global.db (scrubbed, semantic recall)build_index / warm_cache / git_blame / cross_projectRules (5 profiles): Task-specific workflows
Storage (.devctx/): Local context database
index.json - Symbol index (functions, classes, imports, ADRs, sections) — INDEX_VERSION 7state.sqlite - Sessions, metrics, patterns, task handoffs, test failures, explain/read caches, persisted outputs (Node 22+, node:sqlite, schema 9)metrics.jsonl - Opt-in legacy file, only when DEVCTX_METRICS_FILE=path.jsonl is set~/.devctx/global.db - Cross-project memory (opt-in via DEVCTX_GLOBAL_MEMORY=true)What gets persisted:
When it's consulted:
smart_turn(start) - Recovers task checkpointsmart_context - Uses patterns for predictionsmart_summary - Gets task summaryWhat is NOT persisted:
Limitations:
smart_turn (not automatic).devctx/ is local)Honest truth: Task context persistence is opt-in via agent behavior, not automatic via client interception.
Best case scenario:
Typical scenario:
Worst case scenario:
You can check: npm run report:metrics shows actual tool usage and measured smart_turn quality signals.
What we improve:
What we don't guarantee:
The benefit: Agents work with better input, but output quality still depends on agent capability and task complexity.
Honest claim: We provide better context (more relevant, less noise), which can help agents respond more efficiently in complex tasks when the workflow is followed.
What's proven: 90% token savings (measured across 3,666 operations).
What's inferred: Quality improvement (better input → potentially better output, but not explicitly measured).
What we don't control: Agent correctness, task success, response accuracy.
Token usage: 150K → 15K (90% savings)
Token usage: 200K → 25K (87% savings)
Token usage: 180K → 20K (89% savings)
Token usage: 120K → 12K (90% savings)
Token usage: 300K → 30K (90% savings)
These are the essential tools you should understand first:
Read files in compressed modes instead of loading full content.
Modes: outline, signatures, symbol, range, full
When to use: Any time you need to understand file structure without reading everything.
Intent-aware code search with ranked, deduplicated results and index boosting.
Intents: implementation, debug, tests, config, docs, explore
Best for: Finding symbol definitions/usages, understanding call chains, locating implementations.
NOT ideal for: Exact string matching (use Grep), finding files by name (use Glob), broad multi-word queries (generates noise — results include a hint when >30 files match).
One-call context builder: search + read + graph expansion.
Returns relevant files with compressed content, symbol details, and relationship graph.
Smart pattern detection: Automatically detects literal patterns in your task (TODO, FIXME, /**, console.log, debugger) and prioritizes them in search results.
When to use: Starting a new task and need comprehensive context.
Build a symbol index for the project (functions, classes, imports).
When to use: Once after checkout, or after major changes. Improves search ranking and context relevance.
Inspect token savings and usage statistics.
When to use: Verify the MCP is working and see actual savings.
These tools provide specialized capabilities for specific workflows:
Maintain compressed task state across sessions.
Compresses task context to ~100 tokens (goal, status, decisions, blockers). Critical for long tasks. Supports both flat and nested formats.
When git hygiene or SQLite health affects local state, responses also surface mutationSafety, repoSafety, degradedMode, and storageHealth.
Run one operational preflight across repo hygiene, SQLite health, compaction, and legacy cleanup.
Use this before release, after long-lived local usage, or whenever .devctx/state.sqlite looks suspicious.
Display current session context with progress visibility.
Shows goal, status, recent decisions, touched files, pinned context, and progress stats. Updates automatically with each MCP operation.
When repo safety or SQLite health affects state, smart_status stays useful via degraded mode and surfaces storageHealth plus the same mutationSafety contract as smart_turn.
Batch edit multiple files with pattern replacement.
Supports dryRun: true for preview. Useful for bulk refactoring, removing patterns, or renaming across files.
Orchestrate turn start/end with automatic task checkpoint recovery.
Recovers task state (goal, status, decisions, next step), not full conversation history.
Read multiple files in one call.
Reduces round-trip latency when you know you need several files.
Safe diagnostic command execution (allowlisted commands only).
Blocks shell operators and unsafe commands by design.
Analyze git changes intelligently (part of smart_context):
Returns changed files prioritized by impact + related files (tests, importers).
Learn from usage patterns and predict needed files (part of smart_context):
After 3+ similar tasks: 40-60% fewer round-trips, 15-20% additional savings.
Preload frequently accessed files into OS cache.
First query: 250ms → 50ms (5x faster cold start).
Function-level code attribution.
Share context across monorepos and microservices.
Requires .devctx-projects.json config file.
| Client | MCP | Rules | Hooks | smart_turn | Persistence | Near-Automatic | Key Limitations |
|---|---|---|---|---|---|---|---|
| Cursor | ✅ Full | ✅ Conditional ( .cursor/rules/*.mdc) | ❌ No | ✅ Manual call | ✅ SQLite (Node 22+) | 🟡 Medium Agent decides when | • No auto smart_turn• Agent must follow rules • Requires Agent mode |
| Claude Desktop | ✅ Full | ✅ Embedded ( CLAUDE.md) | ✅ SessionStart PostToolUse Stop | ✅ Can auto-trigger via hooks | ✅ SQLite (Node 22+) | 🟢 High Hooks auto-trigger | • Hooks are opt-in • No conditional rules • Fixed context: 200t |
| Codex CLI | ✅ Full | ✅ Embedded ( AGENTS.md) | ❌ No | ✅ Manual call | ✅ SQLite (Node 22+) | 🟡 Low-Medium Agent decides when | • No auto smart_turn• No conditional rules • No hooks |
| Qwen Code | ✅ Full | ✅ Embedded ( AGENTS.md) | ❌ No | ✅ Manual call | ✅ SQLite (Node 22+) | 🟡 Low-Medium Agent decides when | • No auto smart_turn• No conditional rules • No hooks |
Legend:
🟢 High (Claude Desktop with hooks):
smart_turn(start) when you start a session🟡 Medium (Cursor):
smart_turn (not auto-triggered)🟡 Low-Medium (Codex, Qwen):
smart_turn (not auto-triggered)❌ Not automatic prompt interception - MCP cannot intercept or modify your prompts before the agent sees them
❌ Not forced tool usage - Agent always has autonomy to decide which tools to use
❌ Not guaranteed workflow - Agent may skip devctx tools for simple tasks (this is fine)
❌ Not client-level magic - Behavior depends on agent following rules and making good decisions
All clients work the same way:
npm run report:metrics)The differences:
smart_turn(start) on session start)Choose Cursor if:
Choose Claude Desktop if:
smart_turn)Choose Codex or Qwen if:
AGENTS.md file)smart_turn calls and no conditional activationBottom line: All clients work well. The choice depends on your preference for automation level vs simplicity.
See Client Compatibility Guide for detailed comparison.
Restart your AI client. Done.
After updating: The binary is updated globally, but agent rules (.cursorrules, CLAUDE.md, AGENTS.md) in each project are generated from the installed version and are not updated automatically.
Re-run init after each update to get the latest rules:
Then restart your AI client to load the new version.
Restart Cursor. Tools appear in Agent mode.
Files created:
.cursor/mcp.json - MCP server config.cursor/rules/devctx.mdc - Base agent rules (10 lines, always active).cursor/rules/profiles-compact/*.mdc - Task profiles (conditional).devctx/bin/cursor-devctx - Optional assisted launcher for long tasks.git/hooks/pre-commit - Safety hook.gitignore - Adds .devctx/Restart Codex.
Files created:
.codex/config.toml - MCP server configAGENTS.md - Agent rules.git/hooks/pre-commit - Safety hook.gitignore - Adds .devctx/Restart Claude Desktop.
Files created:
.mcp.json - MCP server config.claude/settings.json - Hook configCLAUDE.md - Agent rules.git/hooks/pre-commit - Safety hook.gitignore - Adds .devctx/Restart Qwen Code.
Files created:
.qwen/settings.json - MCP server configAGENTS.md - Agent rules.git/hooks/pre-commit - Safety hook.gitignore - Adds .devctx/What makes this MCP different is task-specific agent guidance. Installation generates rules that teach agents optimal workflows:
Savings: 90% (150K → 15K tokens)
Savings: 87% (200K → 25K tokens)
Savings: 89% (180K → 20K tokens)
Savings: 90% (120K → 12K tokens)
Savings: 90% (300K → 30K tokens)
Key insight: The value isn't just in the tools—it's in teaching agents when and how to use them.
To ensure agents use devctx automatically, set up client-specific rules:
Already included: .cursorrules is committed in the project.
Verify it's working:
./.devctx/bin/cursor-devctx task --prompt "..." -- <agent-command>Create CLAUDE.md in your project root:
Or copy the content from docs/agent-rules-template.md.
Create AGENTS.md in your project root using the same template.
Why these rules matter:
See Agent Rules Template for complete setup.
If the agent doesn't use devctx tools in a non-trivial task, it will add a note:
Why this matters:
When to use these prompts:
Official prompt (complete workflow):
Ultra-short prompt (copy-paste ready):
Example usage:
See agent-rules/ for complete profiles.
Install:
Build index (REQUIRED for quality):
Why critical: Without index, smart_search and smart_context are degraded. Agent may prefer native tools. No token savings.
Use core tools:
smart_read for file structuresmart_search for finding codesmart_context for comprehensive contextsmart_metrics to verify savingsLet the agent decide: Don't force tool usage. The generated rules will guide the agent naturally.
smart_summary if you work on long taskssmart_turn if using Claude Code CLIgit_blame for code attributioncross_project if working in monorepossmart_metrics for usage patternswarm_cache if cold starts are slowprefetch in smart_context for repetitive tasksRuns all verification suites:
Takes 3-4 minutes. See Benchmark Documentation for details.
Release gating for orchestration quality is also available with npm run benchmark:orchestration:release, and npm publish now blocks on that gate via prepublishOnly.
Good signs:
Bad signs:
Example output:
The metrics report now includes adoption analysis to measure how often devctx is actually used.
What we measure:
What we DON'T measure:
Limitations:
Why this is useful:
See Adoption Metrics Design for complete analysis.
Get immediate visibility into devctx tool usage in every agent response.
ENABLED BY DEFAULT - Shows feedback after every devctx tool call.
Disable if too verbose:
What you'll see:
Benefits:
When to use:
See Usage Feedback Documentation for complete guide.
Understand why the agent chose devctx tools and what benefits are expected.
ENABLED BY DEFAULT - Shows decision explanations for every devctx tool call.
Disable if too verbose:
What you'll see:
Benefits:
When to use:
Combine with usage feedback for maximum visibility:
See Decision Explainer Documentation for complete guide.
Detect when devctx should have been used but wasn't.
ENABLED BY DEFAULT - Shows warnings when devctx adoption is low.
Disable if not needed:
What you'll see:
Detects:
Benefits:
Limitations:
All features enabled by default. To disable all:
See Missed Opportunities Documentation for complete guide.
The project includes agent rules that enforce devctx usage across different clients:
.cursorrules (committed to git)CLAUDE.md (create from template in docs/agent-rules-template.md)AGENTS.md (create from template in docs/agent-rules-template.md)All rules enforce the same policy:
smart_read instead of Readsmart_search instead of Grepsmart_context instead of multiple readsSee Agent Rules Template for setup instructions.
The MCP server provides prompts that automatically inject forcing instructions:
Quick forcing:
This injects: Use devctx: smart_turn(start) → smart_context/smart_search → smart_read → smart_turn(end)
Available prompts:
/prompt use-devctx - Ultra-short forcing prompt/prompt devctx-workflow - Complete workflow template/prompt devctx-preflight - Preflight checklist (index + session init)Benefits:
See MCP Prompts Documentation for complete guide.
Check:
Possible causes:
npx smart-context-init --target .npm run build-index or tell agent "Run build_index tool"Force devctx usage (copy-paste ready):
See How to Force devctx Usage for complete workflow.
To track complete workflows (debugging, review, refactor, testing, architecture):
Then restart your AI client. View workflow metrics:
See Workflow Metrics for details.
Check:
Look for:
full mode usage (agent not cascading)Possible causes:
Check:
Possible causes:
smart_turn → No task checkpoints.devctx/state.sqlite tracked/staged → runtime context writes are intentionally blocked until git hygiene is fixed.devctx/state.sqlite locked/corrupted/oversized → inspect storageHealth from smart_status or smart_metricssmart_doctor or smart-context-doctor --jsonRecovery flow:
missing → run a persisted action like smart_summary update or smart_turn endoversized → run smart_summary compactlocked → stop competing devctx processes, then retrycorrupted → back up .devctx/state.sqlite, remove it, and let devctx recreate local stateCheck:
If missing:
If exists but agent ignores:
First-class (AST parsing): JavaScript, TypeScript, JSX, TSX
Heuristic parsing: Python, Go, Rust, Java, C#, Kotlin, PHP, Swift
Structural extraction: Shell, Terraform, HCL, Dockerfile, SQL, JSON, YAML, TOML
Create .devctx-projects.json:
Build indexes for each project:
All data stored in .devctx/:
index.json - Symbol index (INDEX_VERSION 7: ADR + ADR sections, richer Python/Go)state.sqlite - Sessions, metrics, patterns, task handoffs, test failures, explain cache (Node 22+)metrics.jsonl - Opt-in legacy file, only when DEVCTX_METRICS_FILE=path.jsonl is setCross-project (opt-in via DEVCTX_GLOBAL_MEMORY=true):
~/.devctx/global.db - Scrubbed decisions, patterns, playbooks, notes with semantic recallAdd to .gitignore:
This MCP is secure by default:
ls, git status, npm test, etc.)|, &, ;, >, <, `, $()What smart_shell can run:
Real rejection examples:
Verification:
Configuration:
Complete security documentation:
@vscode/ripgrep (no system install needed)| Operation | Without MCP | With MCP | Savings |
|---|---|---|---|
| Read file | 4,000 tokens | 400 tokens | 90% |
| Search code | 10,000 tokens | 500 tokens | 95% |
| Session resume | 5,000 tokens | 100 tokens | 98% |
| Cold start | 250ms | 50ms | 5x faster |
smart_read
smart_search
smart_context
build_index
smart_metrics
smart_summary
smart_turn
smart_read_batch
smart_shell
warm_cache
git_blame
cross_project
See CHANGELOG.md for full release history.
This repository contains the smart-context-mcp npm package in tools/devctx/:
What gets published to npm: Only tools/devctx/ contents (src + scripts)
Development: All work happens in tools/devctx/
See CONTRIBUTING.md for development setup.
Pull requests welcome for:
See CONTRIBUTING.md for guidelines.
Francisco Caballero Portero
Email: fcp1978@hotmail.com
GitHub: @Arrayo
MIT License - see LICENSE file for details.