Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计提醒

context-mode上下文模式

Agent Skill

context-mode 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

5,990

周安装

240

GitHub Stars

11,301

下载量

1,939
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:context-mode(上下文模式)
来源仓库:https://github.com/mksglu/context-mode
仓库路径:skills/context-mode
安装命令:
npx skills add https://github.com/mksglu/context-mode --skill context-mode
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/mksglu/context-mode --skill context-mode

简介

context-mode 默认启用所有大输出命令,优化上下文窗口使用效率。

  • 仅允许直接运行小型 Bash 操作,其余命令需通过 ctx_execute 封装处理。
  • 提供白名单机制控制安全命令执行,减少意外副作用风险。
  • 安装前建议确认权限范围、维护状态,以及是否会触发命令执行或系统调用。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Context Mode: Default for All Large Output

MANDATORY RULE

<context_mode_logic> <mandatory_rule> Default to context-mode for ALL commands. Only use Bash for guaranteed-small-output operations. </mandatory_rule> </context_mode_logic>

Bash whitelist (safe to run directly):

  • File mutations: mkdir, mv, cp, rm, touch, chmod
  • Git writes: git add, git commit, git push, git checkout, git branch, git merge
  • Navigation: cd, pwd, which
  • Process control: kill, pkill
  • Package management: npm install, npm publish, pip install
  • Simple output: echo, printf

Everything else → ctx_execute or ctx_execute_file. Any command that reads, queries, fetches, lists, logs, tests, builds, diffs, inspects, or calls an external service. This includes ALL CLIs (gh, aws, kubectl, docker, terraform, wrangler, fly, heroku, gcloud, etc.) — there are thousands and we cannot list them all.

When uncertain, use context-mode. Every KB of unnecessary context reduces the quality and speed of the entire session.

Decision Tree

About 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)

When to Use Each Tool

SituationToolExample
Hit an API endpointctx_executefetch('http://localhost:3000/api/orders')
Run CLI that returns datactx_executegh pr list, aws s3 ls, kubectl get pods
Run testsctx_executenpm test, pytest, go test./...
Git operationsctx_executegit log --oneline -50, git diff HEAD~5
Docker/K8s inspectionctx_executedocker stats --no-stream, kubectl describe pod
Read a log filectx_execute_fileParse access.log, error.log, build output
Read a data filectx_execute_fileAnalyze CSV, JSON, YAML, XML
Read source code to analyzectx_execute_fileCount functions, find patterns, extract metrics
Fetch web docsctx_fetch_and_indexIndex React/Next.js/Zod docs, then search
Playwright snapshotbrowser_snapshot(filename)ctx_index(path)ctx_searchSave to file, index server-side, query
Playwright snapshot (one-shot)browser_snapshot(filename)ctx_execute_file(path)Save to file, extract in sandbox
Playwright console/networkbrowser_*(filename)ctx_execute_file(path)Save to file, analyze in sandbox
MCP output (already in context)Use directlyDon't re-index — it's already loaded
MCP output (need multi-query)ctx_execute to save → ctx_index(path)ctx_searchSave to file first, index server-side
Wipe indexed KB contentctx_purge(confirm: true)Permanently deletes all indexed content

Automatic Triggers

Use context-mode for ANY of these, without being asked:

  • API debugging: "hit this endpoint", "call the API", "check the response", "find the bug in the response"
  • Log analysis: "check the logs", "what errors", "read access.log", "debug the 500s"
  • Test runs: "run the tests", "check if tests pass", "test suite output"
  • Git history: "show recent commits", "git log", "what changed", "diff between branches"
  • Data inspection: "look at the CSV", "parse the JSON", "analyze the config"
  • Infrastructure: "list containers", "check pods", "S3 buckets", "show running services"
  • Dependency audit: "check dependencies", "outdated packages", "security audit"
  • Build output: "build the project", "check for warnings", "compile errors"
  • Code metrics: "count lines", "find TODOs", "function count", "analyze codebase"
  • Web docs lookup: "look up the docs", "check the API reference", "find examples"

Language Selection

SituationLanguageWhy
HTTP/API calls, JSONjavascriptNative fetch, JSON.parse, async/await
Data analysis, CSV, statspythoncsv, statistics, collections, re
Shell commands with pipesshellgrep, awk, jq, native tools
File pattern matchingshellfind, wc, sort, uniq

Search Query Strategy

  • BM25 uses OR semantics — results matching more terms rank higher automatically
  • Use 2-4 specific technical terms per query
  • Always use source parameter when multiple docs are indexed to avoid cross-source contamination

- Partial match works: source: "Node" matches "Node.js v22 CHANGELOG"

  • Always use queries array — batch ALL search questions in ONE call:

- ctx_search(queries: ["transform pipe", "refine superRefine", "coerce codec"], source: "Zod") - NEVER make multiple separate ctx_search() calls — put all queries in one array

External Documentation

  • Always use ctx_fetch_and_index for external docs — NEVER cat or ctx_execute with local paths for packages you don't own
  • For GitHub-hosted projects, use the raw URL: https://raw.githubusercontent.com/org/repo/main/CHANGELOG.md
  • After indexing, use the source parameter in search to scope results to that specific document

