Agent skill

Prompt Injection Defense

by seb1n in seb1n/awesome-ai-agent-skills

Threat-model and harden AI agents, RAG systems, assistants, and tool-using workflows against direct, indirect, stored, cross-agent, and multimodal prompt injection.

MITAuto-check passedSecurity

Install Prompt Injection Defense

skills CLI
$ npx skills add seb1n/awesome-ai-agent-skills --skill prompt-injection-defense -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install seb1n/awesome-ai-agent-skills prompt-injection-defense --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agent-security/prompt-injection-defense .claude/skills/prompt-injection-defense && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
prompt-injection-defense
GitHub stars
206
Token cost
~2.6k tokens
SKILL.md length
1,313 words
Files
4 (incl. scripts, references)
Skills in repo
101
Repo updated
First seen
Licence
MIT

At a glance

Threat-model and harden AI agents, RAG systems, assistants, and tool-using workflows against direct, indirect, stored, cross-agent, and multimodal prompt injection.

  • Works in 7 steps: Map instructions, data, authority, and… → Define enforceable invariants → Reduce exposed authority → …
  • Reviewing an agent architecture
  • SKILL.md covers Inputs, Output contract, Workflow and Authorization and safety…, plus 3 more sections
  • Runs Python scripts from its folder

What it does

Prompt Injection Defense is an agent skill from seb1n/awesome-ai-agent-skills. Threat-model and harden AI agents, RAG systems, assistants, and tool-using workflows against direct, indirect, stored, cross-agent, and multimodal prompt injection. Use when reviewing an agent architecture, isolating untrusted content, constraining tools and egress, protecting secrets, adding injection-focused tests, investigating a suspected injection incident, or documenting residual prompt-injection risk.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts and reference files (for example `agents/openai.yaml`, `references/defense-patterns.md` and `scripts/audit_boundary_manifest.py`).

It sits in Security, covering Prompt injection and agent security and Threat modeling. The repository describes itself as: 103 ready-to-use AI agent skills for Claude Code, OpenAI Codex, Gemini CLI, Cursor, GitHub Copilot, Windsurf, and other Agent Skills-compatible tools. Complete SKILL.md… The licence is MIT.

When your agent uses it

  • Reviewing an agent architecture
  • Isolating untrusted content
  • Constraining tools and egress
  • Protecting secrets

Example prompts

  • “/prompt-injection-defense”

Requirements

  • Python 3

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Map instructions, data, authority, and sinks
  2. Define enforceable invariants
  3. Reduce exposed authority
  4. Separate control from untrusted content
  5. Validate every transition
  6. Test with safe adversarial cases
  7. Operate and recover

What it can do on your machine

Read from SKILL.md and the folder at commit 75865a5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Prompt Injection Defense loads about 2.6k tokens when it runs, and up to ~4.9k if it reads all its reference files. Until then it costs about 109 tokens; SKILL.md has 1,313 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~109
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from seb1n/awesome-ai-agent-skills at commit 75865a5, republished under its MIT licence (© seb1n). 1,313 words, ~2,637 tokens.

Download SKILL.mdSave it as .claude/skills/prompt-injection-defense/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
prompt-injection-defense
description
Threat-model and harden AI agents, RAG systems, assistants, and tool-using workflows against direct, indirect, stored, cross-agent, and multimodal prompt injection. Use when reviewing an agent architecture, isolating untrusted content, constraining tools and egress, protecting secrets, adding injection-focused tests, investigating a suspected injection incident, or documenting residual prompt-injection risk.

Prompt Injection Defense

Design for compromise of model reasoning. Prompt text and classifiers can reduce attack success, but they do not create a reliable security boundary. Keep consequential authority, authorization, validation, and policy enforcement outside the model.

Inputs

Collect or infer, and label assumptions for:

  • Agent purpose, system/developer instructions, models, memory, and orchestration
  • Every input source, including users, web pages, email, documents, images, audio, tool results, RAG, and other agents
  • Tool list, privileges, identities, targets, write effects, and network egress
  • Secrets, private data, system prompts, policy data, and other protected assets
  • Output sinks such as UI rendering, code execution, messages, databases, and downstream agents
  • Authorization model, human gates, monitoring, incident history, and risk tolerance
  • Representative benign tasks and a safe evaluation environment

Do not request production secrets or malicious artifacts in chat. Use redacted samples or synthetic fixtures.

Output contract

