agentleFS
patonkikhpatonkikh/APES/skills/security/guardrails-builder/skill.md

guardrails-builder

Skill3 starsChanged 4 months agoMITView on GitHub

Design layered input and output guardrails for LLM applications: filters, classifiers, policy rules, tool gates, and human-in-the-loop triggers. Use when working on LLM security, OWASP reviews, threat modeling, guardrails, or prompt injection.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Document where each control executes (client, API gateway, application, model wrapper).

    line 45
  2. Distinctive:

    Run new rules in log-only (shadow) mode before enforcement.

    line 131
  3. Distinctive:

    Keep policy rules externalized (config/database) for updates without redeploy.

    line 132
  4. Distinctive:

    Test guardrails with the injection detection test suite.

    line 134
  5. Distinctive:

    Document bypass procedures for authorized admin/debug use only.

    line 135

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
skill.md

Guardrails Builder

Purpose

Design layered input and output guardrails for LLM applications: filters, classifiers, policy rules, tool gates, and human-in-the-loop triggers.

Input: Threat model or injection report, application flow, policy requirements, latency/cost constraints
Output: Guardrails Design document with layer architecture, rule catalog, integration points, and fallback behaviors Examples: See examples.md for worked input/output.


Workflow

Step 1: Define guardrail objectives

For each pipeline stage, specify what must be enforced:

ObjectiveStageFailure mode if missing
Block injectionPre-LLMSystem prompt override
Enforce output schemaPost-LLMMalformed or unsafe responses
Restrict tool callsTool gateUnauthorized actions
Detect PII leakagePost-LLMCompliance violation

Step 2: Map pipeline layers

Design defense-in-depth:

Input → [Input filter] → [Prompt assembly] → LLM → [Output validator] → [Tool gate] → Response
                              ↑                        ↑
                         [Policy engine]          [Policy engine]

Document where each control executes (client, API gateway, application, model wrapper).

Step 3: Design input guardrails

ControlTypeTriggerActionLatency budget

Types: regex/heuristic, ML classifier, allowlist/denylist, length limits, encoding normalization.

Step 4: Design output guardrails

ControlTypeValidatesAction on fail

Include: schema validation, toxicity/PII detection, topic boundary checks, citation verification for RAG.

Step 5: Design tool and action guardrails

For agent/tool-enabled apps:

ToolAllowed paramsAuth scopeConfirmation required

Define: parameter validation, rate limits, destructive action blocks, human approval triggers.

Step 6: Define fallback behaviors

Failure typeUser-facing messageInternal actionEscalation

Options: block silently, generic refusal, partial response, human handoff, circuit breaker.

Step 7: Specify observability

Define metrics and alerts:

  • Block rate by category
  • False-positive reports
  • Latency overhead per layer
  • Guardrail bypass attempts

Step 8: Validate

Run Validation checklist.


Decision Rules

ConditionAction
No threat model or injection reportRun security/prompt-injection-detector or security/ai-threat-modeling first
Latency budget < 100ms totalPrefer lightweight heuristics; defer ML classifiers to async
Agent with write/delete toolsMandatory human-in-the-loop for destructive operations
Regulated domain (health, finance)Add PII/PHI output scanning; document audit trail
High false-positive tolerance unacceptableUse shadow mode before enforcement
Single LLM call, no toolsFocus on input/output layers; skip tool gate

Validation

  • Every Critical/High threat from input has mapped guardrail
  • Input and output layers both addressed
  • Tool guardrails defined if agents/tools present
  • Fallback behavior specified for each control failure
  • Latency and cost impact estimated per layer
  • False-positive handling strategy documented
  • Observability metrics defined
  • No implementation code (framework-specific)

Anti-patterns

  • Single-layer defense — relying only on system prompt instructions.
  • Block without logging — no visibility into attack attempts or tuning data.
  • Opaque refusals — generic errors with no internal categorization for ops.
  • Guardrails after tools execute — validating output after irreversible action.
  • Unbounded regex lists — unmaintainable patterns with high false-positive rate.

Best Practices

  • Align layers with OWASP LLM recommendations (LLM01 input, LLM02 output handling).
  • Run new rules in log-only (shadow) mode before enforcement.
  • Keep policy rules externalized (config/database) for updates without redeploy.
  • Separate user-facing refusal messages from internal reason codes.
  • Test guardrails with the injection detection test suite.
  • Document bypass procedures for authorized admin/debug use only.

Output Structure

# Guardrails Design: [Application Name]

## Objectives
| Objective | Priority | Stage |
|-----------|----------|-------|

## Architecture
[Layer diagram and integration points]

## Input Guardrails
| ID | Control | Trigger | Action | Latency |
|----|---------|---------|--------|---------|

## Output Guardrails
| ID | Control | Validates | Action | Latency |
|----|---------|-----------|--------|---------|

## Tool Guardrails
| Tool | Constraints | Approval |
|------|-------------|----------|

## Fallback Matrix
| Failure | User message | Internal action |
|---------|--------------|-----------------|

## Observability
| Metric | Threshold | Alert |
|--------|-----------|-------|

## Open Questions
- [ ] [Policy decision needed]

Next Skills

OutcomeRecommended Skill
OWASP compliance checksecurity/owasp-llm-reviewer
Update threat model with controlssecurity/ai-threat-modeling
Governance policy alignmentsecurity/ai-governance-advisor
Refine prompts for defenseai/prompt-engineer
Red-team injection patternssecurity/prompt-injection-detector

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.