CommunityCoding & Developmentgithub.com

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.

What is instruction-surface-security?

instruction-surface-security is a Claude Code agent skill that 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.

Works with~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 Coding & Development skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Instruction-Surface Security

A memory entry, configuration edit, or handoff can change what the next agent treats as authoritative. Protect the transition from mutable content to effective instructions or capabilities. Treat text warnings as defense in depth and put enforceable decisions in the runtime.

When to Activate

  • Audit how a coding, research, or multi-agent runtime discovers instructions, memory, skills, tools, or permission policy.
  • Design an approval boundary for changes that affect later turns, sessions, workers, or deployment.
  • Investigate unexpected instruction drift or check whether a recovery restored the effective runtime state.
  • Evaluate containment and legitimate task completion across a reload, restart, or handoff.

Do not activate for general tool design, routine edits with no instruction or privilege boundary, or generic application security. Use context-degradation for accidental drift and self-managed-context for bounded edits to the model's live context. Use harness-engineering for general optimizer and evaluator governance.

Core Concepts

  • Effective surface. The inputs the selected runtime actually uses to set instructions, tools, executable behavior, or permissions. Include each source's role, scope, precedence, resolvers or imports, writers, and activation triggers. The same file can be data in one runtime and loaded guidance in another.
  • Write and activation. A write changes stored state. Activation changes what an agent consumes or can do. Enforce both boundaries. A repository review gates merge and may leave working-copy activation entirely exposed.
  • Integrity and authorization. A digest identifies content and a verified signature identifies a signer. An independent policy must authorize that principal, revision, target, and effect. A handoff, memory entry, or review note carries evidence and proposals. Any authority it conveys must come from the authenticated delegation envelope and the recipient's own runtime policy.
  • Scope of the evidence. The Mind Viruses preprint observes persistent instructions and onward transfer in its test harnesses. The prompt warning reduced spread in a bounded experiment, with residual first-hop behavior. Read the research evidence when interpreting the paper or comparing interventions.

Practical Guidance

  1. Map one concrete runtime. Pin build, profile, workspace root, and effective agent role. Trace loaders from startup through resume, directory changes, tool discovery, and delegation where supported. For each authority-bearing input, record who can produce or replace it, what consumes it, when it takes effect, and what blocks an unauthorized change. Mark unknown entries. Use loader diagnostics or inspect the installed implementation from a trusted inspection environment.
  2. Stage proposals as data. Keep ordinary task outputs and proposals writable. Keep staged changes out of authority-bearing load paths. Workers can still retrieve source-labeled notes or staged proposals through a data-only index. Review candidate text as quoted data. Use a separate restricted preview only when needed. Time in staging grants no authority.
  3. Approve the effective change. Compare the candidate with the last approved configuration, including differences in scope, capabilities, and imported dependencies. Bind approval to the exact artifact or resolved snapshot, target profile and scope, active base and policy revision, and authorized approver. Use approvals or signatures verified outside the candidate and outside the agent's writable state.
  4. Mediate activation. Use the runtime, launcher, or an external policy boundary to activate precisely the reviewed inputs. Verify at first use and at each supported change of effective inputs. Keep the files or immutable snapshot used at activation consistent with what was verified. Reject stale or unbound changes. Where the host cannot enforce this, constrain the runtime to an approved input set or report the remaining exposure explicitly.
  5. Verify from outside the model. Observe what loaded and which capabilities were available, then exercise a bounded behavioral check and an authorized task. A statement of compliance is diagnostic. For an unexpected change, pause affected launches or sensitive actions, preserve relevant evidence, and restore known-good inputs and settings through a trusted path. Verify from a clean session with affected caches and resumed state accounted for.

For an audit, deliver the effective surface map, evidence links, and unresolved paths. For a design, identify the enforcing component, its approval contract, and a recovery path. Use the runtime review and promotion reference for an inventory and approval record or a prompt to use alongside actual controls. Use the evaluation protocol for defensive experiments.

Examples

A formatting preference proposed by a research worker can be kept as a data record and evaluated on a sample document. The parent can continue compiling the report under its existing instructions. Before making the preference a workspace default, a policy-authorized reviewer approves the exact revision and scope, and the next clean session records the revision it loaded.

A project checks approvals before merging rule changes. Its interactive runtime also reads working-copy rules. Record separate boundaries for publishing and local activation, then verify the latter at load time. A successful merge check establishes only the publishing result.

Guidelines

  • Preserve legitimate work under the last approved state when a change is staged or blocked. Return the affected surface, decision, evidence, and next permitted operation.
  • Match controls to effects. Protect anything that grants authority or automatically steers future agents. Keep regular scratch memory and task artifacts available as data where their loader and permissions support that distinction.
  • Audit delegated work using the recipient's effective permissions. Carry source and scope across the handoff, and require independent authorization for sensitive effects.

Gotchas

  1. Filename lists miss effective inputs. Nested rules, resolved imports, plugin state, dynamic tool registration, and resumed context can change what is in force. Observe the actual loader.
  2. Post-start checks arrive late. A diff or canary can detect a change after admission. Gate the load or capability use before it takes effect.
  3. Approval can outlive its review. Replacing a path or changing an import, scope, or policy can invalidate approval even when the primary file's bytes match.
  4. A refusal can hide a failure. The model may report that it refused while a different writer already changed state. Check trusted lifecycle events and state, including recovery and ordinary task completion.

Integration

Use harness-engineering to protect the controller and logs, multi-agent-patterns for delegation topology and role allocation, and evaluation for deterministic graders and regression coverage. This skill owns the boundary between proposed content and authority during load or use.

References

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.

Related Skills