CLI commands
The context-mode command line — doctor, upgrade, insight, index, search, and the hook dispatcher.
Installing the package puts a single callable binary on your PATH:
context-mode. This page covers every terminal subcommand, plus the slash
commands and chat triggers that surface the rest inside your agent.
| Subcommand | Purpose |
|---|---|
doctor | Diagnose runtimes, the FTS5 knowledge base, and host hooks |
upgrade | Pull, build, and reconfigure hooks in one step |
insight | Open the Insight analytics dashboard |
index | Index a file or directory into the knowledge base |
search | Search the knowledge base for focused snippets |
hook | Route data-heavy host output into the sandbox |
statusline | Render the Claude Code status line |
There is no ctx binary on your PATH. ctx ... (for example ctx stats or
ctx doctor) is a chat trigger you type to your agent, which calls the matching
MCP tool. In a terminal, always use context-mode .... Note that stats and
purge have no terminal subcommand — reach them through the chat trigger or the
/context-mode:ctx-stats and /context-mode:ctx-purge slash commands.
Diagnostics and maintenance
context-mode doctor
Diagnose your installation. The doctor checks three things for every connected host, then prints a checklist of what passed and what needs attention:
- Language runtimes
- The FTS5 knowledge base
- Hook registration
context-mode doctorRun this first whenever an agent stops routing output or the knowledge base looks empty. The same check is available as the ctx_doctor tool.
context-mode upgrade
Pull the latest context-mode, build it, and reconfigure host hooks in one step. Run it after a new release to keep three things in sync:
- The server
- The dispatcher
- Your hook configs
context-mode upgradeThe equivalent tool is ctx_upgrade.
Session status
context-mode insight
Open the Insight dashboard in your browser. Insight is the hosted analytics
layer at https://context-mode.com/insight; the command prints the URL and
opens it in your default browser. It takes no arguments.
context-mode insightSee ctx_insight for the underlying tool.
context-mode statusline
Print the Claude Code status line. You rarely run it by hand — Claude Code calls it internally to render the context-mode segment of its status bar.
- Reads a status-line event on stdin
- Writes the formatted line to stdout
context-mode statuslinestats and purge — chat and slash commands
stats and purge have no terminal subcommand. Reach them three ways:
- Type
ctx statsorctx purgeto your agent - Use the
/context-mode:ctx-statsand/context-mode:ctx-purgeslash commands - In Claude Code and Cursor, both forms are available
ctx stats shows how much context window you saved this session, with a
per-tool breakdown of tokens consumed versus tokens avoided.
- Read-only — it reports and never resets
- context-mode routinely keeps about 98% of a payload's bytes out of context, and this is where you see that number for your own session
- Matching tool: ctx_stats
ctx purge irreversibly wipes the knowledge base and resets session stats:
everything you have indexed is deleted and your savings counters return to zero.
Purge cannot be undone. It deletes all indexed content and resets stats. Run it only when you want a clean slate. The tool form is ctx_purge.
Knowledge base from the terminal
You do not need an agent in the loop to populate or query the knowledge base. The
index and search commands operate on it directly.
context-mode index
Index a file or directory into the FTS5 knowledge base. Tag the content with a
descriptive --source label so you can scope later searches to it.
context-mode index ./src --source codebaseThe matching tool is ctx_index.
context-mode search
Search the knowledge base with BM25 ranking and get back focused snippets instead
of whole files. Narrow the results with --source when you know which label
holds the answer.
context-mode search "retry backoff" --source codebaseThe matching tool is ctx_search.
The hook dispatcher
Hosts call context-mode hook <platform> <event> internally to route data-heavy
output into the sandbox. You rarely run it by hand, but it is useful for testing:
pipe a JSON event into it and inspect what comes back.
echo '{"tool":"Bash","command":"cat large.log"}' | context-mode hook claude-code pretooluse| Stream | Contract |
|---|---|
| stdin | A JSON event |
| stdout | A JSON decision |
This is the same contract every supported host uses.
Slash commands
In Claude Code and Cursor, every status command is also available as a slash command. They do exactly what their CLI or chat-trigger counterparts do, without leaving the chat.
| Slash command | Equivalent |
|---|---|
/context-mode:ctx-stats | ctx stats (chat trigger) |
/context-mode:ctx-doctor | context-mode doctor |
/context-mode:ctx-upgrade | context-mode upgrade |
/context-mode:ctx-purge | ctx purge (chat trigger) |
/context-mode:ctx-index | context-mode index |
/context-mode:ctx-search | context-mode search |
/context-mode:ctx-insight | context-mode insight |
Slash commands exist only on plugin hosts that register them — Claude Code and
Cursor. On other hosts (Codex, Gemini, MCP-only clients) use the context-mode
CLI binary in a terminal, or type the ctx ... chat trigger to your agent.