llm-guardrails

Implement input and output safety guardrails for LLM applications using Python.

Updated Sep 23, 2026
One-click install
npx skills add https://github.com/ehadziabdic/WAgents --skill llm-guardrails-ehadziabdic
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: llm-guardrails
Source: https://github.com/ehadziabdic/WAgents/tree/main/opencode/skills/llm-guardrails
Command: npx skills add https://github.com/ehadziabdic/WAgents --skill llm-guardrails-ehadziabdic

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires guardrails-ai, nemoguardrails, llm-guard, openai, transformers, pyyaml, requests, langdetect, presidio-analyzer, presidio-anonymizer, boto3, and includes scripts (resource) and references (resource) components.

What problem does it solve? LLM applications can leak PII, produce toxic or hallucinated content, and fall to jailbreak or prompt injection attacks. This Skill provides a layered input/output guardrail pipeline that validates, filters, and redacts content before and after every model call. ## Core Features & Use Cases - Input Guardrails: Detect prompt injection patterns, jailbreak attempts, and PII (credit cards, SSNs, emails, phones) in user prompts, with configurable block, warn, or redact actions. - Output Guardrails: Check LLM responses for toxicity, PII leakage, hallucination against source context, format validity, and sensitive topics. - Framework Integrations: Ready-made patterns for Guardrails AI, NeMo Guardrails, LLM Guard, OpenAI Moderation API, and Amazon Bedrock Guardrails. - Red Teaming: A built-in adversarial test suite (injection, jailbreak, PII, harmful, encoding categories) that scores model resistance and generates JSON/Markdown reports. - Use Case: Before launching a customer support chatbot, run the red_team.py suite against your endpoint to measure jailbreak resistance, then deploy the guardrails pipeline to block injection attempts and redact PII in production. ## Quick Start Add safety guardrails to my LLM app that detect prompt injection and PII in user input and check the output for toxicity before returning it.

Frequently Asked Questions about llm-guardrails

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add guardrails to an LLM application in Python?▼

Build a pipeline that runs input guardrails (injection, PII, toxicity checks) before the LLM call and output guardrails (toxicity, PII leakage, hallucination, format checks) after. Libraries like Guardrails AI, NeMo Guardrails, and LLM Guard provide ready-made validators and scanners.

Guardrails AI vs NeMo Guardrails vs LLM Guard: which should I use?▼

Guardrails AI focuses on output validation and structured formats, NeMo Guardrails controls conversational flows with Colang scripting, and LLM Guard provides input/output scanning pipelines. All are Apache 2.0 and provider-agnostic; Guardrails AI and NeMo are the most production-ready.

How do I detect prompt injection attacks in user input?▼

Use regex patterns for known injection phrases as a first layer, then add a trained classifier such as LLM Guard's PromptInjection scanner or Prompt Guard 2. Substring blocklists alone are easily bypassed by paraphrasing or encoding, so always pair them with a model-based detector.

Can I use Amazon Bedrock Guardrails with non-Bedrock models?▼

Yes. The ApplyGuardrail API evaluates text against a guardrail without invoking a Bedrock model, so the same content filters, denied topics, PII handling, and grounding checks can protect self-hosted vLLM, OpenAI, or any other stack.

Why do regex-based PII redaction patterns sometimes leak data?▼

Pattern order matters: a phone regex can consume 10 digits of a credit card number and leave the rest unredacted. Order patterns from most specific to least specific, and consider Presidio for more robust entity-based PII detection and anonymization.

How do I red team my LLM for jailbreak vulnerabilities?▼

Run adversarial test suites covering injection, jailbreak, PII, harmful, and encoding attack categories against your endpoint, then measure the resistance rate. Tools like Garak, PyRIT, and Promptfoo automate broader vulnerability scanning for CI/CD integration.