kmaruthi2002/universal-llm-skills/ai-safety-and-guardrails
Claude Code and agent skill by kmaruthi2002/universal-llm-skills
- community
Checking that the SKILL.md file is still in the repository.
Threat-model and harden LLM applications and agents against misuse and failure: direct and indirect prompt injection, jailbreaks, system prompt and data leakage, PII handling, insecure output handling, excessive agency, moderation of inputs and outputs, output validation, least-privilege tool access, human confirmation for consequential actions, rate limiting and abuse prevention, red-teaming, and incident response for AI features. Use when shipping a chatbot, agent, RAG system, or any feature that sends user or third-party content to a model; when asked to add guardrails, content filters, or safety checks; when reviewing an AI feature's security; or after a model said or did something it should not have. For general application security use secure-coding; for audits of non-AI systems use security-audit.
Install
npx vskill@latest install kmaruthi2002/universal-llm-skills/ai-safety-and-guardrailsSKILL.md
The same SKILL.md was published earlier as kmaruthi2002/universal-llm-skills/ai-safety-and-guardrails.
AI Safety and Guardrails
A language model will, with some probability, follow instructions it should not, reveal what it was told, produce harmful or false content, and take actions it was manipulated into. You cannot prompt that probability to zero. The engineering task is to design the system so that when the model misbehaves, the damage is small, visible, and recoverable.
Scope
Covers the application-level threat model of LLM systems and the controls that address it: injection, jailbreaks, leakage, privacy, output handling, agency limits, moderation, validation, abuse prevention, red-teaming, monitoring, and incident handling.
Neighbours: secure-coding (general vulnerabilities, which still apply), authentication-and-authorization, security-audit (formal audits), ai-agents-and-tool-use and mcp-server-development (tool design), llm-evaluation (measuring safety), prompt-engineering (prompt-level hardening), incident-response.
Core principles
1. The model is not a security boundary
Instructions in a system prompt are requests, not enforcement. Anything the model can do, an attacker who influences its input can try to make it do. Put enforcement — authorisation, validation, rate limits, allowlists — in deterministic code outside the model.
2. All model input from outside your code is potentially hostile
That includes user messages, but also documents, web pages, emails, tool results, retrieved chunks, file names, image text, and metadata. Content the model reads on behalf of a user (indirect input) is the more dangerous channel, because the user did not write it and may not see it.
3. All model output is untrusted
Treat it as user input to every downstream system: escape before rendering, parameterise before querying, never execute directly, validate before acting.
4. Limit capability, not just behaviour
The most reliable defence against a manipulated model is that it simply cannot do much harm: narrow tools, scoped credentials, no access to data the current user cannot see, confirmation gates on consequential actions. This holds even against attacks nobody has invented yet.
5. Defence in depth, measured
No single filter is reliable. Layer controls (input screening, privilege limits, output validation, monitoring) and measure each against a test set, including the false-positive rate — over-blocking is a real failure that pushes users away or to workarounds.
6. Proportionality
Controls should match the risk. An internal brainstorming tool and a public agent that can send money need very different guardrails. Over-engineering a low-risk feature wastes effort; under-engineering a high-risk one is negligent.
Discovering context
- What the system can do: every tool, data source, and output channel. List them; this is the attack surface.
- Who the users are: internal staff, authenticated customers, anonymous public; their incentive to abuse.
- What untrusted content enters: uploads, web browsing, email, third-party data, other users' content (shared documents, comments).
- What data is reachable: whose, how sensitive, under what regulations (privacy law, health, finance, children's data).
- Consequences of failure: embarrassing text, misinformation, data leak, financial loss, physical or legal harm.
- Existing controls: authentication, logging, moderation services, policies. Check what the model provider offers (moderation endpoints, safety settings, data retention options) in current docs.
- Applicable policies: the provider's usage policies, the organisation's acceptable-use policy, sector regulation.
Threat model
| Threat | What happens | Primary controls | |
|---|---|---|---|
| Direct prompt injection / jailbreak | User crafts input to override instructions or elicit disallowed content | Capability limits; moderation; output validation; monitoring; accept residual risk for text-only harms with policy-based filtering | |
| Indirect prompt injection | Instructions hidden in content the model reads (web page, email, document, tool result) | Least privilege; delimit untrusted data; restrict actions after reading untrusted content; confirmation gates; outbound allowlists | |
| System prompt extraction | User gets the model to reveal its instructions | Assume prompts are public; keep secrets out; do not rely on prompt secrecy for security | |
| Sensitive data leakage | Model reveals data from context, retrieval, memory, or training belonging to someone else | Access control at retrieval and tool level; tenant isolation; minimise data in context; output PII scanning | |
| Data exfiltration via tools or rendering | Injected instructions make the model encode private data into a URL, image link, or message to an attacker | Block or allowlist outbound requests; do not auto-render external images or links from model output; confirmation for sends | |
| Insecure output handling | Model output becomes XSS, SQL injection, command injection, or path traversal downstream | Escape, parameterise, validate; never execute model output directly | |
| Excessive agency | Agent performs harmful actions (deletes, sends, purchases) due to error or manipulation | Narrow tools; scoped credentials; human approval; policy checks; dry runs; audit | |
| Hallucination / misinformation | Confident false statements, fabricated citations | Grounding with citations; abstention; verification steps; UI that signals uncertainty; human review for high stakes | |
| Harmful content generation | Hate, harassment, self-harm content, dangerous instructions | Provider safety features; input/output moderation; topic restrictions; escalation paths | |
| Denial of service / denial of wallet | Abuse drives up cost or exhausts capacity | Authentication; rate limits; quotas; token caps; anomaly alerts | |
| Supply chain | Malicious or compromised models, plugins, MCP servers, datasets | Trusted sources; pinning versions; review before installing; least privilege for third-party tools | |
| Memory/data poisoning | Injected content stored in long-term memory or indexes, affecting future sessions or users | Validate writes; scope memory per user; provenance; review and expiry | |
| Training data poisoning (when you fine-tune) | Malicious examples shape behaviour | Curated, provenance-tracked data; review |
Industry references such as the OWASP Top 10 for LLM applications provide a useful checklist; consult the current version.
Controls in depth
Capability and privilege design
The most important layer.
- Inventory every tool and its worst-case misuse. Remove tools that are not needed.
- Separate read from write tools; give read-only contexts no write tools at all.
- Scope credentials per user, per tenant, per tool, with minimal permissions and short lifetimes.
- Authorise every tool call in code against the end user's permissions.
- Allowlist destinations: email recipients, domains for fetching, file paths, database tables.
- Rate- and amount-limit consequential operations (e.g. maximum refund without human approval).
- Sandbox code execution: isolated environment, no secrets, restricted network, resource limits.
Confirmation for consequential actions
Require explicit human confirmation for actions that are irreversible, external, financial, or affect other people: sending messages, publishing, deleting, purchasing, changing permissions, deploying.
- Show the exact action and parameters in plain language.
- The confirmation must be made by the human through a channel the model cannot forge (a UI control, not a model message saying "the user approved").
- One approval covers one action; do not let approval of one send authorise future sends.
- Consider elevated confirmation (re-authentication, second approver) for high-impact actions.
Handling untrusted content
- Delimit untrusted content clearly and label it as data in the prompt (see
prompt-engineering). This lowers but does not eliminate injection success. - Strip or neutralise known-dangerous constructs where appropriate (hidden text in HTML, invisible Unicode characters, markup that renders as links or images).
- After the model has processed untrusted content, reduce its privileges for the remainder of that task or require confirmation for any side-effecting action ("taint tracking" in spirit).
- Separate models or calls: a "quarantined" call that reads untrusted content and returns only structured, validated data to a "privileged" call that can act — so the privileged call never sees raw attacker text. This dual-model pattern is one of the more robust architectural defences.
Input screening
- Moderation classifiers (provider-supplied or open-source) to flag disallowed categories.
- Injection detectors (classifier- or heuristic-based) as a signal, not a guarantee; attackers adapt.
- Topic or scope classifiers to keep a narrow assistant on-task.
- Size limits on inputs and uploads.
- Measure false positives on legitimate traffic before blocking; consider flag-and-review instead of hard blocking for ambiguous cases.
Output validation and filtering
- Schema validation for structured output; business-rule checks on values.
- Moderation on generated text for public-facing outputs.
- PII and secret scanners on outputs (pattern-based for keys, card numbers, identifiers; model-based for names and addresses), especially when context contains other people's data.
- Grounding checks for factual answers: citations present and pointing to real sources.
- Rendering safety: escape HTML; sanitise markdown; do not auto-load remote images or follow links from model output; restrict link schemes.
- For code generated and run by the system: static checks, sandboxed execution, never with production credentials.
Privacy and data protection
- Data minimisation: send the model only the data needed for the task.
- Redact or pseudonymise PII before sending to third-party models where policy requires; re-identify after if needed.
- Choose provider settings (data retention, training opt-out, regional processing) that match obligations; verify in current terms.
- Logs of prompts and outputs are sensitive: restrict access, set retention, redact.
- Handle user rights (access, deletion) across logs, caches, vector stores, and memory.
- Do not put secrets (API keys, passwords, internal URLs with tokens) in prompts.
Abuse prevention
- Require authentication for costly or risky features.
- Rate limits and quotas per user, per IP, per tenant; token caps per request.
- Anomaly detection on usage and spend.
- Account-level enforcement for repeated policy violations.
Transparency and user experience
- Tell users they are interacting with AI and what it can and cannot do.
- Signal uncertainty; show sources.
- Provide easy reporting of bad outputs and escalation to humans.
- For sensitive domains (health, legal, finance, mental health), state limitations and route to qualified help; follow applicable regulations and provider policies.
Process
This is the start of the file. Read the full SKILL.md on GitHub.
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/ai-safety-and-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/kmaruthi2002/universal-llm-skills/ai-safety-and-guardrails)