agentleFS
saizulsaizul/ai-agent-builder-skills/skills/guardrails-and-safety/SKILL.md

guardrails-and-safety

Skill0 starsChanged 9 days agoMITView on GitHub

Add practical guardrails to business LLM agents - PII and secret redaction before prompts, logs and indexes; prompt-injection red flags in retrieved documents, web pages, emails and tool results; least-privilege tools and confirmation for write actions; output checks and abuse handling - with a redaction script (emails, phones, Luhn-checked cards, IBANs, SSNs, IPs, credentials; label/mask/hash modes; JSONL aware; allowlist for known-safe values) and an injection scanner (override phrases, fake role markers, exfiltration links, hidden HTML and invisible characters). Use when an agent handles customer data, reads untrusted content (RAG, browsing, email), takes actions, before launch or a security review, or when asked how to make a chatbot safe.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    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:

    Redact PII and secrets: before data goes to logs, analytics, eval sets, indexes or an LLM provider that should not receive it.

    line 40
  2. Distinctive:

    Scan untrusted content for injection: before indexing and, where feasible, at retrieval.

    line 52

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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 and safety

Guardrails are layers: limit what the agent can do, keep sensitive data out, treat untrusted content as data, check outputs, and watch production. No single filter is enough; the scripts here are tripwires, not proof of safety.

Paths below are relative to this skill's folder.

When to use

  • Agent handles personal data (customers, employees, patients) or payment-related flows
  • Agent reads untrusted content: retrieved documents, web pages, emails, uploaded files, tool output
  • Agent can act: send messages, change records, refund, book
  • Pre-launch security review, or "how do we stop prompt injection / data leaks?"

When not to use

  • General application security (auth, infra, dependencies): use your normal security review
  • Content moderation policy design for a social platform: specialised tooling and policy work
  • Legal compliance sign-off: involve the data protection / legal owner; this skill supports them

Workflow

  1. Map the data flows. For each input (user message, retrieved docs, tool results, files) and output (reply, tool call, log, analytics, index): what data, who can see it, where it is stored and for how long. Mark untrusted inputs and irreversible outputs.
  2. Limit capability first. Least-privilege tools (read-only where possible, scoped to the authenticated user), confirmation for write actions enforced in code, rate limits, spend caps, and a kill switch. See references/guardrail-layers.md.
  3. Redact PII and secrets before data goes to logs, analytics, eval sets, indexes or an LLM provider that should not receive it.
    python3 scripts/redact_pii.py transcript.txt                     # labels: [EMAIL], [PHONE]...
    python3 scripts/redact_pii.py logs.jsonl --jsonl --mode hash --salt "$REDACT_SALT" --out clean.jsonl
    python3 scripts/redact_pii.py export.csv --check --json          # gate: exit 1 if PII found
    python3 scripts/redact_pii.py notes.txt --only EMAIL,PHONE --pattern 'ORDER=ORD-\d{6}'
    python3 scripts/redact_pii.py logs.txt --allow 'support@example\.com' --allow-file allow.txt
    --mode hash maps the same value to the same token so analytics still work; keep the salt secret. The script never prints the values it finds. Regexes miss names and addresses; for those, add patterns or a dedicated PII service.
  4. Scan untrusted content for injection before indexing and, where feasible, at retrieval.
    python3 scripts/injection_scan.py knowledge-base/                # files and folders
    python3 scripts/injection_scan.py chunks.jsonl --jsonl-field text --json
    python3 scripts/injection_scan.py page.html --threshold 3
    Exit 1 when any item scores at or above --threshold. Quarantine flagged items for human review; do not silently drop them (you want to know who is attacking). Patterns and their limits: references/injection-patterns.md.
  5. Harden the prompt and runtime. Delimit untrusted content and state that it is data, not instructions; never put secrets in prompts; strip or neutralise links and images in model output if the channel renders them; validate tool arguments server-side.
  6. Check outputs for the failures that matter to the business: PII of other users, promises (refunds, prices), off-topic content, links to unknown domains. Use redact_pii.py --check on outputs in eval runs and add safety cases to eval-harness.
  7. Monitor and respond. Log redacted conversations, flag injection hits and refusals, review weekly, and keep an incident playbook (disable tool, roll back prompt, notify owner).

Output

Data flows: 4 inputs (2 untrusted: help-center scrape, customer emails), 3 outputs
redact_pii --check on 30-day logs: 1,204 values (EMAIL 812, PHONE 377, CARD 15) -> logs now redacted (hash mode)
injection_scan on 2,310 chunks: 3 suspicious
  kb/faq-shipping.html#12 score=8 override-instructions, hidden-html
Fixes: quarantine 3 chunks, create_refund now requires confirm token, links stripped in SMS channel,
added 6 safety eval cases. Residual risk: names/addresses not detected by regex.

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.