Community编程与开发github.com

上下文工程技能合集

一套全面的 Agent 技能集,涵盖上下文工程、工具工程、多智能体架构和生产级智能体系统。适用于构建、优化、评估或调试需要有效上下文管理和可靠运行循环的智能体系统。

上下文工程技能合集 是什么?

这是一个全面的 Agent 技能集,旨在通过系统化的上下文工程方法,帮助开发者构建生产级的 AI 智能体系统。它涵盖了从基础上下文理论(如注意力机制、上下文退化模式)到高级架构模式(多智能体协调、长程任务提示、记忆系统设计、文件系统上下文管理)的全栈知识。该技能集特别强调了操作卓越性,包括上下文压缩优化(如令牌压缩、自管理上下文、KV 内存共享)、评估框架和工具工程原则,并提供了具体的开发方法论(如任务模型匹配分析)和认知架构(如 BDI 心智状态建模)。它平台无关,适用于 Claude Code、Cursor 或任何支持自定义指令或类似技能构造的 Agent 框架,并且技能之间相互引用,形成一个内部一致的知识体系。用户可以选择独立使用某个技能,也可以组合使用以构建复杂系统,而生产环境中的性能优化和调试策略(如压缩控制分析)则为实际部署提供了可靠保障。

兼容平台✓Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

上下文工程智能体技能集

本合集提供结构化指南,通过有效的上下文工程构建生产级 AI 智能体系统。

何时激活

在以下情况下激活这些技能:

  • 从头构建新的智能体系统
  • 优化现有智能体性能
  • 调试与上下文相关的故障
  • 设计多智能体架构
  • 创建或评估智能体工具
  • 实现内存和持久化层
  • 设计自主研究或评估框架

技能地图

基础上下文工程

理解上下文基础 上下文不仅仅是提示文本——它是推理时语言模型可用的完整状态,包括系统指令、工具定义、检索到的文档、消息历史以及工具输出。有效的上下文工程意味着理解手头任务真正重要的信息,并精炼这些信息以实现最大信噪比。

识别上下文退化 随着上下文增长,语言模型表现出可预测的退化模式:中心信息丢失现象(上下文中心信息受到的关注较少);U型注意力曲线(优先关注开头和结尾);错误累积造成的上下文污染;以及无关信息淹没相关内容导致的上下文分心。

架构模式

多智能体协调 生产级多智能体系统收敛于三种主导模式:具有集中控制的监督/编排架构、用于灵活交接的点对点群体架构,以及用于复杂任务分解的层级结构。关键洞见在于,子智能体主要存在目的是隔离上下文,而非模拟组织角色。

长程任务提示 长时间运行的自主智能体和并行编排,其成败取决于启动提示。伪形式化任务简报指定了成功谓词、非计数结果、带有审计门控返回条件的持久性规则、努力底线、并行组合的多样性策略以及污染防护,将形式化验证的纪律语言化地应用于没有机器可检查成功条件的问题上。在编排运行中,每个工作节点返回一份带有命名检查的输出合约,只有经证实的违规才会阻止返回。

记忆系统设计 记忆架构范围从简单的便签本到复杂的时间知识图谱。向量 RAG 提供语义检索,但丢失了关系信息。知识图谱保留结构,但需要更多的工程投入。文件系统即记忆的模式支持即时上下文加载,无需填充上下文窗口。

基于文件系统的上下文 文件系统提供了一个单一的接口,用于存储、检索和更新几乎无限的上下文。关键模式包括:用于卸载工具输出的便签本、用于长程任务的计划持久化、通过共享文件进行的子智能体通信,以及动态技能加载。智能体使用 ls、glob、grep 和 read_file 进行有针对性的上下文发现,在结构化查询方面通常优于语义搜索。

托管智能体基础设施 后台编码智能体在远程沙盒环境中运行,而非本地机器上。关键模式包括:按固定周期刷新的预构建环境映像、用于即时会话启动的预热沙盒池、用于会话持久化的文件系统快照,以及用于协作智能体会话的多玩家支持。关键优化包括:允许在 git 同步完成前进行文件读取(仅阻止写入)、在用户开始输入时预测性预热沙盒、以及用于并行任务执行的自我生成智能体。

工具设计原则 工具是确定性系统与非确定性智能体之间的契约。有效的工具设计遵循整合原则(优先使用单一综合工具而非多个狭窄工具)、在错误信息中返回上下文、支持响应格式选项以提升令牌效率,并使用清晰的命名空间。

操作卓越性

上下文压缩 当智能体会话耗尽内存时,压缩成为强制性要求。正确的优化目标是每任务令牌数,而非每请求令牌数。带有明确小节(文件、决策和下一步)的结构化摘要比激进压缩保留了更多有用信息。在所有压缩方法中,工件痕迹完整性仍然是最弱的维度。

上下文优化 技术包括:压缩(在接近限制时总结上下文)、观测掩蔽(用引用替代详细的工具输出)、前缀缓存(跨请求复用 KV 块)以及策略性上下文分区(将工作拆分到具有隔离上下文的子智能体)。