Deliver:

  1. A data-flow and trust-boundary map covering protected assets, all modalities, sinks, memory stores, agent hops, approved destinations, and credential boundaries
  2. A threat model listing protected assets, attacker-controlled channels, injection paths, and security invariants
  3. A prioritized defense plan that maps each path to preventive, limiting, detective, and recovery controls, each marked missing, planned, implemented, or verified
  4. Code or configuration changes only within the user's authorized scope
  5. A regression suite with safe direct, indirect, stored, encoded, cross-agent, and multimodal cases as applicable
  6. Verification evidence, observed failures, and metrics rather than a blanket claim of prevention
  7. Residual risk, operational monitoring, and an incident containment/recovery plan

Describe the architecture in a JSON boundary manifest and lint it with scripts/audit_boundary_manifest.py. Record every control's enforcement point, owner, evidence IDs, test IDs, and expiry when time-limited. A passing structural lint is not evidence that controls work. Read references/defense-patterns.md for attack paths, control placement, and verification patterns.

Workflow

1. Map instructions, data, authority, and sinks

Trace content from origin through parsing, retrieval, model context, memory, tools, renderers, output sinks, and downstream agents. Mark every attacker-controlled or mixed-trust source. Include hidden document text, metadata, code comments, OCR, images, audio, redirects, tool descriptions, and persisted memory. Inventory approved and denied destinations, each credential's holder/audience/storage boundary, and every point where content or authority crosses agents.

List assets and consequences: secret disclosure, private-data access, unauthorized tool calls, external communications, transactions, code execution, policy bypass, corrupted memory, or misleading output.

2. Define enforceable invariants

Express requirements in terms a deterministic component can enforce, for example:

  • Retrieved content cannot grant permissions or change the tool allowlist.
  • A support agent cannot read records outside the authenticated tenant.
  • An email body cannot determine recipients for a send operation.
  • Model output cannot execute as code or HTML without validation and safe handling.
  • Secrets unavailable to the task never enter model context.

If an invariant exists only as a prompt instruction, record it as weak and move enforcement to code, policy, isolation, or human control.

3. Reduce exposed authority

Remove unused tools, broad tokens, ambient credentials, generic shells, arbitrary URL fetches, raw SQL, and unrestricted file access. Split read from write and preview from commit. Restrict identities by tenant, object, action, fields, time, and destination.

Keep secrets outside model context and tool results. Add network and data egress allowlists. Sandbox code, parsers, browsers, and file processing. Require independent authorization and, where warranted, action-specific approval immediately before consequential effects. A tool classified critical must not have confirmation mode none.

4. Separate control from untrusted content

Treat untrusted content as quoted data with provenance, never as authority. Preserve source boundaries through retrieval and agent handoffs. Use structured typed messages instead of concatenating instructions and data. Limit retrieved content, strip active content when safe, normalize supported formats, and render outputs with context-appropriate escaping.

Instruction hierarchy, delimiters, reminders, content classifiers, and injection detectors can be defense-in-depth signals. Do not depend on any of them as the sole control.

5. Validate every transition

Validate tool arguments against narrow schemas and policy before execution. Derive sensitive target identifiers from trusted application state rather than untrusted text where possible. Reauthorize at execution time. Validate and encode model outputs for their destination; never send them directly to shells, SQL, templates, URLs, or privileged APIs.

For multi-agent systems, authenticate senders, constrain delegation depth and budgets, pass structured claims with provenance, and recalculate permissions at each hop. Never inherit the broadest upstream privilege implicitly.

6. Test with safe adversarial cases

Use an isolated environment, synthetic accounts, benign canary secrets, inert destinations, and non-destructive tools. Test at least:

  • Direct attempts to override instructions or elicit protected data
  • Indirect instructions embedded in retrieved pages, email, documents, tool results, metadata, and memory
  • Obfuscation, encoding, language changes, splitting across turns, and repeated attempts
  • Cross-agent delegation and tainted summaries
  • Hidden or alternate-modal content when images, audio, PDFs, HTML, or OCR are supported
  • Tool-argument manipulation, target substitution, data exfiltration, and unauthorized egress
  • False positives on representative benign content and normal task completion

Measure invariant violations, unauthorized tool attempts, canary exposure, successful benign tasks, false-positive rate, and containment behavior. A detector pass rate alone is insufficient. Promote a control to verified only when implementation evidence and named test evidence both exist; use implemented when code exists but the relevant tests have not established behavior.

Show full SKILL.md (456 more words)Show less
7. Operate and recover

Log provenance, policy decisions, tool/target metadata, denials, and anomalous sequences without storing secrets or unnecessary content. Alert on canary access, repeated policy failures, new tool exposure, cross-tenant attempts, and unexpected egress.

For a suspected incident, stop or isolate the affected workflow, disable high-risk tools and egress, revoke or rotate exposed credentials, quarantine malicious sources, preserve redacted evidence, identify persisted memory/vector entries and downstream effects, restore clean state, and rerun regression tests before re-enabling access.

