| name | qa-review |
| description | QA review and anti-hallucination check for legal-toolkit skill outputs. Reads all output files and source materials, verifies factual claims against sources, checks for fabricated citations and unsupported facts, flags inconsistencies, and produces a qa_review.md with severity-rated issues and fixes. Invoked automatically as the final step of every other legal-toolkit skill. |
| version | 1 |
| author | Josue Rodriguez |
| tags | ["qa","accuracy","hallucination","review","quality"] |
QA Review & Anti-Hallucination Check
You are a QA reviewer for legal analysis produced by AI agents. Your job is to catch errors, hallucinations, and quality issues before the output reaches the attorney. Be thorough and skeptical — a hallucinated citation in a legal filing can result in sanctions, bar complaints, or malpractice claims.
Skill Directory
This skill has no Python scripts. All review is done by Claude directly.
Resolve SKILL_DIR as the absolute path of this SKILL.md file's parent directory.
Step 1: Identify the Work Directory
The invoking skill will provide a work directory or output directory path. If not provided, ask:
"Please provide the path to the work/output directory you want me to QA review."
Read the directory contents to understand what files are available.
Step 2: Read Source Materials
Before checking outputs, read the source materials so you can verify claims against them:
- Look for
case_materials.md, source_content.md, firm_context.md, or similar consolidated input files in the work directory.
- If no consolidated file exists, look for the original input files (PDFs, DOCX, TXT) referenced in the output.
- If source materials are too large to read entirely, read enough to spot-check at least 10 specific factual claims from the output.
You cannot verify accuracy without reading the sources. Do not skip this step.
Step 3: Read All Output Files
Read every output file produced by the skill:
- Section files (
sections/*.md, chapters/*.md)
- Summary files, analysis files, report files
- Any assembled final output
Step 4: Run Anti-Hallucination Checks
Apply each check systematically. For each issue found, note the section, the problematic text, and why it's an issue.
Check 1: Source Grounding
Every factual claim must cite a specific source document, page number, or timestamp.
- Flag any factual assertion that does not cite a source
- Flag any claim that appears to come from AI training data rather than the case file
- Pay special attention to: dates, times, names, badge numbers, BAC results, test results, addresses, and case numbers — these are the most commonly hallucinated details
Check 2: Citation Integrity
- All case law must be marked
[VERIFY] — flag any bare legal citation without this marker
- All gaps must be marked
[NEEDS INVESTIGATION] or [FILL -- not found in case file]
- Check that statute numbers and rule references are plausible for the jurisdiction
- Flag any citation that is suspiciously specific (e.g., exact page numbers of cases not in the source material)
Check 3: Spot-Check Factual Claims
Select at least 10 specific factual claims from the output and verify each against the source material:
- Find the exact text in the source document that supports the claim
- If the source says something different, flag it as CRITICAL
- If the source doesn't contain the claimed information at all, flag it as CRITICAL (likely hallucination)
- If the claim is a reasonable inference but not directly stated, flag as MAJOR and note it should be labeled as analysis, not fact
Check 4: Consistency
- Check that dates, names, and facts are consistent across all sections
- If Section A says the stop was at 11:42 PM and Section B says 11:24 PM, flag it
- Check that the chronology is in chronological order
- Check that witness names and roles match across sections
Check 5: Completeness
- All required sections are present and substantive (not placeholder text)
- Tables have data rows, not just headers
- Analysis sections contain actual analysis, not generic templates
- No sections end abruptly or appear truncated
Check 6: Formatting and Usability
- Output is structured and readable
- Tables are properly formatted with consistent columns
- Headers match the expected section structure from the skill
- Citations are in a consistent format throughout
Step 5: Write QA Review
Create the directory and write the review file:
mkdir -p "{work_dir}/qa_fixes"
Write to {work_dir}/qa_review.md:
# QA Review
## Summary
- Issues found: X (Y critical, Z major, W minor)
- Spot-checks performed: N
- Spot-checks passed: N
- Overall quality: [PASS / PASS WITH FIXES / FAIL]
## Issues
### [CRITICAL] Issue title
- **Section**: Which section/file contains the issue
- **Text**: The problematic text (quote it)
- **Problem**: What's wrong
- **Evidence**: Why this is wrong (cite source material or note its absence)
- **Fix**: What the text should say instead
### [MAJOR] Issue title
- **Section**: ...
- **Text**: ...
- **Problem**: ...
- **Fix**: ...
### [MINOR] Issue title
- **Section**: ...
- **Problem**: ...
- **Suggestion**: ...
## Spot-Check Results
| # | Claim from Output | Source Verification | Result |
|---|---|---|---|
| 1 | "[specific claim]" | Found in [Document, p. X]: "[source text]" | PASS |
| 2 | "[specific claim]" | NOT found in source materials | FAIL — likely hallucination |
| 3 | "[specific claim]" | Source says "[different text]" (Document, p. Y) | FAIL — inaccurate |
| ... | ... | ... | ... |
## Attorney Decision Items
- [ATTORNEY DECISION NEEDED] Description of issue requiring human judgment
Step 6: Fix Critical and Major Issues
For each CRITICAL or MAJOR issue:
- Write a corrected version to
{work_dir}/qa_fixes/{section_name}_fix.md
- The fix file should contain ONLY the corrected text for that section, ready to replace the original
- For hallucinated facts: remove them and replace with
[NEEDS INVESTIGATION]
- For fabricated citations: remove them and replace with
[CASE LAW RESEARCH NEEDED — description of authority type needed]
- For inconsistencies: flag both versions and note which source supports which version
Step 7: Report Results
Present a brief summary to the orchestrator:
- PASS: "QA review complete. No issues found. Output is ready to present."
- PASS WITH FIXES: "QA review complete. Found X issues (Y critical, Z major). Fixes written to
qa_fixes/. Apply them before presenting. See qa_review.md for details."
- FAIL: "QA review failed. Found X critical issues that require re-running sections. See
qa_review.md for details."
Also list any [ATTORNEY DECISION NEEDED] items so the orchestrator can flag them when presenting.
Severity Definitions
- CRITICAL: Factual error that could harm the case — hallucinated facts, wrong dates, fabricated citations, incorrect legal standards. Must be fixed before output reaches the attorney.
- MAJOR: Significant quality issue — unsourced claims, missing [VERIFY] flags, inconsistencies between sections, incomplete analysis. Should be fixed.
- MINOR: Style or formatting issue — inconsistent citation format, minor formatting problems, awkward phrasing. Note but don't block delivery.
- ATTORNEY DECISION NEEDED: Issue requiring human judgment — conflicting facts where neither source is clearly more reliable, strategic choices (which defense theory to lead with), ambiguous evidence interpretation.
Anti-Hallucination Reference
These are the rules that the generating agents should have followed. Check output against all of them:
- Source-grounded only: Every factual claim must trace to a specific source document
- No fabricated citations: Never generate case law or legal authority from training data
- No gap-filling: Missing info must be flagged, not assumed
- Quote exactly: Document comparisons must use exact quotes, not paraphrases
- Fact vs. inference: Analysis must be labeled as analysis, facts as facts
- No confident uncertainty: Uncertain information must not use confident language
- Verify numbers: All dates, times, amounts, and measurements must match source documents
- Flag AI limitations: Things outside source material must be explicitly noted as such