Doctor
Check and repair your setup with doctor
When the hooks seem quiet, run one command: context-mode doctor. It checks every agent on your machine, step by step, from D1 to D11. Each check shows PASS when it is ready, or prints the command that fixes it. context-mode setup then repairs what doctor finds.
Free · Local · Private · Forever
Context Mode Engine is source-available under the Elastic License 2.0. Free to use, for all time. It runs on your machine and keeps your data in ~/.context-mode.
Key facts
- What it is
- A step-by-step check of your Context Mode Engine install, D1 to D11, plus
context-mode setupto repair it. - Who it is for
- Anyone whose hooks seem quiet, and anyone who wants proof that the install works.
- Agents
- Claude Code, Codex, Gemini CLI, Qwen Code, Pi, OMP, OpenCode, Copilot CLI, Kiro, VS Code and ZCode.
- Measured result
- On 2026-10-23 the plugin team ran setup, a second setup, doctor and remove on Claude Code, Codex, Copilot CLI, Gemini CLI, OpenCode, Pi and Qwen Code, each in a clean temporary home folder on macOS (verified steps).
- Scope
- Doctor reads your setup and heals only a damaged
context.db. Setup writes only the files in its plan and backs each one up first.
The hooks seem quiet
You run your tests and the whole log lands in the chat. Or the agent reads a big page in full. You expected a short reply from the sandbox. Now you want to know which part to look at: Node, the config, the hooks or the database.
Doctor answers that in one run. It checks each part in a fixed order and names the fix for each one.
Step 1: run doctor
Inside your agent, run /ctx-doctor. Your agent can also call the ctx_doctor tool. In Pi, or in any terminal, run:
context-mode doctorThe terminal command comes with the npm package. If you installed with your agent's own command (see Install Context Mode Engine in your agent), get the terminal command once with npm:
npm i -g context-modeTo check one agent, add --agents <id>, for example context-mode doctor --agents codex.
Step 2: read the checks, D1 to D11
Doctor runs D1 to D11 in order for each agent (D5b runs right after D5). Each check shows PASS, or names what to fix and the command for it. The checks fall into four groups:
- Version, Node and shell (D1, D2, D11).
- D1: your build is older than the newest release. Fix:
run ctx_upgrade. D1 usesgit ls-remotewith a 10 s time cap; offline it reportsUNKNOWNand the other checks go on. - D2: Node is older than 24.15.0, or
node:sqlitefails to load. Fix:install Node 24.15.0 or later. - D11: the shell needs a fix (
shon macOS and Linux, Git Bash on Windows). Fix:install Git for Windows.
- D1: your build is older than the newest release. Fix:
- Your agent's config (D3, D4, D5b, D10).
- D3: the MCP entry, a hook entry or the hook timeout needs a fix. Fix:
run ctx_upgrade. - D4: older context-mode entries stay in the config. Fix:
run ctx_upgrade. - D5b: Claude Code hooks and VS Code
chat.useClaudeHooksboth fire for one repo. Fix: turn off one of the two. - D10: the hooks run in a mode that needs a change. Fix: the command named in the row.
- D3: the MCP entry, a hook entry or the hook timeout needs a fix. Fix:
- Hooks, MCP and project folder (D5, D6, D7).
- D5: a real hook call returns a reply in the wrong shape, or too slowly. Fix:
run ctx_upgrade. - D6: the MCP handshake between your agent and the server fails. Fix: the command named in the row.
- D7: the Engine sees a different project folder from the one your agent runs in. Fix:
restart the agent in the correct directory.
- D5: a real hook call returns a reply in the wrong shape, or too slowly. Fix:
- Your local data (D8, D9).
- D8: the schema or the integrity of
context.dbneeds a fix. Fix:run ctx_upgrade, or doctor heals the file on the next run and keeps the old data ascontext.db.<ts>.bak. - D9: the index sources and chunks need a fix. Fix: the command named in the row.
- D8: the schema or the integrity of
Source: the check order and texts in constants.ts. Codex asks you to trust its hooks; context-mode setup --agents codex marks them trusted.
Here is a sample report where every check is ready. Run it to see the rows tick in order, the way the real command prints them:
context-mode doctor- PASS D1 version: the newest release
- PASS D2 node: 24.15.0 or later
- PASS D3 host config: MCP entry and hooks set
- PASS D4 old entries: clean
- PASS D5 hook round trip: reply in your agent's shape
- PASS D5b double-fire: one hook set active
- PASS D6 MCP: handshake ready
- PASS D7 project and worktree: same folder as your agent
- PASS D8 context.db: schema and integrity good
- PASS D9 index: sources and chunks counted
- PASS D10 enforcement mode: mode shown
- PASS D11 shell: sh found
Each other row names the command that fixes it. Run that command, then run doctor again. In a terminal, doctor asks one question for an agent that needs a fix: fix now.
Step 3: repair with setup
context-mode setup is the repair path for every agent. It works in five steps:
- It finds each agent: its command on your
PATHor its config folder. - It shows the plan: the exact command or file change for each agent.
- It asks once, then applies the plan.
- It checks each agent: the config entry, old entries, an MCP handshake and one hook call.
- It rolls back an agent whose check needs a fix, and prints a
gh issue createcommand with a report file.
Setup backs up every file it touches under ~/.context-mode/backups. It leaves CLAUDE.md, AGENTS.md and your other instruction files as they are. Run it again at any time: a second run keeps every file as it is.
context-mode setupSetup options
Prints every agent it supports and whether it finds each one. Read-only.
context-mode setup --listShows the plan and stops there.
context-mode setup --dry-runSets up only the agents you name.
context-mode setup --agents codexPrints the manual step for one agent, with your paths filled in. Read-only.
context-mode setup --print codexSkips the question; sets up only these agents. Use --yes in scripts and automated jobs.
context-mode setup --yes --agents codex,claude-codePrints JSON only on stdout, for scripts.
context-mode setup --jsonRepairs each agent's entries. context-mode upgrade runs it after the npm install.
context-mode setup --repairPuts each touched file back and reports what it restored.
context-mode setup --removeExit codes
0: every check and step passed.1: a check or a step needs a fix.2: a usage error, or setup needs an answer while it runs in a script or an automated job. Add--yes.130: you pressed Ctrl-C.
Step 4: ask for help with the report
When a row still asks for a fix after you run its command, bring the report. Doctor removes secrets from it before it prints. A row that needs a fix also prints a gh issue create command, and the report file is under ~/.context-mode/reports/.
What you get
You see each part of your setup in one list, with PASS or the exact command to run. Setup repairs the rest, backs up what it touches and lets you roll it back. Doctor runs on your machine; its one network call is the D1 version check.
Next, rerun the Engine benchmark on your machine.
Prompts to give your agent
Run `context-mode doctor` and tell me which checks show PASS. For each other check, run the command it prints.
Install Context Mode Engine for this agent. Use the agent's own install command from https://github.com/mksglu/context-mode/blob/16a4bcc5170528db5bcf9924ceaac05e28db8588/docs/install/README.md, then run `context-mode doctor` and show me the result.