secure-ai
Secures AI integrations against prompt injection, privilege escalation, and data leakage. Use when implementing defense-in-depth for LLM pipelines, applying zero-trust controls to autonomous agents, hardening server actions that interact with AI services, validating model outputs, securing MCP tool integrations, or auditing AI system access patterns and identity management. Use for OWASP LLM Top 10, prompt injection defense, agentic security, AI supply chain.
What this skill does
# Secure AI ## Overview Secures AI integration layers through multi-layered defense, structural isolation, and zero-trust orchestration. Covers prompt injection defense, model output validation, agentic security, secure server actions, supply chain integrity, MCP tool security, and audit protocols for applications that interact with LLMs. Aligned with the OWASP Top 10 for LLM Applications 2025 and the NIST AI Risk Management Framework (AI RMF 1.0). Provides coverage for all ten OWASP LLM risks with concrete defense patterns. **When to use:** Securing LLM-powered features against prompt injection, validating and sanitizing model outputs before downstream use, implementing zero-trust for autonomous agents, hardening server actions for AI endpoints, securing MCP tool integrations, managing AI supply chain risks, auditing AI access patterns. **When NOT to use:** General web application security without AI components, frontend-only security concerns, non-AI API hardening, basic authentication or authorization without AI involvement. ## Quick Reference | Pattern | Approach | Key Points | | ---------------------- | ----------------------------------------------- | ---------------------------------------------------------- | | Structural isolation | Separate system/user message roles | Never mix instructions and user data in one string | | Input boundaries | Delimit user data with markers | Helps models identify where untrusted data begins/ends | | Guardian model | Pre-scan input with a fast classifier | Detect injection patterns before main reasoning model | | Output validation | Treat LLM output as untrusted input | Context-aware encoding, parameterized queries, CSP headers | | Least privilege | Capability-based scopes per sub-task | Agents get only the tools needed for current work | | Human-in-the-loop | Require human sign-off for destructive actions | Financial or data-altering events need approval | | Non-human identity | OIDC-based agent authentication | Verifiable identity for every agent, rotate keys regularly | | Server-only AI logic | `server-only` imports for all AI code | Keys and reasoning never leak to client bundle | | Input validation | Zod schemas on all AI-facing server actions | Never pass raw user input to AI services | | Rate limiting | Per-user/IP token budget via Redis | Prevent denial-of-wallet attacks on AI endpoints | | Stream scrubbing | Filter sensitive strings from AI output streams | Remove internal IDs, secrets before reaching client | | MCP tool security | Allowlist tools, validate inputs/outputs | Treat MCP servers as untrusted, enforce least privilege | | Supply chain integrity | Verify model provenance, maintain AI-BOM | Track models, datasets, and dependencies with checksums | | Secret management | Environment variables with CI leak scanning | Use gitleaks in CI to prevent committed secrets | ## Core Security Principles 1. **Isolation is absolute** -- user data must never be treated as system instruction 2. **LLM output is untrusted** -- treat all model responses as potentially malicious input before downstream use 3. **Least privilege for agents** -- grant only the tools needed for the current sub-task, revoke after completion 4. **Human verification of destruction** -- destructive or irreversible actions require a human signature 5. **No secrets in client** -- all AI logic and keys reside in server-only environments 6. **Adversarial mindset** -- assume both users and agents will attempt to bypass rules 7. **Defense in depth** -- layer defenses so that bypassing one layer does not compromise the system 8. **Supply chain verification** -- verify provenance and integrity of all models, datasets, and AI tools ## OWASP LLM Top 10 (2025) Coverage | OWASP Risk | Reference | | -------------------------------------- | ---------------------------------------------------------- | | LLM01 Prompt Injection | Prompt Injection Defense | | LLM02 Sensitive Information Disclosure | Secure Server Actions (stream scrubbing, output filtering) | | LLM03 Supply Chain | Supply Chain and MCP Security | | LLM04 Data and Model Poisoning | Supply Chain and MCP Security | | LLM05 Improper Output Handling | Output Validation and Encoding | | LLM06 Excessive Agency | Agentic Zero-Trust Security (least privilege, HITL) | | LLM07 System Prompt Leakage | Prompt Injection Defense (non-extractable prompts) | | LLM08 Vector and Embedding Weaknesses | Output Validation and Encoding (RAG sanitization) | | LLM09 Misinformation | Output Validation and Encoding (semantic filtering) | | LLM10 Unbounded Consumption | Secure Server Actions (rate limiting, token budgets) | ## Common Mistakes | Mistake | Correct Pattern | | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- | | Mixing user input and system instructions in the same prompt field | Use structural isolation with separate system and user message roles | | Trusting LLM output and passing it directly to exec, eval, or SQL | Treat all model output as untrusted; use parameterized queries and context-aware encoding | | Giving agents unlimited tool access for all tasks | Apply capability-based scopes granting only tools needed per sub-task | | Using static API keys for AI service authentication | Use OIDC with dynamic key rotation and short-lived tokens | | Loading third-party models without provenance checks | Verify model checksums, use signed artifacts, maintain AI-BOM | | Granting MCP servers broad permissions without validation | Allowlist MCP tools, validate all inputs/outputs, enforce human approval for sensitive actions | | Passing raw user input directly to AI services | Validate all input with Zod schemas before AI processing | | Streaming AI responses without output filtering | Scrub sensitive strings from streams before they reach the client | ## Key Frameworks - **OWASP Top 10 for LLM Applications 2025** -- industry standard for LLM vulnerability classification - **NIST AI Risk Management Framework (AI RMF 1.0)** -- four-function framework (Govern, Map, Measure, Manage) for AI risk - **NIST Cybersecurity Framework Profile for AI (NISTIR 8596)** -- guidelines for secure AI adoption - **OWASP MCP Security Cheat Sheet** -- practical guide for securing third-party MCP server integrations - **CycloneDX 1.6 / SPDX 3.0** -- standards supporting AI Bill of Materials (ML-BOM) ## Delegation - **Scan codebase for prompt injection vulnerabilities**: Use `Explore` agent to search for user data flowing into system prompts and unvalidated inputs - **Implement zero-trust agent orchestration**: Use `Task` agent to add identity verification, sandboxing, and human approval gates - **Audit model output handling**: Use `Explore` agent to find
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.