Critical Rules

  1. Always console.log/print your findings. stdout is all that enters context. No output = wasted call.
  2. Write analysis code, not just data dumps. Don't console.log(JSON.stringify(data)) — analyze first, print findings.
  3. Be specific in output. Print bug details with IDs, line numbers, exact values — not just counts.
  4. For files you need to EDIT: Use the normal Read tool. context-mode is for analysis, not editing.
  5. For Bash whitelist commands only: Use Bash for file mutations, git writes, navigation, process control, package install, and echo. Everything else goes through context-mode.
  6. Never use ctx_index(content: large_data). Use ctx_index(path:...) to read files server-side. The content parameter sends data through context as a tool parameter — use it only for small inline text.
  7. Always use filename parameter on Playwright tools (browser_snapshot, browser_console_messages, browser_network_requests). Without it, the full output enters context.
  8. Don't re-index data already in context. If an MCP tool returned data in a previous response, it's already loaded — use it directly or save to file first.

Sandboxed Data Workflow

<sandboxed_data_workflow> <critical_rule> When using tools that support saving to a file: ALWAYS use the 'filename' parameter. NEVER return large raw datasets directly to context. </critical_rule> LargeDataTool(filename: "path") → mcp__context-mode__ctx_index(path: "path") → ctx_search() </sandboxed_data_workflow>

This is the universal pattern for context preservation regardless of the source tool (Playwright, GitHub API, AWS CLI, etc.).

Examples

Debug an API endpoint

const 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}`));

Analyze test output

npm test 2>&1
echo "EXIT=$?"

Check GitHub PRs

gh pr list --json number,title,state,reviewDecision --jq '.[] | "\(.number) [\(.state)] \(.title) — \(.reviewDecision // "no review")"'

Read and analyze a large file

# FILE_CONTENT is pre-loaded by ctx_execute_file
import json
data = json.loads(FILE_CONTENT)
print(f"Records: {len(data)}")
# ... analyze and print findings

Browser & Playwright Integration

When a task involves Playwright snapshots, screenshots, or page inspection, ALWAYS route through file → sandbox.

Playwright browser_snapshot returns 10K–135K tokens of accessibility tree data. Calling it without filename dumps all of that into context. Passing the output to ctx_index(content:...) sends it into context a SECOND time as a parameter. Both are wrong.

The key insight: browser_snapshot has a filename parameter that saves to file instead of returning to context. ctx_index has a path parameter that reads files server-side. ctx_execute_file processes files in a sandbox. None of these touch context.

Workflow A: Snapshot → File → Index → Search (multiple queries)

Step 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)

Total context: ~430B instead of 270K tokens. Real 99% savings.

Workflow B: Snapshot → File → Execute File (one-shot extraction)

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 summary

Total context: ~250B instead of 135K tokens.

Workflow C: Console & Network (save to file if large)

browser_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", ...)

CRITICAL: Why filename + path is mandatory

ApproachContext costCorrect?
browser_snapshot() → raw into context135K tokensNO
browser_snapshot()ctx_index(content: raw)270K tokens (doubled!)NO
browser_snapshot(filename)ctx_index(path)ctx_search~430BYES
browser_snapshot(filename)ctx_execute_file(path)~250BYES

Key Rule

ALWAYS use filename parameter when calling browser_snapshot, browser_console_messages, or browser_network_requests. Then process via ctx_index(path:...) or ctx_execute_file(path:...) — never ctx_index(content:...). Data flow: Playwright → file → server-side read → context. Never: Playwright → context → ctx_index(content) → context again.

Subagent Usage

Subagents automatically receive context-mode tool routing via a PreToolUse hook. You do NOT need to manually add tool names to subagent prompts — the hook injects them. Just write natural task descriptions.

Anti-Patterns

  • Using curl http://api/endpoint via Bash → 50KB floods context. Use ctx_execute with fetch instead.
  • Using cat large-file.json via Bash → entire file in context. Use ctx_execute_file instead.
  • Using gh pr list via Bash → raw JSON in context. Use ctx_execute with --jq filter instead.
  • Piping Bash output through | head -20 → you lose the rest. Use ctx_execute to analyze ALL data and print summary.
  • Running npm test via Bash → full test output in context. Use ctx_execute to capture and summarize.
  • Calling browser_snapshot() WITHOUT filename parameter → 135K tokens flood context. Always use browser_snapshot(filename: "/tmp/snap.md").
  • Calling browser_console_messages() or browser_network_requests() WITHOUT filename → entire output floods context. Always use the filename parameter.
  • Passing ANY large data to ctx_index(content:...) → data enters context as a parameter. Always use ctx_index(path:...) to read server-side. The content parameter should only be used for small inline text you're composing yourself.
  • Calling an MCP tool (Context7 query-docs, GitHub API, etc.) then passing the response to ctx_index(content: response)doubles context usage. The response is already in context — use it directly or save to file first.
  • Ignoring browser_navigate auto-snapshot → navigation response includes a full page snapshot. Don't rely on it for inspection — call browser_snapshot(filename) separately.
  • Expecting ctx_stats to reset or wipe anything → ctx_stats is read-only (shows stats only). Use ctx_purge(confirm: true) to permanently delete all indexed content.

Reference Files

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.34%
按下载量换算743

Claude

28.43%
按下载量换算551

Cursor

19.34%
按下载量换算375

Gemini CLI

10.03%
按下载量换算194

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills