claude-hooks: Skill for Claude Code

.claude/skills/prompt-injection-defender/SKILL.md

prompt-injection-defender is a skill for Claude Code from lasso-security/claude-hooks. It costs 0 tokens per session (958 once invoked), scanned B, original, MIT.

A security add-on that scans outputs from tools such as file reads, web requests, shell commands, and integrations for indirect prompt-injection attempts. These are hidden instructions in retrieved content that try to change an agent's behavior.

In plain words
What is it for?
Monitoring tool output for suspicious instruction overrides, role-play attacks, encoded content, and context manipulation while allowing the agent to continue its original task.
Why use it?
It warns the coding agent when external or tool-produced content appears to override instructions, impersonate a role, hide commands, or manipulate context.

Skill for Claude Code

Written for Claude Code: PostToolUse hook event. Also seen: reads .claude/ paths; mentions Claude Code.

This is lasso-security/claude-hooks's own configuration. It tells Claude Code how to work on claude-hooks itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-hooks configures →

Reuse

Borrowing it

Nothing to install: this file belongs to lasso-security/claude-hooks. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/lasso-security/claude-hooks/dev/.claude/skills/prompt-injection-defender/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/lasso-security/claude-hooks

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for prompt-injection-defender

README.md
[![agentmods](https://agentmods.dev/badge/skills/lasso-security/claude-hooks/prompt-injection-defender/github.svg)](https://agentmods.dev/skills/lasso-security/claude-hooks/prompt-injection-defender)
Your own site
<a href="https://agentmods.dev/skills/lasso-security/claude-hooks/prompt-injection-defender"><img src="https://agentmods.dev/badge/skills/lasso-security/claude-hooks/prompt-injection-defender/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for prompt-injection-defender

Your own site · 80×15
<a href="https://agentmods.dev/skills/lasso-security/claude-hooks/prompt-injection-defender"><img src="https://agentmods.dev/badge/skills/lasso-security/claude-hooks/prompt-injection-defender.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 958 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00958
Opus 5.5 $0.00000 $0.00383
Sonnet 5.5 $0.00000 $0.00192
Haiku 4.5 $0.00000 $0.00096

Measured 1mo ago against content hash 787aa6e55c51, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

prompt-injection-defender scanned grade B with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

The scan reads SKILL.md. This mod also ships 4 executable files (hooks/defender-python/post-tool-defender.py, hooks/defender-python/test-defender.py, hooks/defender-typescript/post-tool-defender.ts, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Instruction-override phrasingmediumPrompt injection

Text telling the model to disregard its earlier instructions or safety rules is the shape of a prompt injection, whoever wrote it.

- [Instruction Override] Attempts to ignore previous instructions

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

Reads agent configuration directorieslowAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

| Global | `~/.claude/settings.json` | All projects |

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

.claude/skills/prompt-injection-defender/SKILL.md · 126 lines

How it starts

The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Prompt Injection Defender Skill

Overview

Defense against indirect prompt injection attacks for Claude Code. This skill provides PostToolUse hooks that scan tool outputs (files, web pages, command results) for injection attempts and warn Claude about suspicious content.

Features

  • Real-time scanning of tool outputs (Read, WebFetch, Bash, Grep, Task, MCP tools)
  • 4 detection categories: Instruction Override, Role-Playing/DAN, Encoding/Obfuscation, Context Manipulation
  • 50+ patterns covering known injection techniques
  • Warn + Continue approach (doesn't block, just warns Claude)
  • Dual implementation: Python/UV and TypeScript/Bun

Skill Structure

prompt-injection-defender/
├── SKILL.md                    # This file
├── patterns.yaml               # Single source of truth for detection patterns
├── cookbook/
│   ├── install_workflow.md     # Interactive installation guide
│   ├── modify_patterns_workflow.md  # Pattern modification guide
│   └── test_defender.md        # Testing workflow
├── hooks/
│   ├── defender-python/        # Python implementation
│   │   ├── post-tool-defender.py
│   │   ├── python-settings.json
│   │   └── test-defender.py
│   └── defender-typescript/    # TypeScript implementation
│       ├── post-tool-defender.ts
│       ├── typescript-settings.json
│       └── test-defender.ts
└── test-prompts/               # Test scenarios
    ├── injection_v1.md         # Instruction override tests
    ├── injection_v2.md         # Role-playing tests
    ├── injection_v3.md         # Encoding tests
    └── injection_v4.md         # Context manipulation tests

Cookbook Decision Tree

Triggers → Workflows

User Request Pattern Workflow to Use
"install prompt injection defender" install_workflow.md
"install the defender" install_workflow.md
"protect against prompt injection" install_workflow.md
"add new pattern" modify_patterns_workflow.md
"modify patterns" modify_patterns_workflow.md
"update detection rules" modify_patterns_workflow.md
"test the defender" test_defender.md
"run injection tests" test_defender.md
"verify defender works" test_defender.md

Read the full file on GitHub · 126 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 126 lines · 0 tokens per session scan B 787aa6e55c51

Subscribe to this mod's changes

prompt-injection-defender is a skill published in the GitHub repository lasso-security/claude-hooks (269 stars, last pushed 9mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 958 tokens. A static security scan graded it B with 2 findings (instruction-override phrasing, reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

agent-state-bar

A design guide for an agent status bar: a short, automatically updated summary of progress, remaining tasks, tool counts, errors, and system state placed near the latest model input.

bojieli/ai-agent-book · 105 tokens

reward-design

A guide to defining the scores that an AI agent receives during trial-and-error training. It covers checks based on rules, human preferences, or another model, and distinguishes rewarding the final result from rewarding the steps taken.

bojieli/ai-agent-book · 131 tokens

context-engineering

A guide to organizing the instructions and information an AI agent receives at each step. It covers system prompts, tool descriptions, conversation history, on-demand skills, and protections against unsafe outside content.

bojieli/ai-agent-book · 96 tokens

kv-cache-design

A guide to arranging an AI agent's conversation so previously processed text can be reused. A KV cache stores intermediate results for earlier tokens, while a prompt cache reuses a stable beginning across requests.

bojieli/ai-agent-book · 91 tokens

loop-engineering

A guide to building reliable loops for AI agents that plan, act, check their work, and continue until a task is truly complete. It includes independent verification and a proposer-reviewer pattern in which one agent's work is checked using outside evidence.

bojieli/ai-agent-book · 139 tokens

pptx

A guide for turning a paper, outline, or structured text into a PowerPoint presentation. It covers an 8–12-slide structure, concise slide points, and generation of a .pptx file.

bojieli/ai-agent-book · 84 tokens