Community程式設計與開發github.com

context-engineering-collection

一個全面的 Agent 技能集合,涵蓋情境工程、檢測工程、多智能體架構及生產級 Agent 系統。適用於建構、優化、評估或除錯需要有效情境管理及可靠運作循環的 Agent 系統。

context-engineering-collection 是什麼?

這是一個專為 AI Agent 開發者設計的綜合性技能集合,核心目標是透過有效的「情境工程」來建構生產級的 Agent 系統。該集合系統性地涵蓋了從基礎理論到高階架構的完整知識,包括:理解情境本質與退化模式(如 Lost-in-Middle)、多智能體協調架構、長時程任務提示、記憶系統設計、基於檔案系統的上下文管理、工具設計原則,以及壓縮、優化、評估、安全等營運卓越主題。 此集合的主要價值在於其深度與實用性,不僅解釋「是什麼」,更深入探討「為什麼」與「怎麼做」。例如,它詳細解釋了多 Agent 系統中「子 Agent 主要用於隔離上下文」而非模擬角色,並提出了自管理上下文、KV 記憶共享(Latent Briefing)、壓縮控制剖析等進階技術。所有技能均為平台中立,可應用於 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 的新對話。

說明文件

情境工程的 Agent 技能集合

本集合提供結構化指引,透過有效的情境工程,建構生產級的 AI Agent 系統。

何時啟用

在以下情況啟用這些技能:

  • 從頭開始建構新的 Agent 系統
  • 優化現有 Agent 的效能
  • 除錯與情境相關的失敗
  • 設計多智能體架構
  • 為 Agent 建立或評估工具
  • 實作記憶與持久化層
  • 設計自主研究或評估檢測平台

技能地圖

基礎情境工程

理解情境基礎 情境不僅是提示文字——它是推理時語言模型可用的完整狀態,包括系統指令、工具定義、檢索文件、訊息歷史以及工具輸出。有效的情境工程意味著理解任務真正重要的資訊,並以最大化訊噪比的方式整理這些資訊。

辨識情境退化 語言模型在情境增長時表現出可預測的退化模式:資訊在情境中央受到的關注較少的「中央遺失」現象;優先關注開頭和結尾的 U 形注意力曲線;錯誤累積時發生的「情境中毒」;以及無關資訊淹沒相關內容時引起的「情境分心」。

架構模式

多智能體協調 生產級多智能體系統收斂於三種主要模式:具中央控制的主管/協調器架構、用於靈活交接的點對點群體架構,以及用於複雜任務拆分的階層結構。關鍵見解在於,子智能體的存在主要是為了隔離情境,而非模擬組織角色。

長時程提示 長時間運行的自主 Agent 和平行協作的成功與否取決於啟動提示。偽形式任務摘要指定成功條件、非計數結果、具有審計門控返回條件的持久化規則、努力下限、平行組合的多樣性策略以及污染防護,將形式化驗證的紀律以語言學方式應用於沒有機器可檢查成功條件的問題。在協作執行中,每個工作程序返回一個帶有名稱檢查的輸出合約,只有經證實的違規才會阻止返回。

記憶系統設計 記憶架構範圍從簡單的暫存區到複雜的時間知識圖譜。向量 RAG 提供語意檢索,但失去了關係資訊。知識圖譜保留了結構,但需要更多的工程投入。將檔案系統作為記憶的模式,可以在不塞滿情境視窗的情況下實現即時情境載入。

基於檔案系統的情境 檔案系統提供了一個統一的介面,用於儲存、檢索和更新幾乎無限的情境。關鍵模式包括用於卸載工具輸出的暫存區、用於長時程任務的計劃持久化、透過共享檔案進行的子智能體通訊,以及動態技能載入。Agent 使用 ls、glob、grep 和 read_file 進行目標式情境發現,通常在結構化查詢上表現優於語意搜尋。

託管 Agent 基礎設施 背景編碼 Agent 在遠端沙盒環境中運行,而非在本地機器上。關鍵模式包括在定期更新週期上重建的預建環境映像、用於即時啟動工作階段的溫暖沙盒池、用於工作階段持久化的檔案系統快照,以及支援協作 Agent 工作階段的多玩家功能。關鍵優化包括允許在 git 同步完成前讀取檔案(僅封鎖寫入)、在使用者開始輸入時進行預測性沙盒暖機,以及用於平行任務執行的自我繁衍 Agent。

工具設計原則 工具是確定性系統與非確定性 Agent 之間的合約。有效的工具設計遵循整合原則(偏好單一綜合工具而非多個狹窄工具)、在錯誤中返回上下文資訊、支援回應格式選項以提高 token 效率,並使用清晰的名稱空間。

營運卓越

情境壓縮 當 Agent 工作階段耗盡記憶體時,壓縮成為必要。正確的優化目標是每任務 token 數,而非每請求 token 數。使用明確的區塊(包括檔案、決策和後續步驟)進行結構化摘要,比激進壓縮保留更多有用資訊。在所有壓縮方法中,工件痕跡完整性仍然是最弱的維度。

