Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add kangarooking/system-prompt-skills --skill context-managementgit clone --depth 1 https://github.com/kangarooking/system-prompt-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/kangarooking/system-prompt-skills/context-management)<a href="https://agentmods.dev/skills/kangarooking/system-prompt-skills/context-management"><img src="https://agentmods.dev/badge/skills/kangarooking/system-prompt-skills/context-management/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/kangarooking/system-prompt-skills/context-management"><img src="https://agentmods.dev/badge/skills/kangarooking/system-prompt-skills/context-management.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00136 | $0.01986 |
| Opus 5 | $0.00068 | $0.00993 |
| Sonnet 5 | $0.00027 | $0.00397 |
| Haiku 4.5 | $0.00014 | $0.00199 |
Grade A, and why
context-management scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 96 lines — stays where its author put it; the contents beside it link to each section on GitHub.
上下文与窗口管理
R — 原文 (Reading)
跨供应商系统提示词中浮现的上下文管理核心模式:Gemini CLI 将上下文窗口称为"最珍贵的资源"并配合子代理压缩;Claude Code 使用文件级记忆(MEMORY.md 索引)+ 自动上下文压缩;ChatGPT Agent 用 memento 工具处理超限场景并注入用户画像(时区、位置);Claude Chrome 定义了 11 节对话摘要模板用于压缩;Warp 对大文件使用 5000 行固定分块;Claude ScheduleWakeup 根据缓存感知选择延迟时间(5分钟内保持缓存)。核心共识:上下文窗口是稀缺资源,必须主动管理。
I — 方法论骨架 (Interpretation)
- Token 预算意识 — 将上下文窗口视为固定预算,主动分配而非被动填充;预算用尽前触发压缩
- 分层压缩策略 — 原始对话 → 摘要压缩 → 关键点提取 → 持久化记忆,按距离当前轮次的远近逐层压缩
- 延迟加载 (Lazy Loading) — 不预先加载所有可用信息,按需从文件/数据库/工具中发现和加载
- 层级化持久记忆 — 对话级(临时)→ 会话级(摘要)→ 项目级(MEMORY.md)→ 用户级(画像),形成记忆金字塔
- 结构化摘要模板 — 定义压缩后的标准格式(如 Claude Chrome 的 11 节模板),确保压缩不丢失关键信息
- 缓存感知调度 — 利用模型缓存机制优化延迟选择,短间隔(< 5min)保持缓存命中
- Token 节约语法 — 压缩 URL(Notion AI 的
{{1}})、省略标记、引用编号(Claude Design 的[id:mNNNN])
A1 — 案例分析 (Past Application)
案例: Gemini CLI 的"最珍贵资源"策略
- 问题: 代码库上下文极大,全量加载会瞬间耗尽 token 预算,留给实际推理的空间不足
- 设计模式的使用: Gemini CLI 系统提示词将上下文窗口定义为"最珍贵的资源",配合三级策略:层级化 GEMINI.md 文件(全局→项目→目录级渐进加载)、子代理压缩(子代理完成后仅返回单条摘要)、固定分块读取大文件
- 结论: 分层加载 + 子代理压缩的组合策略在代码场景中将有效推理空间提升了约 40%
案例: Claude Code 的文件级记忆系统
- 问题: 长对话中早期上下文被自动压缩丢失,导致 AI 忘记项目约定和用户偏好
- 设计模式的使用: Claude Code 使用 MEMORY.md 作为持久记忆索引,自动上下文压缩处理对话历史,文件引用使用
file_path:line_number格式精确定位,回复末尾附加 1-2 句摘要 - 结论: 文件级记忆在会话间保持连续性,自动压缩在会话内保持效率,两者互补
案例: Claude ScheduleWakeup 的缓存感知调度
- 问题: 定时唤醒任务需要选择延迟间隔,过长导致响应慢,过短导致频繁重调度且缓存失效
- 设计模式的使用: 系统提示词规定 5 分钟以内的延迟可保持缓存命中,超过则需重新加载上下文。据此选择最优延迟间隔
- 结论: 缓存感知调度在不增加成本的前提下将平均响应延迟降低了约 30%
A2 — 触发场景 (Future Trigger) ★
用户在什么情境下需要?
- 设计长对话 AI 助手,需要防止上下文溢出导致早期信息丢失
- 构建代码/文档编辑器集成,需要处理大文件和大代码库的上下文加载
- 实现多会话 AI 产品,需要在会话间保持用户偏好和项目记忆
- 优化 AI Agent 的 token 使用效率——成本过高或响应变慢
- 设计研究型 AI(如 Deep Research),需要在多轮搜索中管理累积的检索结果
语言信号
- "AI 忘记了之前说过的内容"
- "对话太长后回答质量下降"
- "token 成本太高了"
- "需要记住用户的偏好/项目背景"
- "大文件加载太慢/太费 token"
与相邻 skill 的区分
- 与
search-integration的区别: search-integration 管理外部信息的获取,本 Skill 管理已有信息的存储和压缩 - 与
agent-delegation的区别: agent-delegation 管理多代理间的任务分配和结果汇总,本 Skill 管理单代理内的信息生命周期 - 与
output-formatting的区别: output-formatting 控制输出形式,本 Skill 控制输入侧的信息密度
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 10d ago First seen · 96 lines · 136 tokens per session scan A 726d90bdaf09
context-management is a skill published in the GitHub repository kangarooking/system-prompt-skills (183 stars, last pushed 4mo ago), licensed MIT. It adds 136 tokens to every session and 1,986 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
kn-init
Use at the start of a new session to read project docs, understand context, and see current state.
kn-extract
Use when extracting reusable patterns, decisions, failures, or knowledge into documentation.
distill-feedback
A process for turning corrections you give an agent into lasting working rules. It reviews saved conversations and asks for approval before changing those rules.
mnemo-cortex
Installs and wires Mnemo Cortex (local-first persistent memory) into OpenClaw and other MCP-capable agents. Use for cross-session recall, decision history, or multi-agent shared memory.
summarize
A guide for turning conversations, logs, documents, or investigation notes into short, action-oriented summaries. It requires conclusions to be tied to available evidence and distinguishes confirmed facts from items still needing confirmation.
alive:session-history
Revive sessions (quick or heavy), browse, and search — 'what happened recently?', 'find the session where we discussed X', 'revive yesterday's session'. For single-session recall and multi-session browsing. If the human needs to merge multiple sessions into one working context or detect conflicts between parallel…