Authorization and safety boundaries

  • Do not test payloads against production, third-party, or user systems without explicit target-specific authorization.
  • Do not trigger real transactions, messages, deletions, access changes, malware, or data exfiltration; use inert canaries and synthetic destinations.
  • Never place real secrets, personal data, privileged system prompts, or live tokens in test corpora or logs.
  • Do not claim that prompt injection has been eliminated. State tested scope, model/configuration, evidence, limitations, and residual risk.
  • Do not silently delete potentially compromised memory, records, or evidence; quarantine first and follow the owner's retention and incident policy.
  • Stop testing and escalate if scope is uncertain, a canary reaches an unintended system, real sensitive data appears, or an unexpected external effect occurs.

Verification and recovery

Before completion, confirm that every protected asset, untrusted path, sink, memory store, agent hop, destination, and credential boundary is represented; every consequential effect has a non-model authority check; critical tools have confirmation; exposed privileges are minimized; and regression tests exercise both attack resistance and benign-task utility. Do not turn unknowns into unsupported all-true assertions: retain missing and planned controls as visible gaps. Re-run tests after model, prompt, parser, retrieval, tool, permission, or orchestration changes.

If a control causes unacceptable task failure, roll back that control in isolation, keep higher-risk tools disabled, preserve the failing case, and redesign the boundary. Do not restore broad authority simply to improve the success rate.

Realistic examples

Email triage agent

Treat subjects, bodies, attachments, and quoted threads as untrusted data. Let the model classify and draft, but derive mailbox and tenant from authenticated state. Separate draft from send, restrict recipient domains, require exact-message approval for external sends, and test an attachment containing an inert instruction to reveal a canary or change the recipient.

Research agent with web access

Run browsing with no access to internal secrets. Allowlist required destinations, strip active content, retain page provenance, and prevent page text from expanding tools or changing the research goal. Test hidden page text, a malicious tool result, encoded instructions, and a normal page containing security-related phrases to measure false positives.

Completion check

Finish only when architecture, controls, tests, and recovery cover the full data flow; evidence shows protected invariants hold in the tested environment; benign utility remains measured; and residual risk plus unverified surfaces are explicit.

© seb1n, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, references) in agent-security/prompt-injection-defense of seb1n/awesome-ai-agent-skills.

  • SKILL.md
  • agents/openai.yaml
  • references/defense-patterns.md
  • scripts/audit_boundary_manifest.py

Open the folder on GitHubat commit 75865a5

Compare with similar skills

Prompt Injection Defense next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Prompt Injection Defense compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Prompt Injection Defense this skillseb1n/awesome-ai-agent-skills206—~2.6kAutomated safety check: PassMIT
Forensifyalexgreensh/repo-forensics190—~2.5kAutomated safety check: NotesCustom licence
Threat Modelingdralgorhythm/claude-agentic-framework125—~581Automated safety check: PassNone
Csono-session/pstack136—~12kAutomated safety check: NotesMIT
Securing AI Systemstrilwu/secskills157—~2.9kAutomated safety check: PassMIT
Securitytelagod/code-abyss244—~907Automated safety check: PassMIT

