Community编程与开发github.com

指令面安全

强化智能体运行环境,抵御持久性提示注入或对指令和权限的未授权更改。用于审计智能体自动加载的内容,为项目规则、技能、记忆或工具配置设计经过审核的激活机制,并测试重载、重启或委派后信任边界是否仍然有效。

指令面安全 是什么?

指令面安全技能专注于保护智能体运行环境免受持久性提示注入和未授权指令更改的影响。它通过映射实际运行环境加载指令、工具和权限的“有效面”,并强制执行评估和激活边界,来确保只有经过审核和批准的更改才能生效。该技能适用于编码、研究或多智能体运行时,可用于审计发现机制、设计批准流程、调查指令漂移以及评估环境重启或委派后的安全性。核心概念包括区分写操作与激活操作、基于摘要和签名的完整性验证、将提议暂存为数据以避免直接授权,以及从模型外部进行验证以检测意外更改。该技能提供了实用的分步审计指南、设计建议、指导原则以及常见陷阱(例如文件名列表可能遗漏有效输入、事后检查为时已晚、批准可能失效以及模型的拒绝可能掩盖状态更改)。它还引用了相关的研究证据(如 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 的新对话。

文档

指令面安全 是做什么的?

一条记忆条目、一次配置编辑或一次交接,都可能改变下一个智能体所依赖的权威内容。保护从可变内容到有效指令或能力之间的过渡。将文本警告视为纵深防御,而将可执行的决策置于运行环境中。

何时激活

  • 审计编码、研究或多智能体运行时如何发现指令、记忆、技能、工具或权限策略。
  • 为影响后续轮次、会话、工作进程或部署的变更设计批准边界。
  • 调查意外的指令漂移,或检查恢复是否还原了有效的运行时状态。
  • 评估在重载、重启或交接过程中,遏制与合法任务完成的情况。

不适用于通用工具设计、没有指令或权限边界的常规编辑,或通用应用程序安全。请使用 context-degradation 处理意外漂移,使用 self-managed-context 处理对模型实时语境的有界编辑。使用 harness-engineering 处理通用优化器和评估器治理。

核心概念

  • 有效面。 所选运行时实际用于设置指令、工具、可执行行为或权限的输入。包括每个来源的角色、作用域、优先级、解析器或导入、写入器以及激活触发器。同一个文件在一个运行时中可能是数据,在另一个运行时中则可能是加载的指导。
  • 写入与激活。 写入更改存储状态。激活更改智能体消耗或能够执行的内容。两者都需要强制执行边界。仓库审查对合并进行把关,但可能使工作副本的激活完全暴露在外。
  • 完整性与授权。 摘要标识内容,经过验证的签名标识签名者。独立的策略必须授权该主体、修订版本、目标和效果。一条交接、记忆条目或审查说明携带证据和建议。它赋予的任何权威必须来自经过身份验证的委托封装和接收方自身的运行时策略。
  • 证据范围。 Mind Viruses 预印本在其测试工具中观察到持久指令和转发行为。提示警告在有限实验中减少了传播,但仍有残留的第一跳行为。在解读论文或比较干预措施时,请阅读研究证据。

实践指导

  1. 映射一个具体的运行时。 明确构建、配置文件、工作空间根目录和有效的智能体角色。跟踪从启动到恢复、目录更改、工具发现以及(如果支持)委派期间的加载器。对于每个承载权威的输入,记录谁可以生成或替换它、谁消耗它、何时生效以及什么阻止了未授权的更改。标记未知条目。使用加载器诊断或从受信任的检查环境中检查已安装的实现。
  2. 将建议暂存为数据。 保持普通任务输出和建议可写。保持暂存的更改不在承载权威的加载路径中。工作进程仍然可以通过仅限数据的索引检索带来源标签的笔记或暂存建议。将候选文本作为引用的数据进行审查。仅在必要时使用独立的受限预览。在暂存中不授予任何权威。
  3. 批准实际变更。 比较候选对象与最后批准的配置,包括作用域、能力和导入依赖项的差异。将绑定批准到确切的制品或解析后的快照、目标配置和作用域、活动基线和策略修订版,以及经授权的批准者。使用在候选对象之外以及在智能体可写状态之外进行验证的批准或签名。
  4. 中介激活。 使用运行时、启动器或外部策略边界来精确地激活经过审查的输入。在首次使用时以及每次支持的有效输入发生变化时进行验证。保持激活时使用的文件或不可变快照与已验证的内容一致。拒绝过期或未绑定的更改。当主机无法强制执行此操作时,将运行时限制在批准的输入集内,或明确报告剩余的暴露面。
  5. 从模型外部进行验证。 观察加载了哪些内容以及哪些能力可用,然后执行一个有界的行为检查和一个授权任务。合规性声明是诊断性的。对于意外的更改,暂停受影响的启动或敏感操作,保存相关证据,并通过可信路径恢复到已知良好的输入和设置。从干净的会话中进行验证,并考虑受影响的缓存和已恢复的状态。

对于审计,提供有效面映射、证据链接和未解决的路径。对于设计,确定执行组件、其批准合约以及恢复路径。使用运行时审查与晋升参考获取清单和批准记录,或作为提示与实际控制措施一起使用。使用评估协议进行防御性实验。

示例

一个研究 worker 提出的格式偏好可以作为数据记录保留,并在样本文档上进行评估。父进程可以继续在其现有指令下编译报告。在将该偏好设为工作空间默认值之前,策略授权的审查者批准确切的修订版本和范围,下一个干净的会话记录其加载的修订版本。

一个项目在合并规则更改之前检查审批。其交互式运行时也会读取工作副本规则。为发布和本地激活分别记录边界,然后在加载时验证后者。成功的合并检查仅确认了发布结果。

指导原则

  • 当变更被暂存或阻止时,保持在上一个批准状态下合法工作的能力。返回受影响的面、决策、证据和下一个允许的操作。
  • 将控制措施与效果匹配。保护任何授予权限或自动引导未来智能体的内容。保持常规的临时记忆和任务制品作为数据可用,前提是其加载器和权限支持这种区分。
  • 使用接收方的有效权限来审计委派的工作。在交接时携带来源和作用域,并要求对敏感效果进行独立授权。

陷阱

  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.

相关技能