Loading...
Loading...
Use context-mode tools (ctx_execute, ctx_execute_file) instead of Bash/cat when processing large outputs. Triggers: "analyze logs", "summarize output", "process data", "parse JSON", "filter results", "extract errors", "check build output", "analyze dependencies", "process API response", "large file analysis", "page snapshot", "browser snapshot", "DOM structure", "inspect page", "accessibility tree", "Playwright snapshot", "run tests", "test output", "coverage report", "git log", "recent commits", "diff between branches", "list containers", "pod status", "disk usage", "fetch docs", "API reference", "index documentation", "call API", "check response", "query results", "find TODOs", "count lines", "codebase statistics", "security audit", "outdated packages", "dependency tree", "cloud resources", "CI/CD output". Also triggers on ANY MCP tool output that may exceed 20 lines. Subagent routing is handled automatically via PreToolUse hook.
npx skill4agent add mksglu/context-mode context-modemkdirmvcprmtouchchmodgit addgit commitgit pushgit checkoutgit branchgit mergecdpwdwhichkillpkillnpm installnpm publishpip installechoprintfctx_executectx_execute_fileAbout to run a command / read a file / call an API?
│
├── Command is on the Bash whitelist (file mutations, git writes, navigation, echo)?
│ └── Use Bash
│
├── Output MIGHT be large or you're UNSURE?
│ └── Use context-mode ctx_execute or ctx_execute_file
│
├── Fetching web documentation or HTML page?
│ └── Use ctx_fetch_and_index → ctx_search
│
├── Using Playwright (navigate, snapshot, console, network)?
│ └── ALWAYS use filename parameter to save to file, then:
│ browser_snapshot(filename) → ctx_index(path) or ctx_execute_file(path)
│ browser_console_messages(filename) → ctx_execute_file(path)
│ browser_network_requests(filename) → ctx_execute_file(path)
│ ⚠ browser_navigate returns a snapshot automatically — ignore it,
│ use browser_snapshot(filename) for any inspection.
│ ⚠ Playwright MCP uses a SINGLE browser instance — NOT parallel-safe.
│ For parallel browser ops, use agent-browser via execute instead.
│
├── Using agent-browser (parallel-safe browser automation)?
│ └── Run via execute (shell) — each call gets its own subprocess:
│ execute("agent-browser open example.com && agent-browser snapshot -i -c")
│ ✓ Supports sessions for isolated browser instances
│ ✓ Safe for parallel subagent execution
│ ✓ Lightweight accessibility tree with ref-based interaction
│
├── Processing output from another MCP tool (Context7, GitHub API, etc.)?
│ ├── Output already in context from a previous tool call?
│ │ └── Use it directly. Do NOT re-index with ctx_index(content: ...).
│ ├── Need to search the output multiple times?
│ │ └── Save to file via ctx_execute, then ctx_index(path) → ctx_search
│ └── One-shot extraction?
│ └── Save to file via ctx_execute, then ctx_execute_file(path)
│
└── Reading a file to analyze/summarize (not edit)?
└── Use ctx_execute_file (file loads into FILE_CONTENT, not context)| Situation | Tool | Example |
|---|---|---|
| Hit an API endpoint | | |
| Run CLI that returns data | | |
| Run tests | | |
| Git operations | | |
| Docker/K8s inspection | | |
| Read a log file | | Parse access.log, error.log, build output |
| Read a data file | | Analyze CSV, JSON, YAML, XML |
| Read source code to analyze | | Count functions, find patterns, extract metrics |
| Fetch web docs | | Index React/Next.js/Zod docs, then search |
| Playwright snapshot | | Save to file, index server-side, query |
| Playwright snapshot (one-shot) | | Save to file, extract in sandbox |
| Playwright console/network | | Save to file, analyze in sandbox |
| MCP output (already in context) | Use directly | Don't re-index — it's already loaded |
| MCP output (need multi-query) | | Save to file first, index server-side |
| Situation | Language | Why |
|---|---|---|
| HTTP/API calls, JSON | | Native fetch, JSON.parse, async/await |
| Data analysis, CSV, stats | | csv, statistics, collections, re |
| Shell commands with pipes | | grep, awk, jq, native tools |
| File pattern matching | | find, wc, sort, uniq |
sourcesource: "Node""Node.js v22 CHANGELOG"queriesctx_search(queries: ["transform pipe", "refine superRefine", "coerce codec"], source: "Zod")ctx_fetch_and_indexcatctx_executehttps://raw.githubusercontent.com/org/repo/main/CHANGELOG.mdsourceconsole.log(JSON.stringify(data))ctx_index(content: large_data)ctx_index(path: ...)contentfilenamebrowser_snapshotbrowser_console_messagesbrowser_network_requestsconst resp = await fetch('http://localhost:3000/api/orders');
const { orders } = await resp.json();
const bugs = [];
const negQty = orders.filter(o => o.quantity < 0);
if (negQty.length) bugs.push(`Negative qty: ${negQty.map(o => o.id).join(', ')}`);
const nullFields = orders.filter(o => !o.product || !o.customer);
if (nullFields.length) bugs.push(`Null fields: ${nullFields.map(o => o.id).join(', ')}`);
console.log(`${orders.length} orders, ${bugs.length} bugs found:`);
bugs.forEach(b => console.log(`- ${b}`));npm test 2>&1
echo "EXIT=$?"gh pr list --json number,title,state,reviewDecision --jq '.[] | "\(.number) [\(.state)] \(.title) — \(.reviewDecision // "no review")"'# FILE_CONTENT is pre-loaded by ctx_execute_file
import json
data = json.loads(FILE_CONTENT)
print(f"Records: {len(data)}")
# ... analyze and print findingsbrowser_snapshotfilenamectx_index(content: ...)browser_snapshotfilenamectx_indexpathctx_execute_fileStep 1: browser_snapshot(filename: "/tmp/playwright-snapshot.md")
→ saves to file, returns ~50B confirmation (NOT 135K tokens)
Step 2: ctx_index(path: "/tmp/playwright-snapshot.md", source: "Playwright snapshot")
→ reads file SERVER-SIDE, indexes into FTS5, returns ~80B confirmation
Step 3: ctx_search(queries: ["login form email password"], source: "Playwright")
→ returns only matching chunks (~300B)Step 1: browser_snapshot(filename: "/tmp/playwright-snapshot.md")
→ saves to file, returns ~50B confirmation
Step 2: ctx_execute_file(path: "/tmp/playwright-snapshot.md", language: "javascript", code: "
const links = [...FILE_CONTENT.matchAll(/- link \"([^\"]+)\"/g)].map(m => m[1]);
const buttons = [...FILE_CONTENT.matchAll(/- button \"([^\"]+)\"/g)].map(m => m[1]);
const inputs = [...FILE_CONTENT.matchAll(/- textbox|- checkbox|- radio/g)];
console.log('Links:', links.length, '| Buttons:', buttons.length, '| Inputs:', inputs.length);
console.log('Navigation:', links.slice(0, 10).join(', '));
")
→ processes in sandbox, returns ~200B summarybrowser_console_messages(level: "error", filename: "/tmp/console.md")
→ ctx_execute_file(path: "/tmp/console.md", ...) or ctx_index(path: "/tmp/console.md", ...)
browser_network_requests(includeStatic: false, filename: "/tmp/network.md")
→ ctx_execute_file(path: "/tmp/network.md", ...) or ctx_index(path: "/tmp/network.md", ...)filenamepath| Approach | Context cost | Correct? |
|---|---|---|
| 135K tokens | NO |
| 270K tokens (doubled!) | NO |
| ~430B | YES |
| ~250B | YES |
ALWAYS useparameter when callingfilename,browser_snapshot, orbrowser_console_messages. Then process viabrowser_network_requestsorctx_index(path: ...)— neverctx_execute_file(path: ...).ctx_index(content: ...)Data flow: Playwright → file → server-side read → context. Never: Playwright → context → ctx_index(content) → context again.
curl http://api/endpointctx_executecat large-file.jsonctx_execute_filegh pr listctx_execute--jq| head -20ctx_executenpm testctx_executebrowser_snapshot()filenamebrowser_snapshot(filename: "/tmp/snap.md")browser_console_messages()browser_network_requests()filenamefilenamectx_index(content: ...)ctx_index(path: ...)contentquery-docsctx_index(content: response)browser_navigatebrowser_snapshot(filename)