Community程式設計與開發github.com

指令表面安全性

強化代理執行時期,防止持續性提示注入或對指令與權限的未經授權變更。可用於稽核代理自動載入的內容、設計經過審查的啟用機制、管理專案規則、技能、記憶體或工具設定,並測試信任邊界在重新載入、重新啟動或委派後是否仍然有效。

指令表面安全性 是什麼?

這項「指令表面安全性」技能專注於保護 AI 代理執行時期,防止因持續性提示注入或未經授權的指令、權限變更而導致的安全漏洞。其核心概念是區分「寫入」(改變儲存狀態)與「啟用」(改變代理實際消費或擁有的能力),並對兩者都實施強制邊界。該技能提供一套實用方法,包括映射具體執行時期的載入鏈、將提議內容暫存為資料(不授予權限)、為確切的生效變更綁定審核、在啟用時進行中介驗證,以及從模型外部進行獨立驗證。它支援多種代理執行時期,如編碼、研究或多人代理系統,並適用於稽核、設計安全架構、調查指令漂移或評估代理重載後的行為。技能也提及相關研究證據(Mind Viruses 預印本)與防禦性評估協議,並與其他技能如 `harness-engineering` 和 `multi-agent-patterns` 整合使用。

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

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

指令表面安全性(Instruction-Surface Security)

記憶體條目、設定編輯或交接,都可能改變下一個代理視為權威的內容。保護從可變內容到有效指令或能力的轉換過程。將文字警告視為深度防禦的一環,並在執行時期內實施可強制執行的決策。

何時啟用

  • 稽核編碼、研究或多人代理執行時期如何發現指令、記憶體、技能、工具或權限政策。
  • 為影響後續回合、工作階段、工作單元或部署的變更設計核可邊界。
  • 調查非預期的指令漂移,或檢查復原作業是否恢復了有效的執行時期狀態。
  • 評估在重新載入、重新啟動或交接過程中的隔離性以及合法任務完成度。

請勿為一般工具設計、無關指令或權限邊界的例行編輯,或一般的應用程式安全性啟用此技能。對於意外漂移,請使用 context-degradation;對於模型即時上下文的有限編輯,請使用 self-managed-context。對於一般的最佳化器和評估器治理,請使用 harness-engineering。

核心概念

  • 有效表面(Effective surface)。 所選執行時期實際用於設定指令、工具、可執行行為或權限的輸入。涵蓋每個來源的角色、範圍、優先順序、解析器或匯入項目、寫入器以及啟用觸發器。同一個檔案在一個執行時期中是資料,在另一個執行時期中可能是已載入的指導方針。
  • 寫入與啟用(Write and activation)。 寫入會改變儲存狀態。啟用則會改變代理消費或能夠執行的內容。兩者都必須強制實施邊界。儲存庫審查會控管合併,但可能完全暴露工作副本的啟用過程。
  • 完整性與授權(Integrity and authorization)。 摘要(digest)用於識別內容,而經過驗證的簽章用於識別簽署者。獨立政策必須授權該主體、版本、目標與效果。交接、記憶體條目或審查註記承載了證據與提案。其所傳達的任何權限都必須來自經過驗證的委派封裝以及接收方自身的執行時期政策。
  • 證據範圍(Scope of the evidence)。 Mind Viruses 預印本在其測試框架中觀察到持續性指令與向前傳遞的行為。提示警告在有限的實驗中減少了擴散,但仍存在殘留的首次跳躍行為。在解讀論文或比較干預措施時,請閱讀研究證據。

實用指導原則

  1. 映射具體的執行時期。 確定建置版本、設定檔、工作區根目錄以及有效的代理角色。追蹤從啟動到恢復、目錄變更、工具發現以及(若支援)委派的載入器。對於每個承載權限的輸入,記錄誰可以產生或取代它、誰消費它、何時生效,以及什麼會阻止未經授權的變更。標記未知的條目。使用載入器診斷或從可信的檢查環境檢查已安裝的實作。
  2. 將提案暫存為資料。 保持一般任務輸出與提案為可寫入狀態。將暫存的變更保留在承載權限的載入路徑之外。工作單元仍可透過純資料索引檢索帶有來源標籤的筆記或暫存提案。將候選文字作為引用的資料進行審查。僅在必要時使用獨立的受限預覽。在暫存階段不授予任何權限。
  3. 核准生效的變更。 將候選變更與上次核准的設定進行比較,包括範圍、能力以及匯入依賴項的差異。將核准綁定到確切的成品或解析後的快照、目標設定檔與範圍、有效基礎與政策版本,以及授權的核准者。使用在候選內容外部以及在代理可寫入狀態外部驗證的核准或簽章。
  4. 中介啟用過程。 使用執行時期、啟動器或外部政策邊界來精確啟用經過審查的輸入。在首次使用時以及每次支援的有效輸入變更時進行驗證。確保啟用時使用的檔案或不可變快照與驗證過的內容一致。拒絕過時或未綁定的變更。若主機無法強制執行此點,請將執行時期限制為一組經核准的輸入,或明確報告剩餘的暴露風險。
  5. 從模型外部驗證。 觀察載入了哪些內容以及哪些能力可用,然後執行一次受限的行為檢查與一次授權的任務。合規聲明僅具診斷價值。對於非預期的變更,暫停受影響的啟動或敏感操作,保留相關證據,並透過可信路徑還原已知良好的輸入與設定。從一個乾淨的工作階段進行驗證,並考量受影響的快取與恢復的狀態。

