Skip to content

Defending LLMs with Guardrails

Add runtime safety filters that screen prompts and responses for jailbreaks, injection, toxicity and data leaks.

Stars
35,430
Licence
Apache-2.0
Files
4 files

What it does

This skill teaches an AI agent how to set up safety checks around a language model application. It covers three open-source guardrail tools: Llama Guard 3 (a classifier that labels text as safe or unsafe), NeMo Guardrails (rules for conversation flow and topics), and LLM Guard (scanners for prompt injection, toxicity, secrets and personal data). The agent can then write the configuration code and test a set of known-bad prompts to check that they get blocked.

Great for

  • Engineers adding a safety layer to a chatbot, RAG system or AI agent before launch
  • Security teams testing whether an existing LLM app blocks jailbreaks and prompt injection
  • Teams that want to check guardrail block rates and false-positive rates on a labelled prompt set

Skip it if

  • People who only want to use a finished chatbot: this is a build-time guide for developers, not a protection that works by itself (guardrails must be deployed and configured)
  • Use against systems you do not own or have no authorization to test: the validation harness sends attack-style prompts to the target guardrails, and the skill itself says to test only systems you are authorized to assess
  • Organisations expecting guardrails to catch every attack: the skill presents them as one layer in defense-in-depth, and classifiers can miss novel attacks

Try asking

  • “Set up LLM Guard input and output scanners to block prompt injection and redact secrets in my chatbot”
  • “Write a NeMo Guardrails config.yml with Colang flows that refuse off-topic questions and add a jailbreak rail”
  • “Run Llama Guard 3 on my user prompts and assistant responses and explain the category codes it returns”
  • “Use the validation script to measure block rate and false positives on my JSONL file of test prompts”
Step-by-step guide: how to use Defending LLMs with GuardrailsInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

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

    defending-llms-with-guardrails.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip defending-llms-with-guardrails.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip defending-llms-with-guardrails.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

  • Run the validation harness on a labelled JSONL corpus you own before trusting any guardrail configuration, and track false positives as well as block rates.
  • Combine the deterministic LLM Guard scanners with the semantic Llama Guard classifier rather than relying on one tool.
  • Review the scripts and any model downloads before running them, since the harness loads models and sends prompts through them.

What's inside

  • references/api-reference.md
  • references/standards.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.