自管理上下文 模型(而非运行框架)决定哪些内容保留在其实时上下文中:可编辑区域作为一个文件暴露给模型,模型使用代码工具重写该文件,并在每次循环中重新解析。运行框架维护不变量(固定的系统和任务前缀、角色折叠、编辑门、收据、确定性预算读数、溢出时回滚)。在前缀缓存下,编辑成本随编辑后的文本长度缩放,因此编辑被批处理并放置在尾部附近;策略可以通过指令引导、作为技能演化,或通过成功门控的效率奖励进行训练。

压缩控制分析 模型是否应控制自身的压缩,需要按模型测量而非假设。在同一个运行框架上,跨硬性上下文预算阶梯运行框架驱动和模型驱动的压缩,记录行为概况(接口采纳率、每次调用的压缩因子、已归档内容的重开率、首次压缩时的上下文填充、对压力警告的响应),并在两个方向上校准时序指令,因为抑制早期压缩模型的同一指令,可能与根本不压缩的另一个模型重合。按模型和压力机制分配控制权,将压缩暴露为带有已归档原件的可逆折叠,并在模型或提示发生变化时重新验证。

潜在简报(KV 内存共享) 编排器-工作器系统可能累积令牌:当监督者积累长轨迹,而工作器仅看到狭窄文本片时。潜在简报使用任务引导的注意力(类似注意力匹配的压缩)在工作器模型的 KV 缓存中压缩编排器轨迹,因此当栈暴露工作器 KV 状态且模型兼容时,工作器无需完整文本回放即可接收相关的潜在状态。

评估框架 生产级智能体评估需要确定性检查和涵盖事实准确性、完整性、工具效率和过程质量的多维度评分标准。仅在结构、证据和评分计算有效后使用模型评委;将评委设计、成对比较和偏差缓解引导至高级评估。

运行框架工程 可靠的自主智能体需要围绕模型的显式运行循环:锁定的指标、可编辑表面、持久化日志、新颖性检查、回滚规则和人工审批边界。运行框架防止智能体削弱评估器、在压缩过程中丢失状态,或将模糊目标转变为不可审查的更改。

指令表面安全 清点运行时会加载哪些内容作为指令以及哪些内容授予能力。将建议的更改保持在活动加载器之外,要求对确切的有效更改进行独立授权,并在合法任务完成的同时,测试新会话是否存在未授权的状态或能力更改。

自我改进循环 当运行框架本身成为优化目标时,需要不同的纪律:递归自我改进、元运行框架搜索、失败驱动的有界自我编辑、进化支架搜索以及上下文机制进化。控制约束是经验性的两分割接受门、带有原始轨迹的文件系统经验存档、每个可编辑表面之外的运行时强制约束,以及防止崩溃的多样性保留。

开发方法论

项目开发 有效的 LLM 项目开发从任务模型匹配分析开始:通过手动原型验证任务是否适合 LLM 处理,然后再构建自动化。生产流水线遵循分阶段、幂等的架构(获取、准备、处理、解析、渲染),并利用文件系统状态管理进行调试和缓存。带有明确格式规范的结构化输出设计支持可靠的解析。从最小架构开始,仅在证明必要时添加复杂性。

认知架构

BDI 心智状态 信念-期望-意图建模提供了一种将结构化外部上下文转换为智能体心智状态的正式方法。它适用于理性智能体、可解释性以及需要在信念、目标和所选动作之间建立可审计链接的系统。

核心概念

该合集围绕四个核心主题组织。首先,上下文基础建立了上下文是什么、注意力机制如何工作,以及为什么上下文质量远比数量重要的概念。其次,架构模式涵盖了使有效智能体系统得以实现的协调结构机制。第三,操作卓越性涉及优化、评估和运行框架可靠性。第四,开发方法论和认知架构涵盖了项目执行和正式心智状态建模。

实用指导

每个技能可以独立使用或组合使用。从基础开始,建立上下文管理心智模型。根据系统需求,分支进入架构模式。在优化生产系统时,参考操作技能。

这些技能平台无关,适用于 Claude Code、Cursor 或任何支持自定义指令或类似技能构造的 Agent 框架。

集成

本合集内部集成——技能相互引用并建立在共享概念之上。基础技能为所有其他技能提供上下文。架构技能(多智能体、记忆、工具)可以组合用于复杂系统。操作技能(优化、评估)适用于使用基础和架构技能构建的任何系统。

参考

本合集内部技能:

上下文工程外部资源:

  • 关于注意力机制和上下文窗口限制的研究
  • 来自领先 AI 实验室关于智能体系统设计的生产经验
  • LangGraph、AutoGen 和 CrewAI 的框架文档

技能元数据

创建日期:2025-12-20 最后更新:2026-10-01 作者:Agent Skills for Context Engineering Contributors 版本:2.6.0

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

advanced-evaluation

This skill should be used for advanced LLM evaluation: LLM-as-judge systems, direct scoring, pairwise comparison, rubric calibration, evaluator bias mitigation, confidence scoring, and automated quality assessment.

bdi-mental-states

This skill should be used when modeling agent mental states with BDI concepts: beliefs, desires, intentions, RDF-to-belief transformations, rational agency traces, cognitive agents, BDI ontologies, and neuro-symbolic AI integration.