對於稽核,交付有效表面地圖、證據連結以及未解決的路徑。對於設計,識別強制執行元件、其核准合約以及復原路徑。使用執行時期審查與晉升參考作為盤點與核准記錄,或作為與實際控制措施一同使用的提示。使用評估協議進行防禦性實驗。

範例

一個由研究工作單元提出的格式偏好設定,可以作為資料記錄保存,並在一個文件樣本上進行評估。父代理可以繼續在其現有指令下編譯報告。在將該偏好設定設為工作區預設值之前,需由受到政策授權的審查者核准確切的版本與範圍,然後下一個乾淨的工作階段會記錄其載入的版本。

一個專案會在合併規則變更前檢查核准。其互動式執行時期也會讀取工作副本的規則。為發佈與本地啟用分別記錄獨立的邊界,然後在載入時驗證後者。成功的合併檢查僅確立了發佈結果。

指導方針

  • 當變更被暫存或阻止時,保留在上次核准狀態下的合法工作。回傳受影響的表面、決策、證據以及下一步允許的操作。
  • 使控制措施與效果相匹配。保護任何授予權限或自動引導未來代理的項目。在其載入器與權限支援此區分的情況下,保持一般的暫存記憶體與任務成品可作為資料存取。
  • 使用接收方的有效權限來稽核委派的工作。在交接過程中傳遞來源與範圍,並要求對敏感效果進行獨立授權。

注意事項

  1. 檔案名稱列表會遺漏有效輸入。 巢狀規則、已解析的匯入項、外掛狀態、動態工具註冊以及已恢復的上下文都可能改變實際生效的內容。請觀察實際的載入器。
  2. 啟動後檢查來得太晚。 差異比對或金絲雀測試可以在允許進入後才偵測到變更。請在變更生效前,先控管載入或能力的使用。
  3. 核准可能比審查存活得更久。 更換路徑或變更匯入項、範圍或政策,即使主要檔案的位元組相同,也可能使核准失效。
  4. 拒絕可能隱藏失敗。 模型可能報告它拒絕了某請求,但另一個寫入器可能已經改變了狀態。請檢查可信的生命週期事件與狀態,包括復原與一般任務完成。

整合

使用 harness-engineering 來保護控制器與日誌,使用 multi-agent-patterns 來處理委派拓撲與角色分配,使用 evaluation 來進行確定性評分與回歸覆蓋。本技能負責管理在載入或使用期間,提案內容與權限之間的邊界。

參考資料

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.

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.

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.

self-managed-context

This skill should be used when a model gets read-write control over its own live context window instead of a harness-scheduled compaction policy: the context exposed as an editable file the model rewrites with code tools, model-driven eviction and in-place updates, the harness invariants that keep self-editing safe (pinned prefix, edit gate, edit receipts, budget readouts, rollback on overflow), the prefix-cache cost of mid-context edits, and steering or training the model's own context-editing strategy. Route note content and fixed-threshold summarization to context-compression, cache-stable layout under harness control to context-optimization, file offloading to filesystem-context, and loop governance to self-improvement-loops.

tool-design

This skill should be used for the tool-interface layer of an agent system specifically: writing tool descriptions agents can route on, designing tool schemas and response formats, naming conventions, actionable error recovery messages, MCP server design, tool-set consolidation, and deciding when to add or remove an individual tool. Use this when the unit of work is a single tool or a set of tools. Route project-shape, pipeline architecture, and task-model-fit decisions to project-development; route deciding whether to introduce sub-agents to multi-agent-patterns.

相關技能