Knowledge > Runbooks > Content Ops > Audit Content Quality and Completeness
Audit Content Quality and Completeness
Systematically audit the unified_rag_content table to identify quality gaps, missing content, and improvement opportunities across ITW illustrations and church knowledge base entries.
Prerequisites
- Supabase MCP or direct DB access
- Access to
sermon-illustrations/scripts/for batch fixes - Time: a full audit typically takes 1–2 hours
Safety Rules
- NEVER bulk-delete from
unified_rag_content— useis_public = falseto suppress content. - Always scope queries by
categoryto avoid accidentally modifying non-illustration content. - ONE production database — all changes are live immediately.
Steps
Phase 1: Quantitative Overview
-
Count content by category and visibility:
SELECTcategory,is_public,COUNT(*) AS count,AVG(length(content)) AS avg_chars,MIN(length(content)) AS min_chars,MAX(length(content)) AS max_charsFROM unified_rag_contentWHERE category IN ('illustration', 'church_kb')GROUP BY category, is_publicORDER BY category, is_public; -
Check theological lens coverage (illustrations only):
SELECTtl.name AS lens,COUNT(urc.id) AS total,COUNT(CASE WHEN urc.is_public = true THEN 1 END) AS public_count,COUNT(CASE WHEN urc.image_url IS NOT NULL THEN 1 END) AS has_imageFROM sai_theological_lenses tlLEFT JOIN unified_rag_content urcON urc.theological_lens_id = tl.idAND urc.category = 'illustration'GROUP BY tl.id, tl.nameORDER BY public_count ASC;Flag lenses with fewer than 20 public illustrations as gaps.
-
Identify stubs (short content):
SELECT COUNT(*) AS stub_countFROM unified_rag_contentWHERE category = 'illustration'AND length(content) < 300AND is_public = true; -
Identify illustrations missing images:
SELECT COUNT(*) AS missing_image_countFROM unified_rag_contentWHERE category = 'illustration'AND is_public = trueAND image_url IS NULL; -
Check for missing scripture references:
SELECT COUNT(*) AS missing_refFROM unified_rag_contentWHERE category = 'illustration'AND is_public = trueAND (scripture_reference IS NULL OR scripture_reference = '');
Phase 2: Topic Coverage Analysis
-
Check topic tag distribution:
SELECT unnest(topic_tags) AS tag, COUNT(*) AS countFROM unified_rag_contentWHERE category = 'illustration'AND is_public = trueGROUP BY tagORDER BY count DESCLIMIT 40;Look for: missing important topics (grace, prayer, hope, forgiveness) or over-indexed topics.
-
Check scripture book coverage — identify major books with no illustrations:
SELECTSUBSTRING(scripture_reference FROM '^[^0-9]+') AS book,COUNT(*) AS countFROM unified_rag_contentWHERE category = 'illustration'AND is_public = trueAND scripture_reference IS NOT NULLGROUP BY bookORDER BY count ASCLIMIT 20;
Phase 3: Quality Spot-Check
- Sample 20 random illustrations for manual quality review:
Review each for: theological accuracy, appropriate length, scripture match, readability.SELECT id, title, scripture_reference, content, theological_lens_idFROM unified_rag_contentWHERE category = 'illustration'AND is_public = trueORDER BY RANDOM()LIMIT 20;
Phase 4: Prioritize and Fix
-
Build a priority fix list:
Gap Type Priority Fix Runbook Crisis-level stubs (< 100 chars) P1 regenerate-stubs.md Lens with < 10 illustrations P1 generate-lens-content.md Common topics with < 5 illustrations P2 generate-by-topic.md Missing scripture references P2 Manual UPDATE Missing images P3 illustration-images.md Lens with 10–20 illustrations P3 generate-lens-content.md -
Suppress low-quality content that cannot be improved by regeneration:
UPDATE unified_rag_contentSET is_public = false, updated_at = now()WHERE id IN ('[uuid1]', '[uuid2]')AND category = 'illustration';
Verification
Run the overview queries again after fixes to confirm:
- Stub count is zero or near-zero.
- All lenses have at least 20 public illustrations.
- No major topic gaps remain.
- Image coverage has improved.