跳到正文
Skillpedia
技术文档48k · #4614

filesystem-context

它能做什么

这个系统可以帮助 AI 管理重要信息,同时又不会让它的短期记忆超载。它会把数据保存到文件中,需要时 AI 再去读取,而不是试图一次性记住所有内容。

适用场景

  • ✓AI 一次收到的信息太多时。
  • ✓AI 需要长期记住某些重要内容时。
  • ✓AI 的不同部分需要共享信息时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/filesystem-context/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/filesystem-context/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“把这次搜索的结果保存到一个文件里,方便我以后查阅。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会把重要信息写入文件。当它需要再次使用这些信息时,只会查找并读取必要的部分,而不是把所有内容都加载到记忆中。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Filesystem-Based Context Engineering

The filesystem provides a single interface through which agents can flexibly store, retrieve, and update an effectively unlimited amount of context. This pattern addresses the fundamental constraint that context windows are limited while tasks often require more information than fits in a single window.

The core insight is that files enable dynamic context discovery: agents pull relevant context on demand rather than carrying everything in the context window. This contrasts with static context, which is always included regardless of relevance.

When to Use

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

Core Concepts

Context engineering can fail in four predictable ways. First, when the context an agent needs is not in the total available context. Second, when retrieved context fails to encapsulate needed context. Third, when retrieved context far exceeds needed context, wasting tokens and degrading performance. Fourth, when agents cannot discover niche information buried in many files.

The filesystem addresses these failures by providing a persistent layer where agents write once and read selectively, offloading bulk content while preserving the ability to retrieve specific information through search tools.

Detailed Topics

The Static vs Dynamic Context Trade-off

Static Context Static context is always included in the prompt: system instructions, tool definitions, and critical rules. Static context consumes tokens regardless of task relevance. As agents accumulate more capabilities (tools, skills, instructions), static context grows and crowds out space for dynamic information.

Dynamic Context Discovery Dynamic context is loaded on-demand when relevant to the current task. The agent receives minimal static pointers (names, descriptions, file paths) and uses search tools to load full content when needed.

Dynamic discovery is more token-efficient because only necessary data enters the context window. It can also improve response quality by reducing potentially confusing or contradictory information.

The trade-off: dynamic discovery requires the model to correctly identify when to load additional context. This works well with current frontier models but may fail with less capable models that do not recognize when they need more information.

Pattern 1: Filesystem as Scratch Pad

The Problem Tool calls can return massive outputs. A web search may return 10k tokens of raw content. A database query may return hundreds of rows. If this content enters the message history, it remains for the entire conversation, inflating token costs and potentially degrading attention to more relevant information.

The Solution Write large tool outputs to files instead of returning them directly to the context. The agent then uses targeted retrieval (grep, line-specific reads) to extract only the relevant portions.

Implementation

def handle_tool_output(output: str, threshold: int = 2000) -> str:
    if len(output) < threshold:
        return output
    
    # Write to scratch pad
    file_path = f"scratch/{tool_name}_{timestamp}.txt"
    write_file(file_path, output)
    
    # Return reference instead of content
    key_summary = extract_summary(output, max_tokens=200)
    return f"[Output written to {file_path}. Summary: {key_summary}]"

The agent can then use grep to search for specific patterns or read_file with line ranges to retrieve targeted sections.

Benefits

  • Reduces token accumulation over long conversations
  • Preserves full output for later reference
  • Enables targeted retrieval instead of carrying everything

Pattern 2: Plan Persistence

The Problem Long-horizon tasks require agents to make plans and follow them. But as conversations extend, plans can fall out of attention or be lost to summarization. The agent loses track of what it was supposed to do.

The Solution

…

常见问题

为什么不能一次把所有信息都交给 AI?

AI 的「短期记忆」(称为上下文窗口)是有限的。如果信息太多,它可能会忘记最重要的内容,或者变得混乱。

AI 怎么知道哪些信息值得保存?

AI 经过训练,能够识别对当前任务至关重要或将来可能有用的信息,然后决定把它们保存到文件中。

这有点像 AI 的「记事本」吧?

可以这么理解。AI 会像使用记事本或档案柜一样,用文件来存放重要信息,并在需要时取出来。

详情

作者的原始描述

Use for file-based context management, dynamic context discovery, and reducing context window bloat. Offload context to files for just-in-time loading.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4614
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能