plugins/healthcare/skills/contracts/skills/synthesize/SKILL.md
After sweep rounds settle, turn findings into a report with cited claims, run a sampled semantic audit, and surface knowledge proposals. Analysis happens via scripts, never mental math.
npx skillsauth add anthropics/healthcare synthesizeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Never dump every finding into context. Get counts first, then pull what you need:
bun $ANT_CONTRACTS_CLI sql "SELECT kind, count(*) FROM findings WHERE run_id='$ANT_CONTRACTS_RUN_ID' GROUP BY kind"
For the per-doc tally, write a script (heredoc → bun) that reads
findings and writes the projection to /tmp/tally.json — read THAT.
Only SELECT … claim, quote … for the specific findings you're putting
in the report.
For anything beyond reading — counts, joins, comparisons, tallies — write a
short script (Bash heredoc → bun, or a scratch SQLite db under /tmp) and
run it. The findings are already in SQL; most analysis is a SELECT. If you
need a second Workflow fan-out for analysis, launch one.
bun $ANT_CONTRACTS_CLI write reports '{"run_id":"'$ANT_CONTRACTS_RUN_ID'","brief_id":<b>,"body":"…markdown…"}'
Then one report_claims row per factual statement in the body, each linked
via claim_citations. The v_uncited_claims view must be empty when you're
done — check it.
When scope was 1 doc, 1 worker, and every report cite was minted via
cli cite this session: the gate already enforced quote==span. Sample
only the heading/subject context check; skip the byte-reverify. At
corpus scale, do the full audit — it's the distractor-clause guard.
A real quote can support the wrong claim (e.g. a bare "§4.2.4.1.11: 5.5%" inserted by amendment has no topic — it's a savings percentage, not a withhold). Sample your report claims and, for each, re-read the cited span plus its surrounding section heading (and the base contract's parent section when the cite is a bare amendment insertion). Does the section's subject match the claim's subject? Is the cited document in the right family?
bun $ANT_CONTRACTS_CLI write audits '{"run_id":"'$ANT_CONTRACTS_RUN_ID'","kind":"semantic_sample","sample_n":<n>,"result":"<json or prose>"}'
A failed audit means the claim is wrong — fix the report and re-audit.
Check what scope excluded (computed, not something you set):
bun $ANT_CONTRACTS_CLI sql "SELECT * FROM v_scope_excluded WHERE run_id='$ANT_CONTRACTS_RUN_ID'"
If excluded == 0, write a trivial 0/0 audit row and stop — there's
nothing to sample. If the question named a single contract by ID and
reformulate's cross-ref grep already returned zero, the same applies.
Otherwise, full-read a random handful of the excluded set against the brief. Search for the entity names, agreement/reference numbers, section anchors, and defined terms you discovered DURING the sweep — not just the original scope predicate (re-applying the same predicate to the set it already excluded is circular and proves nothing). The point is to catch documents the scope filter missed because it didn't yet know the vocabulary. Book the miss rate:
bun $ANT_CONTRACTS_CLI write audits '{"run_id":"'$ANT_CONTRACTS_RUN_ID'","kind":"recall_sample","sample_n":<n>,"result":"{\"misses\":<m>,\"of\":<n>}"}'
set runs $ANT_CONTRACTS_RUN_ID status done. Then follow knowledge-harvest.
tools
Extract plain text from a document file - PDF, DOCX, XLSX, PPTX, RTF, or plain text/markdown/HTML. Use when a binary document needs to be turned into text, for example a contract PDF or an EHR DocumentReference attachment. Other skills (fhir) invoke scripts/extract.ts directly; the contracts MCP server bundles its own copy (servers/documents/src/extract.mjs) so its bundle stays self-contained — port fixes to both.
testing
Answer a question across a corpus of contract documents with verified citations. Use when the user asks what a contract says, which contracts have a clause, what changed between amendments, or any question that needs reading and citing across a set of contract files. The corpus must be on the local filesystem (see README).
tools
Connect to a hospital's FHIR R4 server (Epic, Oracle Health/Cerner, MEDITECH, athenahealth, or any SMART-on-FHIR endpoint), pull a patient's clinical data and notes, and extract structured findings. Use when users say "connect to the EHR", "connect to Epic/Cerner", "pull notes for patient X", "what do the last 6 months of notes say about Y", or any task that starts from a live EHR rather than pasted text.
tools
Assign CPT and HCPCS Level II procedure codes from clinical documentation the way a professional coder builds the claim. Use when users say "code this encounter for procedures", "what CPT codes apply", "assign HCPCS codes", "code this op note", or when turning visit notes or operative reports into claim-ready procedure codes.