context-mode
Skill này làm gì
Skill này hướng dẫn agent AI xử lý đầu ra lệnh lớn và tệp qua công cụ context-mode thay vì đọc toàn bộ. Skill dành cho lập trình viên làm việc với log dài, phản hồi API lớn và đầu ra build.
Khi nào nên dùng
- ✓Khi agent được yêu cầu phân tích log, tóm tắt đầu ra lệnh hoặc phân tích một phản hồi JSON lớn.
- ✓Khi một bản build hoặc kiểm tra phụ thuộc có thể tạo đầu ra dài cần được lọc.
- ✓Khi một ảnh chụp trang hoặc cấu trúc trình duyệt quá lớn để đọc trực tiếp.
Liên kết skill
https://github.com/mksglu/context-mode/blob/main/skills/context-mode/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Phân tích các log build này và chỉ cho tôi các lỗi, đừng hiển thị toàn bộ đầu ra.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill đặt quy tắc mặc định: dùng công cụ context-mode cho mọi thứ đọc, truy vấn, lấy, liệt kê hoặc build, và giữ lệnh shell thông thường cho các thao tác nhỏ, an toàn. Sau đó agent chỉ hiển thị những phần quan trọng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
| Situation | Tool | Example |
|---|---|---|
| Hit an API endpoint | ctx_execute |
fetch('http://localhost:3000/api/orders') |
| Run CLI that returns data | ctx_execute |
gh pr list, aws s3 ls, kubectl get pods |
| Run tests | ctx_execute |
npm test, pytest, go test ./... |
| Git operations | ctx_execute |
git log --oneline -50, git diff HEAD~5 |
| Docker/K8s inspection | ctx_execute |
docker stats --no-stream, kubectl describe pod |
| Read a log file | ctx_execute_file |
Parse access.log, error.log, build output |
| Read a data file | ctx_execute_file |
Analyze CSV, JSON, YAML, XML |
| Read source code to analyze | ctx_execute_file |
Count functions, find patterns, extract metrics |
| Fetch web docs | ctx_fetch_and_index |
Index React/Next.js/Zod docs, then search |
| Playwright snapshot | browser_snapshot(filename) → ctx_index(path) → ctx_search |
Save 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/network | browser_*(filename) → ctx_execute_file(path) |
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) | ctx_execute to save → ctx_index(path) → ctx_search |
Save to file first, index server-side |
Câu hỏi thường gặp
Những lệnh nào vẫn có thể chạy trực tiếp?
Các thao tác nhỏ, an toàn như tạo thư mục, di chuyển tệp, ghi git, điều hướng và echo vẫn có thể chạy trong shell.
Nó làm gì với đầu ra lớn?
Nó xử lý đầu ra trong hộp cát và chỉ trả về các kết quả liên quan vào cuộc trò chuyện.
Nó có áp dụng cho mọi lệnh không?
Nó áp dụng cho hầu hết các lệnh. Quy tắc là dùng context-mode bất cứ khi nào agent không chắc đầu ra sẽ lớn đến đâu.
Chi tiết
Mô tả gốc của tác giả
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 referen
repo: mksglu/context-mode
Độ phổ biến
- Sao GitHub
- 33k
- Vị trí xếp hạng
- #8510
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
context-mode
33kDạy agent dùng các công cụ context-mode để đọc, tìm kiếm và chạy tác vụ nặng dữ liệu, giữ đầu ra lớn ngoài cuộc trò chuyện chính.
context-mode
33kDạy agent chạy công việc nặng dữ liệu trong hộp cát và chỉ in câu trả lời, để tệp thô và trang web không làm ngập cuộc trò chuyện.
ctx-doctor
33kChạy chẩn đoán context-mode để kiểm tra runtime, hook, kho tìm kiếm, plugin và phiên bản, rồi hiển thị báo cáo đạt hoặc không đạt.
ctx-index
33kCho phép agent của bạn lập chỉ mục một thư mục hoặc dự án cục bộ thành kho tìm kiếm, để các câu hỏi sau này tìm đúng đoạn mà không đọc lại mọi tệp.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.