情境優化 技術包括壓縮(在接近限制時摘要情境)、觀察遮蔽(以引用取代冗長的工具輸出)、前綴快取(跨請求重用 KV 區塊)以及策略性情境分割(將工作分配給具有隔離情境的子智能體)。

自管理情境 由模型(而非測試平台)決定哪些內容保留在其實時情境中:可編輯區域作為一個檔案暴露給模型,模型使用程式碼工具重寫該檔案,並在每次回合重新解析。測試平台維持不變量(固定的系統和任務前綴、角色折疊、編輯門、收據、確定性預算讀數、溢位時回滾)。在前綴快取下,編輯成本與編輯後的文字長度成比例,因此編輯會批次處理並考慮尾部位置;策略可以透過指令引導、發展為技能,或使用成功門控的效率獎勵進行訓練。

壓縮控制剖析 模型是否應該控制自身的壓縮,是根據每個模型測量的,而不是假設的。在單一測試平台上,針對一系列的硬性情境預算,分別進行測試平台驅動和模型驅動的壓縮,記錄行為檔案(介面採用率、每次呼叫的壓縮比、已封存內容的重新開啟率、首次壓縮時的情境填充量、對壓力警告的反應),並在兩個方向上校準時機指令。因為同一個指令可以約束一個過早壓縮的模型,但也可能與另一個根本不壓縮的模型一致。為每個模型和壓力狀態指派控制權,將壓縮暴露為具有已封存原始檔案的可逆折疊,並在模型或提示變更時重新認證。

潛在簡報(KV 記憶共享) 協調器-工作程序系統可能在監督者累積長軌跡但工作程序僅看到狹窄文字片段時,導致 token 量複合增加。潛在簡報使用任務引導的注意力(類似 Attention Matching 的壓縮),在工作程序模型的 KV 快取中壓縮協調器軌跡,因此當堆疊暴露工作程序 KV 狀態且模型相容時,工作程序可以在無需完整文字重播的情況下接收相關的潛在狀態。

評估框架 生產級 Agent 評估需要確定性檢查和多維度評分標準,涵蓋事實準確性、完整性、工具效率和流程品質。僅在結構、證據和評分標準數學有效後使用模型評審;將評審設計、成對比較和偏差緩解轉介給進階評估。

測試平台工程 可靠的自主 Agent 需要圍繞模型的明確運作循環:鎖定的指標、可編輯的表面、持久的日誌、新穎性檢查、回滾規則和人類審批邊界。測試平台防止 Agent 削弱評估器、在壓縮過程中丟失狀態,或將模糊目標轉化為不可審查的變更。

指令面安全性 盤點運行時作為指令載入的內容以及授予功能的內容。將提議的變更保持在活躍載入器之外,需要針對確切的有效變更進行獨立授權,並在合法任務完成之外,測試新的工作階段是否存在未經授權的狀態或功能變更。

自我改進循環 當測試平台本身成為優化目標時,適用的學科不同:遞迴自我改進、元測試平台搜尋、失敗驅動的有界自我編輯、演化 scaffold 搜尋以及情境機制演化。控制約束是經驗性的雙分割接受門、包含原始軌跡的檔案系統經驗存檔、每個可編輯表面之外的運行時強制約束,以及防止崩潰的多樣性保留。

開發方法論

專案開發 有效的 LLM 專案開發始於任務-模型契合度分析:在建構自動化之前,透過手動原型驗證任務是否適合 LLM 處理。生產管線遵循階段化、冪等架構(獲取、準備、處理、解析、渲染),並使用檔案系統狀態管理進行除錯和快取。具有明確格式規範的結構化輸出設計,實現可靠的解析。從最小架構開始,僅在證明必要時才增加複雜性。

認知架構

BDI 心智狀態 信念-期望-意圖模型提供了一種形式化方式,將結構化的外部情境轉化為 Agent 心智狀態。適用於理性代理、可解釋性,以及需要信念、目標和選擇行動之間可審計連結的系統。

核心概念

本集合圍繞四個核心主題組織。首先,情境基礎確立了什麼是情境、注意力機制如何運作,以及為什麼情境品質比數量更重要。其次,架構模式涵蓋了實現有效 Agent 系統的結構和協調機制。第三,營運卓越涉及優化、評估和測試平台可靠性。第四,開發方法論和認知架構涵蓋專案執行和形式化心智狀態建模。

實用指引

每個技能可以獨立使用或組合使用。從基礎開始,以建立情境管理心智模型。根據系統需求分支到架構模式。在優化生產系統時參考營運技能。

這些技能是平台中立的,適用於 Claude Code、Cursor 或任何支援自訂指令或類似技能結構的 Agent 框架。

整合

本集合與自身整合——技能彼此參考並建立在共享概念之上。基礎技能為所有其他技能提供背景。架構技能(多智能體、記憶、工具)可以組合用於複雜系統。營運技能(優化、評估)適用於使用基礎和架構技能建構的任何系統。

參考資料

本集合中的內部技能:

關於情境工程的外部資源:

  • 關於注意力機制和情境視窗限制的研究
  • 來自頂尖 AI 實驗室關於 Agent 系統設計的生產經驗
  • 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.

相關技能