Similar skills

  • Forensify

    alexgreensh/repo-forensics

    Cross-agent self-inspection of your AI-agent stack. An agent skill from alexgreensh/repo-forensics.

    190 GitHub stars~2.5k tokensUpdated 14 days ago
    SecurityAuto-check: notes
  • Threat Modeling

    dralgorhythm/claude-agentic-framework

    Finds security threats in a design with a STRIDE pass per component, rates severity and records fixes, with extra checks for AI agent and tool risks.

    125 GitHub stars~581 tokensUpdated 2 mo ago
    SecurityAuto-check passed
  • Cso

    no-session/pstack

    Chief Security Officer mode. An agent skill from no-session/pstack.

    136 GitHub stars~12k tokensUpdated 6 mo ago
    SecurityAuto-check: notes
  • Securing AI Systems

    trilwu/secskills

    Assess and harden LLM applications and agentic systems against prompt injection, tool misuse, excessive agency, memory poisoning, RAG data leakage, and model supply-chain risk, mapped to the OWASP…

    157 GitHub stars~2.9k tokensUpdated 1 mo ago
    SecurityAuto-check passed
  • Security

    telagod/code-abyss

    Defensive security engineering judgment, distilled from a stronger model - invoke when THREAT MODELING a system or feature; making security-relevant design decisions (auth, crypto, trust boundaries…

    244 GitHub stars~907 tokensUpdated 2 mo ago
    SecurityAuto-check passed
  • Skill Scanner

    getsentry/skills

    Official

    Scan agent skills for security issues. An agent skill from getsentry/skills.

    1k GitHub starsUsed in 4 repos~2.5k tokens
    SecurityAuto-check: warnings

More from seb1n/awesome-ai-agent-skills

All 101 skills in this repo
  • Agent Red Teaming

    seb1n/awesome-ai-agent-skills

    Plan, execute, document, and retest authorized security assessments of AI agents and multi-agent workflows using safe adversarial cases, synthetic identities, canaries, and evidence-based findings.

    206 GitHub stars~2.8k tokensUpdated 2 mo ago
    Auto-check passed
  • Eu AI Act Readiness

    seb1n/awesome-ai-agent-skills

    Build a preliminary, evidence-based EU AI Act readiness assessment across AI-system inventory, territorial scope, operator roles, prohibited-practice screening, risk classification, transparency…

    206 GitHub stars~3.3k tokensUpdated 2 mo ago
    Auto-check passed
  • Human In The Loop

    seb1n/awesome-ai-agent-skills

    Design and verify auditable human oversight, approval gates, escalation paths, and safe state transitions for AI agent workflows.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • MCP Server Building

    seb1n/awesome-ai-agent-skills

    Design, implement, harden, and verify Model Context Protocol (MCP) servers with precise tool contracts, least-privilege authorization, safe transports, structured errors, and interoperability tests.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • PDF Processing

    seb1n/awesome-ai-agent-skills

    Inspect, extract, OCR, create, merge, split, reorder, rotate, annotate, fill, redact, compress, secure, and verify PDF documents while preserving source files and visual fidelity.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Skill Supply Chain Audit

    seb1n/awesome-ai-agent-skills

    Audit agent skills, plugins, prompts, manifests, scripts, dependencies, and bundled assets for provenance, prompt-injection, permission, execution, exfiltration, persistence, and update risk.

    206 GitHub stars~2.4k tokensUpdated 2 mo ago
    Auto-check passed

Categories

Questions about Prompt Injection Defense

What does Prompt Injection Defense do?

Threat-model and harden AI agents, RAG systems, assistants, and tool-using workflows against direct, indirect, stored, cross-agent, and multimodal prompt injection. Prompt Injection Defense is an agent skill from seb1n/awesome-ai-agent-skills. Threat-model and harden AI agents, RAG systems, assistants, and tool-using workflows against direct, indirect, stored, cross-agent, and multimodal prompt injection.

When should I use Prompt Injection Defense?

Prompt Injection Defense fits situations like: reviewing an agent architecture; isolating untrusted content; constraining tools and egress; protecting secrets.

How do I install Prompt Injection Defense in Claude Code?

Run `npx skills add seb1n/awesome-ai-agent-skills --skill prompt-injection-defense -a claude-code`. Or copy the skill folder (agent-security/prompt-injection-defense in seb1n/awesome-ai-agent-skills) into .claude/skills/prompt-injection-defense in your project. Claude Code loads it when a task matches its description.

How do I install Prompt Injection Defense in Codex?

Run `npx skills add seb1n/awesome-ai-agent-skills --skill prompt-injection-defense -a codex`. Or copy the skill folder (agent-security/prompt-injection-defense in seb1n/awesome-ai-agent-skills) into .agents/skills/prompt-injection-defense in your project. Codex loads it when a task matches its description.

Can I use Prompt Injection Defense in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add seb1n/awesome-ai-agent-skills --skill prompt-injection-defense -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/prompt-injection-defense, .gemini/skills/prompt-injection-defense, .github/skills/prompt-injection-defense and .opencode/skills/prompt-injection-defense in your project.

What does Prompt Injection Defense need to run?

Going by SKILL.md and its folder, Prompt Injection Defense needs Python for the scripts in its folder. Our summary lists: Python 3.

Does Prompt Injection Defense access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Prompt Injection Defense safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Prompt Injection Defense use?

Prompt Injection Defense is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Prompt Injection Defense use?

About 2.6k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.3k tokens, read only when the agent opens those files.

What are the alternatives to Prompt Injection Defense?

Skills that share tags, products or a category with Prompt Injection Defense: Forensify (alexgreensh/repo-forensics, 190 stars), Threat Modeling (dralgorhythm/claude-agentic-framework, 125 stars), Cso (no-session/pstack, 136 stars) and Securing AI Systems (trilwu/secskills, 157 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Prompt Injection Defense?

seb1n (a GitHub user) maintains it in seb1n/awesome-ai-agent-skills, which has 206 GitHub stars. The repository holds 101 skills in this directory. The repository was last updated on August 9, 2026.

Source: seb1n/awesome-ai-agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.