guardrails
Skill1 starsChanged 3 months agoMITView on GitHub
Runtime input and output controls for LLM systems — the filtering layer, with an honest account of what it can and cannot buy you. Carries: where a guardrail belongs in the defence stack (last, not first), input-side injection detection and its false-positive economics, output-side PII redaction and secret scanning on every path including streaming, schema-constrained generation as the control that actually works, tool-call allowlisting and argument validation, content moderation models, egress filtering, and fail-open vs fail-closed as a deliberate decision per control. Load when adding input/output filtering, validating model output, constraining tool calls, redacting PII, or moderating content. Triggers: guardrails, prompt injection detection, input validation, output filtering, PII redaction, content moderation, Llama Guard, NeMo Guardrails, structured output, JSON schema, function calling validation, refusal, safety filter, egress filtering, jailbreak detection, block unsafe output. Architecture-level defences are `agent-security`; attack generation is `llm-red-teaming`; the musts are `policy/ai-security.md` AI5, AI11.
We split this skill into the rules it gives an agent
4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
4
Distinctive
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
- Distinctive: line 20
Pinned: no single pinned tool — this skill is pattern-level · authored 2026-07.
- Distinctive: line 80
Run on every path — normal responses, error messages, tool results returned to users, and
- Distinctive: line 138
When the moderation service times out, do you block or allow?
- Distinctive: line 148
Write the choice down per control.
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
guardrails — the last layer, useful precisely because it isn't the only one
Pinned: no single pinned tool — this skill is pattern-level · authored 2026-07. Specific moderation models and libraries move fast; verify any named tool before relying on it.
On-demand: load this when adding runtime filtering. Read
agent-securityfirst — that skill carries the structural defences, and a guardrail bolted onto an over-privileged agent is decoration. The non-negotiable rules are canon:ai-security.mdAI5(output is untrusted input) andAI11(sensitive output filtered at the boundary).
When this applies
Adding input or output filtering. Validating model output. Constraining tool calls. Redacting PII. Moderating content. Deciding what to do when a filter is unavailable.
Where guardrails sit — and the honest claim
agent-security's ladder puts detection at step 7, last. That ordering is the whole point:
- A guardrail raises the cost of an attack. It does not make one impossible.
- A passing guardrail is not clearance — same rule as the hooks in
security.mdS1. - Guardrails are worth building anyway: they catch the common case cheaply, they generate the telemetry that tells you you're under attack, and they turn a silent failure into a logged one.
The claim to make is "this reduces the rate and gives us signal," never "this prevents injection." Teams that believe the second one stop doing the first six steps.
The two sides, and which is more tractable
| Input side | Output side | |
| Goal | Spot hostile or out-of-policy input | Stop harmful, leaking, or malformed output |
| Reliability | Weak — adversary adapts, obfuscates, translates, encodes | Much stronger — you're checking against your own rules |
| False positives | Expensive: blocks legitimate users | Cheaper: usually a retry or a redaction |
| Invest here? | Modest effort, log everything | This is where the effort pays |
Output-side controls are deterministic checks against known rules; input-side controls are an arms race against an adaptive adversary. If you have budget for one, spend it on the output side and on structure.
Structured output — the control that actually works
The highest-value guardrail isn't a filter, it's making malformed output impossible:
class ToolChoice(BaseModel):
tool: Literal["search_docs", "get_account", "escalate"] # enum, not free text
query: str = Field(max_length=200)
resp = client.messages.create(..., tools=[{"name": "choose", "input_schema": ToolChoice.model_json_schema()}])
choice = ToolChoice.model_validate(resp.tool_use.input) # validate anyway — never trust the API's wordThe model picks from options rather than composing freely. This converts "did it say something
dangerous?" into "is this value in the enum?" — a question with a reliable answer. Combine with
agent-security ladder step 3.
Always re-validate server-side. Schema-constrained decoding is a strong nudge, not a guarantee, and a proxy or a version change can silently drop the constraint.
Output-side controls
Run on every path — normal responses, error messages, tool results returned to users, and streaming. The streaming path is the one that ships unfiltered, because the filter was wired on the complete response.
| Control | Notes |
| Secret scanning | Same patterns as guard-secrets.py. A model can regurgitate a key from its context |
| PII redaction | What counts as PII is data-governance's call. Regex for structured identifiers, NER for names/addresses; accept it's imperfect |
| Tenant-boundary check | If the response references an id, verify the caller may see it. Catches retrieval scoping failures (D7) |
| Content moderation | A classifier for harm categories. Tune thresholds on your own traffic, not the defaults |
| Schema validation | Above |
| Injection-in-output | Model output going into another prompt (multi-agent, summarisation chains) gets the same treatment as untrusted input (AI7) |
Streaming
Two workable patterns, and one that isn't:
- Buffer to a boundary — filter per sentence or per N tokens. Small latency cost, real filtering.
- Optimistic with retraction — stream, and if the filter trips, send a retraction the client honours. Requires a client that actually implements it.
- Filter only the final assembled response — this is the one that doesn't work, because the content already reached the user.
Pick one deliberately. Measure the added TTFT against the SLI (reliability-sre R1).
Input-side controls
Worth having, with realistic expectations:
- Injection classifiers — a model or heuristic scoring "does this look like an instruction override?" Expect adaptation. Log every detection even when you don't block — the detection rate is a security signal and the trend matters more than the individual verdict.
- Length and structure caps — cheap, and they bound the injection surface.
- Encoding normalisation — strip zero-width and bidi characters, normalise Unicode (homoglyph and hidden-character attacks are common and cheap to defeat).
- Source-based trust — a document from the vetted corpus is treated differently from a user-uploaded PDF. This is more useful than any classifier: it's a property you know rather than one you infer.
On indirect injection: input filtering the user's message does nothing about a payload in a
retrieved document. Apply the same normalisation and detection to retrieved content, and remember
this is mitigation — the boundary is what the agent can do (AI2).
Tool-call guardrails
The highest-consequence boundary in an agent system:
- Allowlist — the agent may call these tools; anything else is rejected before execution.
- Argument validation — schema, ranges, enums, path-traversal checks. A model-supplied file path gets resolved and confirmed inside the intended directory.
- Server-side authorization — the tool re-checks against the user's identity, not the agent's
(
authn-authzI4,I8). This is the one that survives a full compromise of the model, and the one most often missing. - Human gate on irreversible actions (
AI3), with the consequence rendered from the action. - Rate and budget caps (
AI9), failing closed.
Fail-open or fail-closed — decide per control
When the moderation service times out, do you block or allow? There is no universal answer, and the failure mode is not deciding:
| Fail closed (block) | Fail open (allow) |
| Output PII/secret redaction | Optional quality checks |
| Tool-call authorization | Advisory classifiers |
| Budget and rate caps | Telemetry enrichment |
Anything protecting a hard boundary fails closed. Anything advisory fails open and logs loudly. Write the choice down per control; alert when a fail-open path is actually taken, or you'll run unprotected for weeks without knowing.
Gotchas
- Guardrails as the whole security story. The single most common mistake in this area.
- The streaming bypass. Worth stating twice.
- Blocking without logging. A blocked request is your best signal that someone is probing; discarding it wastes the one thing detection is genuinely good for.
- Tuning on synthetic attacks only. False-positive rate on real traffic is what determines whether the control survives contact with users.
- Redacting in the response but not in the logs.
observabilityandS6— the log is a second copy nobody filtered. - A moderation model with unexamined defaults. Its notion of harm is not yours; calibrate against your policy or you'll block legitimate use and miss what you care about.
Other versions15 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 15
- ai-analyst-lab/ai-analyst★ 304same name
- irahardianto/awesome-agv★ 157same name
- googlicius/obsidian-steward★ 85same name
- bolasblack/claude-skills★ 4same name
- hajekim/agentic-design-patterns-skills★ 4same name
- dfrysinger/skills★ 3same name
- adewale/guardrails-skill★ 2same name
- Citadel-Cloud-Management/citadel-saas-factory★ 2same name
- meaningfy-ws/skillery★ 2same name
- antrafa/skills★ 1same name
5 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use prototype, grill-me and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
GoogleSkillprototype
Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
Also in 3 projects that use this
GoogleSkillgrill-me
A relentless interview to sharpen a plan or design.
Also in 4 projects that use this
MicrosoftSkillhandoff
Compact the current conversation into a handoff document for another agent to pick up.
Also in 3 projects that use this
- +1 more from google
In this repository59 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- agent-evaluationSkill
- agent-securitySkill
- annotationSkill
- authn-authzSkill
- caching-and-queuesSkill
- config-hydraSkill
- config-omegaconfSkill
- containersSkill
- data-acquisitionSkill
- data-dvcSkill
- datasetsSkill
- edaSkill
- env-uvSkill
- evaluationSkill
- example-skillSkill
- finetune-unslothSkill
- gitopsSkill
- governanceSkill
- graph-storesSkill
- hpo-optunaSkill
- iac-terraformSkill
- infra-awsSkill
- infra-azureSkill
- infra-gcpSkill
- kubernetesSkill
- llm-evalSkill
- llm-red-teamingSkill
- local-stackSkill
- mcp-securitySkill
- memorySkill
- monitoringSkill
- notebooksSkill
- object-and-lakehouseSkill
- observabilitySkill
- pipelinesSkill
- policy-as-codeSkill
- processSkill
- relational-storesSkill
- reliability-sreSkill
- reportingSkill
- secrets-managementSkill
- secure-cicdSkill
- servingSkill
- sqlSkill
- statisticsSkill
- supply-chain-securitySkill
- tabularSkill
- testingSkill
- threat-modelingSkill
- timeseriesSkill
- tracking-mlflowSkill
- tracking-wandbSkill
- trainingSkill
- vector-storesSkill
- visualizationSkill
- wave-planningSkill
- workflow-orchestrationSkill
- wranglingSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

