lauren-framework/lauren-ai/adding-guardrails
Claude Code and agent skill by lauren-framework/lauren-ai
- community
Checking that the SKILL.md file is still in the repository.
Adds content safety filters to lauren-ai agents using @use_guardrails for input and output checks. Use when an agent needs prompt injection protection, PII redaction, topic filtering, length limiting, or LLM-powered content evaluation. Also covers creating custom guardrail classes injectable via @guardrail.
Install
npx vskill@latest install lauren-framework/lauren-ai/adding-guardrailsSKILL.md
The same SKILL.md was published earlier as lauren-framework/lauren-ai/adding-guardrails.
Usecodemap find "SymbolName"to locate any symbol before reading — it givesexact file + line range and is faster than grep across the whole repo.
Adding Guardrails to Agents
Quick start
Run it:
Two guardrail decorators — critical distinction
| Decorator | Purpose | Applied to | |||
|---|---|---|---|---|---|
@use_guardrails(input=[...], output=[...]) | Attaches guardrail instances to an @agent() class | Agent class | |||
| `@guardrail(kind="input"\ | "output"\ | "any")` | Marks a class as a DI-injectable guardrail provider (also applies @injectable) | Guardrail class |
These are two entirely different decorators for two different purposes. Do not confuse them:
- Use
@use_guardrailson your@agent()class to plug in filter instances. - Use
@guardrailon a standalone class to make it injectable through the DI
container so that it can be resolved and passed into @use_guardrails.
Import them as separate symbols:
Built-in guardrails
| Class | Direction | What it does | |
|---|---|---|---|
PromptInjectionFilter() | input | Blocks jailbreak and prompt-override attempts | |
PIIRedactor() | input (or output) | Redacts email, phone, SSN, credit card with [REDACTED] | |
LengthFilter(max_chars=N) | output | Truncates output to at most N characters | |
TopicFilter(blocked=[...]) | input or output | Blocks messages containing listed keywords | |
LLMGuardrail(policy="...") | input or output | Uses a separate LLM call to evaluate against a policy |
Full documentation and examples for each: see guardrails.md.
Decorator stacking position
@use_guardrails() must sit between @agent() (above) and @use_tools() (below). The full correct order:
Python applies decorators bottom-up, so @use_tools runs first, then @use_guardrails, then @remember, and finally @agent which reads all collected metadata. Swapping the order silently drops tools or guardrails.
Conditional guardrails
None entries in the lists are silently dropped, which enables feature-flag or config-driven guard selection:
DI-injectable guardrails with @guardrail
When your guardrail requires injected dependencies (database clients, config, etc.), define it as a class decorated with @guardrail:
@guardrail(kind="input") automatically applies @injectable, so the DI container can resolve AllowlistFilter with its dependencies and pass it to @use_guardrails:
Reference
See guardrails.md for:
- Full API for each built-in guardrail
- Implementing the
InputGuardrail/OutputGuardrailprotocol GuardrailDecisionAPI (allow(),allow(replacement=...),block(reason))- Stacking behaviour (first
blockshort-circuits remaining guards) GuardrailViolatedexception handling
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/adding-guardrails/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lauren-framework/lauren-ai/adding-guardrails)