Skip to content

Commit a483d26

Browse files
committed
docs: expand CLAUDE.md with mandatory context-mode routing rules
Added detailed guidelines for using context-mode MCP tools, including prohibited commands and their alternatives, as well as a tool selection hierarchy. This update aims to enhance user understanding of command restrictions and proper tool usage to prevent context flooding. Signed-off-by: T
1 parent f4aaf35 commit a483d26

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

‎CLAUDE.md‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,66 @@ When adding content to a future version:
169169
3. Update ROADMAP.md candidate pool entries.
170170
4. Use `feat:` for new content, `fix:` for corrections.
171171
5. Push. The release pipeline handles VERSION, tags, CHANGELOG, the `**Version:**` line here, and the `**Current:**` line in ROADMAP.md.
172+
173+
# context-mode — MANDATORY routing rules
174+
175+
You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
176+
177+
## BLOCKED commands — do NOT attempt these
178+
179+
### curl / wget — BLOCKED
180+
Any Bash command containing `curl` or `wget` is intercepted and replaced with an error message. Do NOT retry.
181+
Instead use:
182+
- `ctx_fetch_and_index(url, source)` to fetch and index web pages
183+
- `ctx_execute(language: "javascript", code: "const r = await fetch(...)")` to run HTTP calls in sandbox
184+
185+
### Inline HTTP — BLOCKED
186+
Any Bash command containing `fetch('http`, `requests.get(`, `requests.post(`, `http.get(`, or `http.request(` is intercepted and replaced with an error message. Do NOT retry with Bash.
187+
Instead use:
188+
- `ctx_execute(language, code)` to run HTTP calls in sandbox — only stdout enters context
189+
190+
### WebFetch — BLOCKED
191+
WebFetch calls are denied entirely. The URL is extracted and you are told to use `ctx_fetch_and_index` instead.
192+
Instead use:
193+
- `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` to query the indexed content
194+
195+
## REDIRECTED tools — use sandbox equivalents
196+
197+
### Bash (>20 lines output)
198+
Bash is ONLY for: `git`, `mkdir`, `rm`, `mv`, `cd`, `ls`, `npm install`, `pip install`, and other short-output commands.
199+
For everything else, use:
200+
- `ctx_batch_execute(commands, queries)` — run multiple commands + search in ONE call
201+
- `ctx_execute(language: "shell", code: "...")` — run in sandbox, only stdout enters context
202+
203+
### Read (for analysis)
204+
If you are reading a file to **Edit** it → Read is correct (Edit needs content in context).
205+
If you are reading to **analyze, explore, or summarize** → use `ctx_execute_file(path, language, code)` instead. Only your printed summary enters context. The raw file content stays in the sandbox.
206+
207+
### Grep (large results)
208+
Grep results can flood context. Use `ctx_execute(language: "shell", code: "grep ...")` to run searches in sandbox. Only your printed summary enters context.
209+
210+
## Tool selection hierarchy
211+
212+
1. **GATHER**: `ctx_batch_execute(commands, queries)` — Primary tool. Runs all commands, auto-indexes output, returns search results. ONE call replaces 30+ individual calls.
213+
2. **FOLLOW-UP**: `ctx_search(queries: ["q1", "q2", ...])` — Query indexed content. Pass ALL questions as array in ONE call.
214+
3. **PROCESSING**: `ctx_execute(language, code)` | `ctx_execute_file(path, language, code)` — Sandbox execution. Only stdout enters context.
215+
4. **WEB**: `ctx_fetch_and_index(url, source)` then `ctx_search(queries)` — Fetch, chunk, index, query. Raw HTML never enters context.
216+
5. **INDEX**: `ctx_index(content, source)` — Store content in FTS5 knowledge base for later search.
217+
218+
## Subagent routing
219+
220+
When spawning subagents (Agent/Task tool), the routing block is automatically injected into their prompt. Bash-type subagents are upgraded to general-purpose so they have access to MCP tools. You do NOT need to manually instruct subagents about context-mode.
221+
222+
## Output constraints
223+
224+
- Keep responses under 500 words.
225+
- Write artifacts (code, configs, PRDs) to FILES — never return them as inline text. Return only: file path + 1-line description.
226+
- When indexing content, use descriptive source labels so others can `ctx_search(source: "label")` later.
227+
228+
## ctx commands
229+
230+
| Command | Action |
231+
|---------|--------|
232+
| `ctx stats` | Call the `ctx_stats` MCP tool and display the full output verbatim |
233+
| `ctx doctor` | Call the `ctx_doctor` MCP tool, run the returned shell command, display as checklist |
234+
| `ctx upgrade` | Call the `ctx_upgrade` MCP tool, run the returned shell command, display as checklist |

0 commit comments

Comments
 (0)