book-sft-pipeline

This skill should be used for book-to-SFT pipelines: ePub extraction, literary segmentation, author-voice dataset construction, style-transfer training, LoRA workflows, and model evaluation for voice replication.

compaction-control-profiling

This skill should be used when deciding, for a specific model and workload, whether the harness or the model should control compaction, and when qualifying or calibrating that choice with measurements: context-budget sweeps that compare harness-driven and model-driven compaction on one harness, the context-pressure regime where delegation pays, a per-model compaction behavior profile (interface uptake, compression factor per call, reopen rate of archived content, context fill at first compaction, response to pressure warnings), context anxiety and timing-instruction calibration, reversible collapse-and-archive interfaces, and re-qualification after a model or prompt change. Route the editable-file protocol, harness invariants, and edit-position cache cost of self-editing agents to self-managed-context, summary content to context-compression, harness thresholds and cache layout to context-optimization, and general evaluation design to evaluation.

comprehensive-research-agent

Ensure thorough validation, error recovery, and transparent reasoning in research tasks with multiple tool calls

context-compression

This skill should be used when long-running agent sessions need context compression, structured summarization, compaction, token-per-task optimization, or durable handoff summaries that preserve decisions, files, risks, and next actions.

context-degradation

This skill should be used for diagnosing and mitigating context degradation: lost-in-middle failures, context poisoning, context clash, context confusion, attention-pattern issues, and agent performance degradation caused by accumulated or conflicting context.

context-fundamentals

This skill should be used to explain or reason about the foundational concepts of context engineering: what context is, the anatomy of a context window, how attention mechanics work, the U-shaped attention curve, why context quality matters more than quantity, and the mental models needed to interpret every other context-engineering decision. Use this for conceptual explanation, onboarding, and background reading. Route operational work to the specialized skills: debugging attention failures goes to context-degradation, token-efficiency work goes to context-optimization, conversation summarization goes to context-compression, and project-shape decisions go to project-development.

context-optimization

This skill should be used for improving context efficiency: context budgeting, observation masking, prefix or KV-cache strategy, partitioning, token-cost reduction, retrieval scoping, and extending effective context capacity without lowering answer quality.

evaluation

This skill should be used when building agent evaluation systems: deterministic checks, regression suites, multi-dimensional rubrics, quality gates, production monitoring, baseline comparison, and outcome measurement for agent pipelines.

filesystem-context

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.

harness-engineering

This skill should be used when designing autonomous agent harnesses: research loops, evaluation scaffolds, locked and editable surfaces, durable logs, novelty gates, pruning, rollback, PR preparation, and human approval boundaries.

hosted-agents

This skill should be used when designing hosted or background agent infrastructure: sandboxed execution, remote coding environments, warm pools, session persistence, multiplayer collaboration, self-spawning agents, or Modal-style sandboxes.

instruction-surface-security

Hardens agent runtimes against persistent prompt injection or unauthorized changes to instructions and permissions. Use to audit what agents auto-load, design reviewed activation for project rules, skills, memory, or tool configuration, and test whether trust boundaries hold after reload, restart, or delegation.

latent-briefing

This skill should be used when the user asks to "share memory between agents", "KV cache compaction for multi-agent", "orchestrator worker context", "latent briefing", "reduce worker tokens", "cross-agent memory without summarization", or discusses Attention Matching compaction, recursive language models with workers, or token explosion in hierarchical agents.

long-horizon-prompting

This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.

memory-systems

This skill should be used for persistent semantic memory in agent systems: cross-session knowledge retention, entity tracking, temporal validity, graph or vector retrieval, memory consolidation, and memory benchmark selection. Route file-backed scratchpads to filesystem-context, handoff summaries to context-compression, and token-efficiency tactics to context-optimization.

multi-agent-patterns

This skill should be used when designing multi-agent systems that need context isolation, supervisor or swarm coordination, explicit handoffs, parallel execution, or a decision on whether multiple agents are justified.

project-development

This skill should be used for project-level decisions about LLM-powered systems: whether an LLM is the right primitive for the task at hand, the shape of a multi-stage batch or agent pipeline, token and cost estimation, choosing between single-agent and multi-agent at the project level, structured output design for downstream parsing, and structuring agent-assisted iteration. Use this when the unit of work is a whole project or a multi-stage pipeline. Route individual tool design to tool-design and individual skill-loading or context-budget tactics to context-optimization.

self-improvement-loops

This skill should be used when the harness, scaffold, workflow, or optimizer itself is the optimization target: recursive self-improvement (RSI) loops, meta-harnesses, self-improving harnesses that mine their own failures and propose bounded edits, evolutionary or population-based search over agent scaffolds, acceptance gates for self-modifying systems, and agentic context evolution where the mechanism that produces context is versioned and evolved. Route governance of a single autonomous loop (locked surfaces, durable logs, rollback, novelty gates, approval boundaries) to harness-engineering, measurement and quality-gate design to evaluation, judge design to advanced-evaluation, and remote sandbox infrastructure to hosted-agents.

相关技能