filesystem-context
Skill này làm gì
Skill này chỉ cách lưu các đầu ra dài, kế hoạch và ghi chú vào file rồi đọc lại chỉ khi cần, giữ cửa sổ làm việc của AI luôn thông thoáng. Nó dành cho người xây dựng agent chạy tác vụ dài hoặc chia sẻ công việc giữa các agent.
Khi nào nên dùng
- ✓Khi đầu ra công cụ hoặc log đang làm đầy cửa sổ ngữ cảnh của agent.
- ✓Khi một agent cần giữ kế hoạch hoặc ghi chú nháp qua một tác vụ dài.
- ✓Khi nhiều agent phải chia sẻ thông tin qua file thay vì tin nhắn trực tiếp.
Liên kết skill
https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/filesystem-context/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
“Thiết lập agent của tôi để lưu đầu ra lệnh dài vào file và chỉ đọc những phần nó cần.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill yêu cầu agent ghi kết quả vào file, rồi tra cứu các phần liên quan khi cần, thay vì giữ mọi thứ trong prompt.
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.
Filesystem-Based Context Engineering
Use the filesystem as the primary overflow layer for agent context because context windows are limited while tasks often require more information than fits in a single window. Files let agents store, retrieve, and update an effectively unlimited amount of context through a single interface.
Prefer dynamic context discovery -- pulling relevant context on demand -- over static inclusion, because static context consumes tokens regardless of relevance and crowds out space for task-specific information.
When to Activate
Activate this skill when:
- Tool outputs are bloating the context window
- Agents need to persist state across long trajectories
- Sub-agents must share information without direct message passing
- Tasks require more context than fits in the window
- Building agents that learn and update their own instructions
- Implementing scratch pads for intermediate results
- Terminal outputs or logs need to be accessible to agents
Do not activate this skill for adjacent work owned by other skills:
- Semantic cross-session memory, entity tracking, or temporal knowledge graphs:
memory-systems. - Conversation summarization, compaction, or durable handoff wording:
context-compression. - Token-efficiency tactics that do not require file-backed storage:
context-optimization. - Multi-agent topology or handoff protocol design:
multi-agent-patterns. - Model edits that evict content from the live window itself:
self-managed-context.
Core Concepts
Diagnose context failures against these four modes, because each requires a different filesystem remedy:
- Missing context -- needed information is absent from the total available context. Fix by persisting tool outputs and intermediate results to files so nothing is lost.
- Under-retrieved context -- retrieved content fails to encapsulate what the agent needs. Fix by structuring files for targeted retrieval (grep-friendly formats, clear section headers).
- Over-retrieved context -- retrieved content far exceeds what is needed, wasting tokens and degrading attention. Fix by offloading bulk content to files and returning compact references.
- Buried context -- niche information is hidden across many files. Fix by combining glob and grep for structural search alongside semantic search for conceptual queries.
Use the filesystem as the persistent layer that addresses all four: write once, store durably, retrieve selectively.
Detailed Topics
The Static vs Dynamic Context Trade-off
Treat static context (system instructions, tool definitions, critical rules) as expensive real estate -- it consumes tokens on every turn regardless of relevance. As agents accumulate capabilities, static context grows and crowds out dynamic information.
Use dynamic context discovery instead: include only minimal static pointers (names, one-line descriptions, file paths) and load full content with search tools when relevant. This is more token-efficient and often improves response quality by reducing contradictory or irrelevant information in the window.
Accept the trade-off: dynamic discovery requires the model to recognize when it needs more context. Current frontier models handle this well, but less capable models may fail to trigger loads. When in doubt, err toward including critical safety or correctness constraints statically.
Pattern 1: Filesystem as Scratch Pad
Redirect large tool outputs to files instead of returning them directly to context, because a single web search or database query can dump thousands of tokens into message history where they persist for the entire conversation.
Write the output to a scratch file, extract a compact summary, and return a file reference. The agent then uses targeted retrieval (grep for patterns, read with line ranges) to access only what it needs.
def handle_tool_output(output: str, threshold: int = 2000) -> str:
if len(output) < threshold:
return output
file_path = f"scratch/{tool_name}_{timestamp}.txt"
write_file(file_path, output)
key_summary = extract_summary(output, max_tokens=200)
return f"[Output written to {file_path}. Summary: {key_summary}]"
Use grep to search the offloaded file and read_file with line ranges to retrieve targeted sections, because this preserves full output for later reference while keeping only ~100 tokens in the active context.
Pattern 2: Plan Persistence
Write plans to the filesystem be
Câu hỏi thường gặp
Vì sao lưu ngữ cảnh vào file?
File có thể chứa nhiều thông tin hơn cửa sổ ngữ cảnh, và agent chỉ tải những gì nó cần.
Có giống bộ nhớ dài hạn không?
Không. Bộ nhớ dài hạn qua các phiên được bao quát riêng, còn skill này tập trung vào file dùng trong một tác vụ.
Các file cũ có được dọn dẹp không?
Skill nhắc đến các chính sách dọn dẹp cho ngữ cảnh được lưu bên ngoài prompt.
Chi tiết
Mô tả gốc của tác giả
This skill should be used when agent work needs file-backed context: durable scratchpads, tool-output offloading, just-in-time discovery, cross-agent handoff files, filesystem memory, or cleanup policies for context stored outside the prompt.
Độ phổ biến
- Sao GitHub
- 18k
- Vị trí xếp hạng
- #10642
- Giấy phép
- MIT
- Cập nhật
- 11/10/2026
Bình luận
- …
Thêm skill từ kho mã này
context-engineering-collection
18kGiúp agent của bạn quản lý những gì đưa vào cửa sổ ngữ cảnh của model AI, từ bộ nhớ và công cụ đến thiết lập nhiều agent và đánh giá.
advanced-evaluation
18kDạy agent của bạn cách đánh giá câu trả lời AI bằng một AI khác, với chấm điểm, so sánh cạnh nhau và kiểm tra thiên lệch.
bdi-mental-states
18kDạy agent của bạn mô hình hóa niềm tin, mục tiêu và kế hoạch bằng cách tiếp cận BDI, để các quyết định của nó có thể được truy vết và giải thích.
context-compression
18kGiúp agent của bạn rút gọn các phiên AI dài thành bản tóm tắt giữ lại quyết định, file, rủi ro và bước tiếp theo.
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.