ai-output-validation
Validates, parses, and sanitizes AI-generated outputs before they reach end users or downstream systems. Structured output enforcement, schema validation, and…
Detects and mitigates LLM hallucinations in production pipelines. Validates AI-generated facts, code, and decisions before they reach end users or downstream systems.
$ npx -y skills add DevelopersGlobal/ai-agent-skills --skill hallucination-prevention --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/hallucination-preventionContext preview
The summary Claude sees to decide when to auto-load this skill.
Detects and mitigates LLM hallucinations in production pipelines. Validates AI-generated facts, code, and decisions before they reach end users or downstream systems.
name: hallucination-prevention description: Detects and mitigates LLM hallucinations in production pipelines. Validates AI-generated facts, code, and decisions before they reach end users or downstream systems. category: harden applies-to: [claude, gemini, cursor, copilot, any] version: 1.0.0
LLMs hallucinate — they generate plausible-sounding but factually incorrect content with high confidence. In production systems, hallucinations cause incorrect medical advice, broken code, wrong legal citations, fabricated API calls, and erroneous financial data.
This skill builds hallucination detection and mitigation into your AI pipeline architecture — before output reaches users or downstream systems.
1. Map all AI outputs in your system. For each, classify:
2. Apply this skill's full rigor to Critical and High outputs. Lighter checks for Medium and Low.
**Verify:** Every AI output in your pipeline has a hallucination risk classification.
3. For factual queries: **always provide source documents** in the prompt (RAG pattern). Instruct the model to cite sources and refuse to answer if the information isn't in the provided documents. 4. For code generation: run the code in a sandbox and verify it produces the expected output before returning to the user. 5. For structured outputs (JSON, SQL, etc.): validate against a schema before using. 6. For numerical claims: require the model to show its work step-by-step and verify key calculations independently.
**Verify:** Every Critical/High output is grounded in provided sources or verified by execution.
7. **Self-consistency checking**: Ask the model the same question 2–3 ways and compare answers. Divergent answers signal uncertain ground. 8. **Chain-of-thought with verification**: Prompt the model to reason step-by-step, then verify the reasoning chain, not just the conclusion. 9. **Separate generation from verification**: Use one prompt to generate, a different prompt to critically evaluate. Never use the same model call for both. 10. **Human-in-the-loop for Critical outputs**: Require human review before Critical AI-generated content reaches end users.
**Verify:** Critical outputs have at least two independent verification mechanisms.
11. When the model is uncertain, it should say so — never present uncertain information as confident fact.
12. Confidence scores: Where available, expose confidence thresholds. Route low-confidence outputs to human review. 13. Graceful degradation: If the AI cannot answer accurately, show the user relevant source documents instead.
**Verify:** The system has a defined behavior for when AI confidence is low.
14. Log all AI inputs and outputs. 15. Implement feedback mechanisms (thumbs up/down, explicit corrections). 16. Regularly audit a sample of outputs for accuracy. 17. Track and alert on: sudden changes in output patterns, high user correction rates, model responses contradicting grounded sources.
**Verify:** A feedback mechanism exists and hallucination incidents are tracked.
| Excuse | Rebuttal | |--------|----------| | "This model is highly accurate" | All LLMs hallucinate. Accuracy ≠ 100%. Design for the failure case. | | "Users will catch errors" | Users often can't distinguish hallucinated content from real content. Don't rely on them. | | "It's a demo/MVP" | Hallucinations that reach demos become the baseline expectation. Fix them early. | | "We'll add verification in v2" | Hallucinations that cause harm in v1 may not give you a v2. |
AI agent skills for production grade applications
Validates, parses, and sanitizes AI-generated outputs before they reach end users or downstream systems. Structured output enforcement, schema validation, and…
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.