mimic-table-relationships

mimic-table-relationships is a skill for Claude Code, Codex from hannesill/m4. It costs 56 tokens per session (1,050 once invoked), scanned A, original, MIT.

A guide to how tables in MIMIC-IV, a medical database of hospital and intensive-care data, relate to one another. It explains identifiers such as patient, hospital admission, and ICU-stay IDs and how to join records safely.

In plain words
What is it for?
Use it when writing or debugging SQL queries that join MIMIC-IV patients, admissions, ICU stays, laboratory results, diagnoses, prescriptions, or event records.
Why use it?
It helps prevent duplicate rows, missing records, and incorrect links when combining data from different hospital or ICU tables.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or debugging SQL queries that join MIMIC-IV patients, admissions, ICU stays, laboratory results, diagnoses, prescriptions, or event records.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hannesill/m4/mimic-table-relationships
View source ↗ hannesill/m4
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add hannesill/m4 --skill mimic-table-relationships
Clone the repo
git clone --depth 1 https://github.com/hannesill/m4

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mimic-table-relationships

README.md
[![agentmods](https://agentmods.dev/badge/skills/hannesill/m4/mimic-table-relationships/github.svg)](https://agentmods.dev/skills/hannesill/m4/mimic-table-relationships)
Your own site
<a href="https://agentmods.dev/skills/hannesill/m4/mimic-table-relationships"><img src="https://agentmods.dev/badge/skills/hannesill/m4/mimic-table-relationships/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mimic-table-relationships

Your own site · 80×15
<a href="https://agentmods.dev/skills/hannesill/m4/mimic-table-relationships"><img src="https://agentmods.dev/badge/skills/hannesill/m4/mimic-table-relationships.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,050 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00056 $0.01050
Opus 5.5 $0.00022 $0.00420
Sonnet 5.5 $0.00011 $0.00210
Haiku 4.5 $0.00006 $0.00105

Measured 1mo ago against content hash 32be4507039f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

mimic-table-relationships scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/m4/skills/system/mimic-table-relationships/SKILL.md · 75 lines

How it starts

The opening of the file, as written. The whole thing — 75 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MIMIC-IV Table Relationships

subject_id (patient) → hadm_id (hospital admission) → stay_id (ICU stay). One admission can hold several ICU stays, so each event needs the right key and a time window.

1. Join on the key the table is recorded under

Key Tables
stay_id chartevents, inputevents, ingredientevents, outputevents, procedureevents, datetimeevents. Derived: vitalsign, gcs, urine_output, first_day_*, scores (sofa: stay_id + hr)
hadm_id admissions, diagnoses_icd, procedures_icd, prescriptions, pharmacy, emar, services. Derived: charlson
subject_id + time labevents, microbiologyevents, omr. Derived lab panels, one row per specimen: chemistry, complete_blood_count, bg, ...

hadm_id is NULL for labs and cultures taken outside an admission, including ED draws before an ICU admission: 26% of labevents and 33% of microbiologyevents in the demo, and the derived lab panels inherit the NULLs. Join these on subject_id plus a time window; a hadm_id join drops them.

diagnoses_icd and procedures_icd have no time and repeat for every ICU stay of the admission.

2. Bound every event by the stay's time window

Without a window, a hadm_id or subject_id join copies each event to every ICU stay of the admission or patient. M4's first_day_lab uses intime - 6 h to intime + 24 h:

-- Highest creatinine (itemid 50912) from 6 h before to 24 h after ICU admission
SELECT ie.stay_id, MAX(le.valuenum) AS creatinine_max
FROM mimiciv_icu.icustays ie
LEFT JOIN mimiciv_hosp.labevents le
  ON le.subject_id = ie.subject_id
 AND le.itemid = 50912
 AND le.charttime >= ie.intime - INTERVAL 6 HOUR
 AND le.charttime <= ie.intime + INTERVAL 1 DAY
GROUP BY ie.stay_id;

Put the window in the LEFT JOIN ... ON clause to keep stays without a value. Back-to-back stays can have overlapping windows, so one lab can count for both; that is intended for per-stay features.

Check a join for duplication:

SELECT COUNT(*) AS joined_rows,
       COUNT(*) - COUNT(DISTINCT le.labevent_id) AS duplicated_rows
FROM mimiciv_icu.icustays ie
JOIN mimiciv_hosp.labevents le ON le.hadm_id = ie.hadm_id;  -- unbounded: duplicates

Read the full file on GitHub · 75 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · -115 lines · +20 tokens per session 32be4507039f
  2. 2mo ago Changed · +1 lines da7a2aeede8e
  3. 3mo ago First seen · 189 lines · 36 tokens per session scan A 64e4c0dcce83

Subscribe to this mod's changes

mimic-table-relationships is a skill published in the GitHub repository hannesill/m4 (52 stars, last pushed 1mo ago), licensed MIT. It adds 56 tokens to every session and 1,050 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

mimic-table-relationships compared with skills from other repositories

mimic-table-relationships next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
mimic-table-relationshipshannesill/m4Skill521mo agoMITA56Claude Code, Codex
arbor-agent-orchestratorRUC-NLPIR/ArborSkill1.2k27d agoApache-2.0A77Claude Code, Codex
embeddingsruvnet/rufloSkill83ktodayMITA62Claude Code
migration-reviewrohitg00/ai-engineering-from-scratchSkill81ktodayMITA35Claude Code
tooluniverse-phylogeneticsmims-harvard/ToolUniverseSkill1.8kyesterdayApache-2.0A155Claude Code
tooluniverse-cancer-variant-interpretationmims-harvard/ToolUniverseSkill1.8kyesterdayApache-2.0A93Claude Code
tooluniverse-cell-line-profilingmims-harvard/ToolUniverseSkill1.8kyesterdayApache-2.0A100Claude Code