Skip to content

Prompt Injection Detector

Scans text for prompt injection attacks using regex, heuristics, and a DeBERTa classifier.

Stars
35,430
Licence
Apache-2.0
Files
3 files

What it does

Once installed, the agent can check user inputs or stored prompts for attempts to hijack an AI model, such as 'ignore your previous instructions' or hidden encoded commands. It combines three checks: pattern matching against known attack phrases, a structural anomaly score, and a machine-learning classifier (a Hugging Face DeBERTa model) that gives a probability of injection. It can screen live inputs before they reach an LLM app or audit old logs.

Great for

  • Developers building chatbots, AI agents, or RAG pipelines who want an input-screening layer
  • Security teams reviewing LLM interaction logs for past injection attempts
  • Teams red-teaming existing prompt injection defenses

Skip it if

  • As the only protection for an LLM app: the skill itself says it must be combined with output validation and least-privilege tool access, since detectors can miss novel attacks
  • Detecting jailbreaks that do not involve injected adversarial instructions, which the skill explicitly excludes
  • Non-technical users without Python experience, since setup requires installing ML libraries and a roughly 700 MB model

Try asking

  • “Scan prompts.txt with full mode and output JSON for my pipeline”
  • “Check this user message for prompt injection before sending it to my chatbot”
  • “Audit last month's historical prompts and list the ones flagged as injections”
  • “Run a quick regex-only screen on incoming input with sub-millisecond latency”
Step-by-step guide: how to use Prompt Injection DetectorInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 3 original files, the Apache-2.0 licence and an attribution note.

    detecting-ai-model-prompt-injection-attacks.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip detecting-ai-model-prompt-injection-attacks.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip detecting-ai-model-prompt-injection-attacks.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Start with --mode regex or --mode heuristic to test without downloading the model, then enable full mode for classifier accuracy
  • Tune --threshold (default 0.85) against benign samples from your own app to control false positives
  • Treat the detector as one layer of defense: pair it with output checks and restricted tool permissions

What's inside

  • references/api-reference.md
  • scripts/agent.py
  • SKILL.md

Redistributed unmodified from mukul975/Anthropic-Cybersecurity-Skills under the Apache-2.0 licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.