| name | context-mode |
| description | Route shell, file reads, HTTP, and data analysis through context-mode MCP tools (ctx_ prefix) to protect the context window. Activate when context-mode is connected or on "ctx" commands.
|
| metadata | {"notes":"<https://github.com/mksglu/context-mode/blob/main/configs/opencode/AGENTS.md>"} |
context-mode — MANDATORY routing rules
context-mode MCP tools available. Rules protect context window from flooding. One unrouted command dumps 56 KB into context.
Think in Code — MANDATORY
Analyze/count/filter/compare/search/parse/transform data:
write code via context-mode_ctx_execute(language, code), console.log() only the answer.
Do NOT read raw data into context. PROGRAM the analysis, not COMPUTE it.
Pure JavaScript — Node.js built-ins only (fs, path, child_process).
try/catch, handle null/undefined. One script replaces ten tool calls.
BLOCKED — do NOT attempt
curl / wget — BLOCKED
Shell curl/wget intercepted and blocked. Do NOT retry.
Use: context-mode_ctx_fetch_and_index(url, source) or
context-mode_ctx_execute(language: "javascript", code: "const r = await fetch(...)")
Inline HTTP — BLOCKED
fetch('http, requests.get(, requests.post(, http.get(, http.request( — intercepted. Do NOT retry.
Use: context-mode_ctx_execute(language, code) — only stdout enters context
Direct web fetching — BLOCKED
Use: context-mode_ctx_fetch_and_index(url, source) then context-mode_ctx_search(queries)
REDIRECTED — use sandbox
Shell (>20 lines output)
Shell ONLY for: git, mkdir, rm, mv, cd, ls, npm install, pip install.
Otherwise: context-mode_ctx_batch_execute(commands, queries) or context-mode_ctx_execute(language: "shell", code: "...")
File reading (for analysis)
Reading to edit → reading correct.
Reading to analyze/explore/summarize → context-mode_ctx_execute_file(path, language, code).
grep / search (large results)
Use context-mode_ctx_execute(language: "shell", code: "grep ...") in sandbox.
Tool selection
- GATHER:
context-mode_ctx_batch_execute(commands, queries) — runs all commands, auto-indexes, returns search.
ONE call replaces 30+. Each command: {label: "header", command: "..."}.
- FOLLOW-UP:
context-mode_ctx_search(queries: ["q1", "q2", ...]) — all questions as array, ONE call.
- PROCESSING:
context-mode_ctx_execute(language, code) | context-mode_ctx_execute_file(path, language, code)
— sandbox, only stdout enters context.
- WEB:
context-mode_ctx_fetch_and_index(url, source) then context-mode_ctx_search(queries)
— raw HTML never enters context.
- INDEX:
context-mode_ctx_index(content, source) — store in FTS5 for later search.
ctx commands
| Command | Action |
|---|
ctx stats | Call stats MCP tool, display full output verbatim |
ctx doctor | Call doctor MCP tool, run returned shell command, display as checklist |
ctx upgrade | Call upgrade MCP tool, run returned shell command, display as checklist |
ctx purge | Call purge MCP tool with confirm: true. Warns before wiping knowledge base. |
After /clear or /compact: knowledge base and session stats preserved. Use ctx purge to start fresh.