api-design
Design stable, versioned, self-documenting APIs. Easy to use correctly, hard to use incorrectly. Apply Hyrum's Law from day one.
Validates, parses, and sanitizes AI-generated outputs before they reach end users or downstream systems. Structured output enforcement, schema validation, and fallback handling.
$ npx -y skills add DevelopersGlobal/ai-agent-skills --skill ai-output-validation --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/ai-output-validationContext preview
The summary Claude sees to decide when to auto-load this skill.
Validates, parses, and sanitizes AI-generated outputs before they reach end users or downstream systems. Structured output enforcement, schema validation, and fallback handling.
name: ai-output-validation description: Validates, parses, and sanitizes AI-generated outputs before they reach end users or downstream systems. Structured output enforcement, schema validation, and fallback handling. category: test applies-to: [claude, gemini, cursor, copilot, any] version: 1.0.0
AI models produce unstructured text by default. In production pipelines, unstructured outputs cause brittle parsing, unexpected behavior, and silent failures. This skill enforces structured output generation and validation at every AI system boundary.
1. Define the exact structure you need BEFORE writing the prompt. 2. Use JSON Schema or Pydantic/Zod models to formalize the expected output. 3. Example schema:
{
"type": "object",
"required": ["summary", "action", "confidence"],
"properties": {
"summary": {"type": "string", "maxLength": 200},
"action": {"type": "string", "enum": ["approve", "reject", "review"]},
"confidence": {"type": "number", "minimum": 0, "maximum": 1}
}
}4. Design the schema to be **minimal** — only what you actually need.
**Verify:** Schema is defined and versioned before any prompt is written.
5. Explicitly instruct the model to output in your defined format. 6. Include the schema or an example in the prompt. 7. Use models/APIs that support structured output natively where available (OpenAI structured outputs, Gemini JSON mode, Anthropic tool use). 8. Prompt pattern:
Respond ONLY with valid JSON matching this schema:
{schema}
Do not include explanation or markdown. Output raw JSON only.**Verify:** Prompt explicitly requests structured output with schema reference.
9. Parse the output against your schema — never use raw AI output directly. 10. If parsing fails:
11. Validate semantic constraints beyond the schema:
**Verify:** All AI outputs pass schema validation before use. Failed validations are logged.
12. If AI output will be rendered as HTML: sanitize against XSS. 13. If AI output will be executed as code: sandbox it and review before execution. 14. If AI output will be stored in a database: sanitize against injection. 15. Never trust AI output the way you'd trust your own code — it's user-generated content.
**Verify:** AI output is sanitized appropriate to its destination.
16. Log the schema validation pass/fail rate. 17. Sample and review AI outputs regularly for semantic correctness. 18. Alert on high validation failure rates (>5%).
**Verify:** Validation metrics are tracked. Alert configured.
| Excuse | Rebuttal | |--------|----------| | "The model outputs valid JSON 99% of the time" | That 1% causes production incidents. Always validate. | | "We display it to users, not parse it" | Users act on AI output. Wrong output drives wrong actions. | | "Structured output adds latency" | Validation is microseconds. Debugging unvalidated output is hours. | | "The model is deterministic enough" | No LLM is deterministic enough to skip validation. |
AI agent skills for production grade applications
Design stable, versioned, self-documenting APIs. Easy to use correctly, hard to use incorrectly. Apply Hyrum's Law from day one.
Automated quality gates from commit to production. Every merge to main is potentially shippable. No manual steps in the deployment path.
Get layered, context-aware explanations of unfamiliar code. Understand what it does, why it was written that way, and how to work with it safely.
Structured code review focusing on correctness, security, and maintainability. Correctness before style. Every reviewer comment must be actionable.
Load minimum necessary context into agent context windows. Prevents token bloat, reduces cost, and improves focus. Only load what the current task needs.
Systematic root cause analysis for production and development bugs. Hypothesis-driven debugging — never guess-and-check.