context-engine
Skill0 starsChanged 3 months agoMITView on GitHub
上下文引擎 v3:Claude 5 新范式(原则式指令+信任判断+手动记忆)+ token 预算 + 输出精简 + Shadow VFS + 策略压缩
9 other projects use a version of this.
Adopted by
Most recently taken up by
- darkweb19/skillstheir own version, first seen Nov 8, 2026
- relote-com/omarchy-context-enginetheir own version, first seen Nov 8, 2026
- Context-Engine-AI/Context-Enginetheir own version, first seen Oct 25, 2026
- teachskillofskills-ai/DigitalMarketingPro-techshutheir own version, first seen Oct 11, 2026
- m1rl0k/Context-Enginetheir own version, first seen Oct 8, 2026
- Hassaan146/claude-skillstheir own version, first seen Jul 25, 2026
Used with
Projects with it also use andreessen, business-investment-advisor and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Hussain-ElfalahSkillandreessen
Also in 4 projects that use this
Hussain-ElfalahSkillbusiness-investment-advisor
Also in 4 projects that use this
csiddhant796-blipSkillkarpathy-coder
Use when writing, reviewing, or committing code to enforce Karpathy's 4 coding principles — surface assumptions before coding, keep it simple, make surgical changes, define verifiable goals. Triggers on "review my diff", "check complexity", "am I overcomplicating this", "karpathy check", "before I commit", or any code quality concern where the LLM might be overcoding.
Also in 4 projects that use this
- +8 more from Hussain-Elfalah
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- indranilbanerjee/digital-marketing-pro★ 934same name
- Context-Engine-AI/Context-Engine★ 400same name
- Hassaan146/claude-skills★ 18same name
- relote-com/omarchy-context-engine★ 4same name
- m1rl0k/Context-Engine★ 3same name
- Hussain-Elfalah/Agentic-Skills★ 2same name
- mahiunfiltered/claude-code-skills★ 1same name
- darkweb19/skills★ 0same name
- teachskillofskills-ai/DigitalMarketingPro-techshu★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository219 other files it gives its agents.
- agent-doctrineSkill
- agent-evaluation-frameworkSkill
- agent-visualization-flintSkill
- hermes-agentSkill
- bailian-cliSkill
- edge-browser-automationSkill
- computer-useSkill
- jupyter-live-kernelSkill
- backup-strategiesSkill
- browser-automationSkill
- chinese-ai-free-apiSkill
- cicd-pipeline-templatesSkill
- copybaraSkill
- devops-toolkitSkill
- email-deliverabilitySkill
- monitoring-observabilitySkill
- obsidian-maintenanceSkill
- obsidian-troubleshootingSkill
- openclaw-windowsSkill
- openclaw-workerSkill
- webhook-subscriptionsSkill
- windows-dev-environmentSkill
- windows-masterSkill
- zero-downtime-deploySkill
- codebase-inspectionSkill
- github-workflowSkill
- adaptive-communicationSkill
- agent-cost-dashboardSkill
- agent-evolutionSkill
- agent-governanceSkill
- agent-osSkill
- context-efficient-toolsSkill
- context-loss-awarenessSkill
- creative-synthesisSkill
- hermes-desktop-pluginsSkill
- emotional-intelligenceSkill
- graph-engineering-workflowSkill
- hermes-maintenanceSkill
- hermes-voiceSkill
- hermes-hygieneSkill
- identity-coreSkill
- income-loopSkill
- master-synthesisSkill
- meta-cognitionSkill
- reasoning-engineSkill
- self-preservationSkill
- teaching-abilitySkill
- temporal-awarenessSkill
- hermes-themesSkill
- thinking-visualizationSkill
- user-modelingSkill
- voice-full-restoreSkill
- knowledge-graph-traversalSkill
- mcp-browser-canvasSkill
- free-api-gatewaySkill
- native-mcpSkill
- web-reverse-apiSkill
- ai-edaSkill
- huggingface-hubSkill
- industrial-ai-siemens-mcpSkill
- The first 60 shown.
The file
Files
Context Engine — 上下文引擎
汇聚所有上下文优化策略:输出压缩、文件读取优化、策略压缩、预算管理。一站式省 token。
一、输出压缩(简洁模式)
当用户说"简洁"/"少说点"/"别啰嗦"时启用:
- 无填充词(跳过"好的""我来帮你""让我看看")
- 无事中播报(跳过"首先我..."、"现在我在...",直接干,汇报结果)
- 不重复已说内容
- 一点一段落
- 代码优先于文字描述
- 列表优先于段落
- 中文天然省 token,异步用中文
三级压缩:lite(30%节省)、full(60%节省)、ultra(关键词仅已知上下文)
二、文件读取优化(Shadow VFS)
原生 read_file 每次都把文件全量注入上下文——同一文件读 3 次浪费 3 倍 token,破坏 prompt cache。
Shadow VFS 解决:
- read_file → 只返回指针(路径 + hash + 行数 + token 估算 + 前 5 行预览)
- materialise → 需要分析代码时才加载完整内容
- invalidate → 文件修改后标记缓存失效
| 场景 | 原生 | Shadow VFS |
| 读 500 行文件 ×10 次 | ~40,000 token | ~4,900 token |
| 节省 | — | ~87% |
只在实际需要分析代码内容时才物化。确认文件存在/知道大致内容就够了。
脚本路径:D:/Hermes/scripts/shadow_vfs.py
压缩后恢复(LCM 模式)
借鉴 hermes-lcm (873⭐) 的 DAG 无损理念:压缩 ≠ 删除。
- 压缩后如果后续任务需要之前讨论的细节 →
session_search(query="关键词")找回 - 关键决策、架构定论、用户偏好 → 压缩前先存 memory(不受压缩影响)
- 长任务开始前预判:"如果等会儿被压缩,哪些信息是后面必须用的?" → 提前存 memory
压缩后丢失 → 找回映射
| 丢失内容 | 找回方式 |
| 早期决策/定论 | memory 工具(已持久化) |
| 中间讨论细节 | session_search |
| 代码上下文 | SigMap 签名索引 |
| MCP 工具 schema | copium 式按需展开 |
三、策略压缩
在逻辑边界手动压缩,而非依赖随机自动压缩。
压缩时机
| 阶段过渡 | 压缩? | 原因 |
| 研究 → 规划 | 是 | 研究内容冗长,规划是精炼输出 |
| 规划 → 实现 | 是 | 规划已在 TodoWrite,释放上下文给代码 |
| 实现 → 测试 | 可能 | 如果测试引用最近代码则保留 |
| 调试 → 新功能 | 是 | 调试追踪对后续工作无益 |
| 实现中 | 否 | 丢失变量名/文件路径/局部状态代价大 |
| 失败方案后 | 是 | 清空死胡同思路,尝试新方法 |
压缩后保留
CLAUDE.md 指令、TodoWrite 任务列表、Memory 文件、Git 状态、磁盘文件。
压缩后丢失
中间推理分析、详细文件内容、对话上下文、工具调用历史。
四、Token 预算审计
当需要了解上下文消耗时,审计以下组件:
- Skills:每个 1-5K token,按需加载,不用全载
- MCP 工具:每个工具 schema ~500 token,30 工具服务器 > 所有 skills 总和
- Agent 描述:即使 Agent 未被调用,其描述也在上下文中
- CLAUDE.md:保持精简,不要重复 rules 内容
估算公式
- 散文:字数 × 1.3
- 代码/混合:字符数 / 4
五、上下文健康速查
- < 70% — 正常操作,全精度
- 70-85% — 精度开始下降,考虑压缩
85% — 幻觉风险飙升,立即压缩或清空
六、组合策略
日常使用:简洁模式 + Shadow VFS = 输出省 60% + 文件读省 87% 长会话:策略压缩在逻辑边界 + 预算审计每隔 5-10 轮 用户交互:直接选深度 25%/50%/75%/100%,不等提问
七、Claude 5 上下文工程新范式(v3.0 新增)
基于 HN 244pts/155 评论讨论 + Anthropic 官方博文,Claude 5 彻底改变了上下文工程的游戏规则。
核心转变
旧范式(Claude 4 / GPT-5 之前) 新范式(Claude 5 / Fable 5)
───────────────────────────────── ─────────────────────────
详尽系统提示,覆盖每个边界情况 → 原则式指令,信任模型判断
500 行 CLAUDE.md 全量注入 → 精简到 50 行核心原则
自动记忆(模型自己管理) → 手动记忆(Agent 不要管记忆)
指令优先("你必须...") → 判断优先("根据情况判断")
前缀工程(crafting prompts) → 对话工程(just talk to it)五条新规则
| # | 规则 | 说明 |
| 1 | 原则式指令 | 给原则不说规则。说"保持代码简洁"而非"每个函数不超过 20 行" |
| 2 | 信任模型判断 | "use your own judgement" 真的有效。模型知道什么时候打破规则 |
| 3 | 禁用自动记忆 | Agents 会写太多、不会删、做错误推断。记忆必须人工管理 |
| 4 | 精简前缀 | 500 行 system prompt → 50 行核心原则。模型自己补充细节 |
| 5 | 对话优于指令 | 用自然对话沟通,而非像写法律合同一样写 prompt |
对 Skills 的影响
旧方式(v2.0 风格):
## 规则
1. 每次必须先检查 A
2. 如果 A 返回 X,则执行 B
3. B 失败时回退到 C
4. C 超时 30 秒后重试 3 次
...(200 行规则)新方式(v3.0 风格):
## 原则
- 优先走可靠路径,失败时自主降级
- 不确定时问用户,不要猜测
- 保持输出简洁,代码优先于文字对 Memory 的影响
用户反馈:禁用 auto-memory 后性能反而提升。原因:
- Agent 写的 memory 太多太杂,噪声淹没信号
- Agent 不会删 memory,越积越多
- Agent 从 memory 做推断经常出错("它记得 A 和 B,就推断 C 也是真的")
新策略:Memory 只由人工触发。Agent 可以在发现重要信息时建议存 memory,但不自动存储。
实践检查清单
在写 skill 或 system prompt 时自问:
- 这条规则能不能改成原则?("你必须 X" → "倾向于 X")
- 这个边界情况模型自己能判断吗?(如果能,删掉规则)
- 这段内容 100 字能说清吗?(不能 → 精简)
- 是不是在替模型做它自己能做的决策?(是 → 删掉)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

