Extracts Key Risk Indicators (KRIs) from clinical trial protocol PDFs and assembles them into a structured JSON file ready for CRA monitoring agents. Use this skill whenever the user wants to: parse a clinical protocol, extract rules or guidelines from a protocol PDF, generate KRIs, build a monitoring rule set, analyze a protocol document, or compare extracted rules against a golden set. Works on any Phase 2/3 trial regardless of sponsor or format (ALLOVIVE, Pfizer, Novartis, or any other). Always use this skill when a protocol PDF is provided and the user wants structured extraction of any kind.
How this skill is triggered — by the user, by Claude, or both
Slash command
/protocol-kri-extractor:protocol-kri-extractorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Extracts monitoring rules (KRIs) from any clinical trial protocol PDF.
Extracts monitoring rules (KRIs) from any clinical trial protocol PDF. Protocol-agnostic: no hardcoded section names, visit labels, or therapeutic areas.
Every extracted KRI matches this structure:
{
"kri_id": "SOA-V1-001",
"kri_name": "V1- IMP administration",
"description": "What this KRI monitors and why it matters",
"category_id": "SOA",
"category_label": "Schedule of Activities",
"rule_for_llm": "V1- Verify that [specific actionable check with exact values]",
"protocol_reference": "Section X.X, Page N: \"verbatim quote ≤30 words\"",
"additional_footnotes": "Footnote N: verbatim text — or null"
}
Five categories (universal across all trials — from ICH GCP, not protocol-specific):
pip install pdfplumber pymupdf camelot-py[cv] opencv-python-headless openpyxl --break-system-packages -q
python /path/to/scripts/run_pipeline.py \
--pdf /path/to/protocol.pdf \
--out /path/to/output/ \
[--golden /path/to/golden_set.json]
Or run steps individually — see Step-by-step below.
Read references/steps.md for the detailed prompt templates and logic for each step.
Step 1A — Manifest: Read cover pages + TOC. Map every section to SOA/ELIG/SAF/END/OPS.
Step 1B-Camelot — Table Extraction (PRIMARY): Use Camelot (lattice mode) via scripts/camelot_table_extractor.py to extract the SoA table into soa_table.csv and soa_table.json. This is the PRIMARY source of truth for the SoA procedure × visit grid. Camelot reads table line geometry from the PDF and gives ~99% structural accuracy — deterministic, reproducible, and not affected by LLM variance. Handles multi-page tables automatically. The CSV and JSON outputs become the canonical SoA data for all downstream steps.
Step 1B-Vision — Vision Fallback (SECONDARY): For cells where Camelot detects the lattice structure but the cell content contains footnote superscripts (e.g., "X¹⁰", "X¹³·¹⁴") that Camelot may read as empty, use Claude Vision at 450 DPI as fallback. Also use multi-pass vision (full + left 55% crop + right 55% crop at 450 DPI) with majority voting for wide tables (>12 columns) to recover any cells Camelot missed. Save conflicts in multipass_conflicts.json.
Step 1B-ColDetect — Column Boundary Detection: After extraction, run scripts/vision_table_extractor.py column detection to verify column boundaries match the Camelot-extracted structure. Flag any discrepancies.
Step 1B — Ontology: Build the SoA ontology from the Camelot-extracted table data (verified by vision fallback where needed). Run Footnote Cross-Validation as a safety net.
The SOA extraction follows a strict 6-step process:
soa_table.csv and soa_table.json as the tracking artifacts.V1 - procedure name). Also create one KRI per procedure × visit cell.N/N cells covered = 100%.For non-SOA categories, extraction uses one LLM call per category producing raw_{CAT}.json:
Step 3A — Completeness: Every Camelot CSV cell with "X" must have a KRI. Step 3A+ — Clinical Heuristics: 10 protocol-agnostic heuristics:
detect_contiguous_gaps() from scripts/vision_table_extractor.py.
Step 3B — Accuracy: 20 random KRIs re-verified against source pages. Threshold ≥85%.
Step 3C — Consistency: Same procedure across visits must have consistent details.Step 4A — Assembly: Run scripts/step4a_assemble.py to merge all category files → extracted_kris.json + Extracted_KRIs.xlsx (Excel workbook with 5 sheets: SOA, ELIGIBILITY, SAF&TOX, END&STAT, OPE&COM — blue headers, frozen row 1, wrapped text).
Step 4B — Golden Set Prompt: After assembly, ask the user if a golden set is available.
Step 4C — Golden Set Comparison: Category-by-category LLM comparison with protocol evidence for every difference.
Step 4D — Comparison Verification: After Step 4C, run a reconciliation pass. For each "MISSING" verdict, search the extracted KRIs for any KRI whose rule_for_llm contains the same key terms (procedure name + visit prefix). If found, reclassify as EQUIVALENT or SUBSET (false negative in comparison). Also for each "DIVERGENT" verdict, re-read both rules and confirm they truly check different clinical requirements — not just differently worded versions of the same check. Output a comparison_verified.json with corrections.
Each pipeline run produces these files in the output directory:
| File | Description | Source |
|---|---|---|
manifest.json | Protocol metadata and section map | Step 1A |
soa_table.csv | Canonical SoA matrix (Camelot) | Step 1B-Camelot |
soa_table.json | SoA matrix + visit-procedure mapping (Camelot) | Step 1B-Camelot |
ontology.json | SoA ontology (visits, procedures, footnotes) | Step 1B |
raw_SOA.json | SOA KRIs (check-in + procedure + cross-visit) | Step 2 |
raw_ELIG.json | Eligibility KRIs | Step 2 |
raw_SAF.json | Safety KRIs | Step 2 |
raw_END.json | Endpoint KRIs | Step 2 |
raw_OPS.json | Operations KRIs | Step 2 |
extracted_kris.json | All KRIs assembled | Step 4A |
Extracted_KRIs.xlsx | Excel workbook (5 sheets) | Step 4A |
gaps_report.json | Completeness + heuristic results | Step 3A/3A+ |
accuracy_report.json | 20-KRI accuracy sample | Step 3B |
consistency_report.json | Procedure family consistency | Step 3C |
comparison_report.json | Golden set comparison (if provided) | Step 4C |
rule_for_llm starts with visit code: V1-, S2-, All visits-.After Step 4A assembly completes, always ask the user:
"Do you have a golden set to compare against? You can provide a file path or upload it."
If the user provides a golden set, run Step 4C (see references/steps.md for full details).
Phase 1 — Matching: For each category (SOA, ELIG, SAF, END, OPS) separately, match extracted KRIs to golden KRIs using semantic similarity (not just ID matching). Handle 1:many and many:1 splits.
Phase 2 — Two-tier semantic judging: LLM evaluates each pair using two criteria:
Tier 1 — Semantic coverage (lenient): Does the extracted KRI check the SAME clinical requirement? If yes, differences in phrasing, sentence structure, verbosity, or explanatory context are IRRELEVANT. Focus on WHAT is verified, not HOW the sentence reads.
Tier 2 — Factual precision (strict): When either rule contains specific protocol facts — numeric thresholds, visit windows (±days), drug names & doses, named instruments/scales, washout durations, specific methods (e.g. "ultrasound-guided") — those facts MUST be accurate and present. Wording around them doesn't matter, but the facts themselves do.
Verdicts:
Phase 3 — Protocol evidence: For every non-EQUIVALENT pair, read the cited protocol pages and show a 3-column comparison.
Phase 4 — Coverage gaps: Identify golden KRIs with no extracted match and extracted KRIs with no golden match.
The final comparison_report.json contains:
(EQUIVALENT + SUPERSET + 0.5*SUBSET) / total_golden * 100
=80 → PASS | 60-79 → ITERATE | <60 → REWORK
references/steps.md — detailed LLM prompt templates for each stepreferences/kri_examples.md — annotated KRI examples per categoryscripts/camelot_table_extractor.py — Camelot-based table extraction (PRIMARY for SoA)scripts/vision_table_extractor.py — Vision-based extraction + multi-pass + Heuristic 10scripts/step4a_assemble.py — Assembly + Excel generation (no LLM needed)npx claudepluginhub espresso-clinical/claude-skills --plugin protocol-kri-extractorGenerates clinical trial protocols for medical devices or drugs, including research-only and full protocol modes with waypoint-based architecture.
Audits medical manuscripts against 32 reporting guidelines (STROBE, CONSORT, PRISMA, TRIPOD+AI, etc.) and generates item-by-item compliance reports with PRESENT/MISSING/PARTIAL status.
Generates clinical decision support documents for pharmaceutical research: biomarker-stratified cohort analyses with survival statistics and evidence-based treatment recommendation reports with GRADE grading. Outputs publication-ready LaTeX/PDF.