mimic-sofa-24h

mimic-sofa-24h is a skill for Claude Code, Codex from hannesill/m4. It costs 0 tokens per session (2,621 once invoked), scanned A, a copy of mimic-apsiii-24h-raw, MIT.

A reference SQL query for calculating the Sequential Organ Failure Assessment (SOFA) score from MIMIC intensive-care data. SOFA is a 0–24 clinical score that summarises problems across six organ systems during a patient's first ICU day.

In plain words
What is it for?
Use it as reference when writing or checking SQL that calculates first-day SOFA scores from MIMIC ICU records.
Why use it?
It provides a documented query pattern for extracting and calculating this specific medical score from the source data.

Skill for Claude CodeCodex

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

Good fit Use it as reference when writing or checking SQL that calculates first-day SOFA scores from MIMIC ICU records.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hannesill/m4/mimic-sofa-24h
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-sofa-24h
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-sofa-24h

README.md
[![agentmods](https://agentmods.dev/badge/skills/hannesill/m4/mimic-sofa-24h/github.svg)](https://agentmods.dev/skills/hannesill/m4/mimic-sofa-24h)
Your own site
<a href="https://agentmods.dev/skills/hannesill/m4/mimic-sofa-24h"><img src="https://agentmods.dev/badge/skills/hannesill/m4/mimic-sofa-24h/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-sofa-24h

Your own site · 80×15
<a href="https://agentmods.dev/skills/hannesill/m4/mimic-sofa-24h"><img src="https://agentmods.dev/badge/skills/hannesill/m4/mimic-sofa-24h.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,621 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.
Origin 100% copy Near-identical to another mod 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.00000 $0.02621
Opus 5 $0.00000 $0.01311
Sonnet 5 $0.00000 $0.00524
Haiku 4.5 $0.00000 $0.00262

Measured 10d ago against content hash f83028155d98, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

mimic-sofa-24h 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 10d 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.

Origin

This is a copy

100% identical to mimic-apsiii-24h-raw — 1,135 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

benchmark/tasks/sofa/mimic-sofa-24h/skills-rawsql/mimic-sofa-24h/SKILL.md · 272 lines

How it starts

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

Reference SQL (matched-content control)

The following block is the public reference SQL used to construct the ground truth for this task. It is provided verbatim, without procedural prose, to test whether matched task-relevant content alone explains the WITH-SKILL gain.

-- ------------------------------------------------------------------
-- Title: Sequential Organ Failure Assessment (SOFA) score
-- This query extracts the SOFA score for the first day of each ICU
-- patient's stay. SOFA quantifies organ dysfunction across 6 systems,
-- each scored 0-4, with a total range of 0-24.
-- ------------------------------------------------------------------

-- Reference for SOFA:
--    Vincent JL et al. "The SOFA (Sepsis-related Organ Failure
--    Assessment) score to describe organ dysfunction/failure."
--    Intensive Care Medicine. 1996;24(7):707-710.

-- Adapted from mimic-code first_day_sofa.sql
-- Uses data from 6 hours before to 24 hours after ICU admission.

-- Components:
--   Respiration: PaO2/FiO2 ratio (arterial only) with ventilation status
--   Coagulation: Platelet count
--   Liver: Bilirubin
--   Cardiovascular: MAP + vasopressor doses (mcg/kg/min)
--   CNS: Glasgow Coma Scale
--   Renal: Creatinine + urine output (mL/day)
--
-- DEVIATION from mimic-code: first_day_sofa does not filter blood gases by
-- specimen. The benchmark restricts PaO2/FiO2 to arterial specimens to match
-- the SOFA definition and task instructions.

WITH vaso_stg AS (
    SELECT
        ie.stay_id,
        'norepinephrine' AS treatment,
        vaso_rate AS rate
    FROM mimiciv_icu.icustays AS ie
    INNER JOIN mimiciv_derived.norepinephrine AS mv
        ON ie.stay_id = mv.stay_id
        AND mv.starttime >= ie.intime - INTERVAL '6' HOUR
        AND mv.starttime <= ie.intime + INTERVAL '1' DAY
    UNION ALL
    SELECT
        ie.stay_id,
        'epinephrine' AS treatment,
        vaso_rate AS rate
    FROM mimiciv_icu.icustays AS ie
    INNER JOIN mimiciv_derived.epinephrine AS mv
        ON ie.stay_id = mv.stay_id
        AND mv.starttime >= ie.intime - INTERVAL '6' HOUR
        AND mv.starttime <= ie.intime + INTERVAL '1' DAY
    UNION ALL
    SELECT
        ie.stay_id,
        'dobutamine' AS treatment,
        vaso_rate AS rate
    FROM mimiciv_icu.icustays AS ie
    INNER JOIN mimiciv_derived.dobutamine AS mv
        ON ie.stay_id = mv.stay_id
        AND mv.starttime >= ie.intime - INTERVAL '6' HOUR
        AND mv.starttime <= ie.intime + INTERVAL '1' DAY
    UNION ALL
    SELECT
        ie.stay_id,
        'dopamine' AS treatment,
        vaso_rate AS rate
    FROM mimiciv_icu.icustays AS ie
    INNER JOIN mimiciv_derived.dopamine AS mv
        ON ie.stay_id = mv.stay_id
        AND mv.starttime >= ie.intime - INTERVAL '6' HOUR
        AND mv.starttime <= ie.intime + INTERVAL '1' DAY
)

, vaso_mv AS (
    SELECT
        ie.stay_id,
        MAX(CASE WHEN treatment = 'norepinephrine' THEN rate ELSE NULL END) AS rate_norepinephrine,
        MAX(CASE WHEN treatment = 'epinephrine' THEN rate ELSE NULL END) AS rate_epinephrine,
        MAX(CASE WHEN treatment = 'dopamine' THEN rate ELSE NULL END) AS rate_dopamine,
        MAX(CASE WHEN treatment = 'dobutamine' THEN rate ELSE NULL END) AS rate_dobutamine
    FROM mimiciv_icu.icustays AS ie
    LEFT JOIN vaso_stg AS v
        ON ie.stay_id = v.stay_id
    GROUP BY
        ie.stay_id
)

, pafi1 AS (
    SELECT
        ie.stay_id,
        bg.charttime,
        bg.pao2fio2ratio,
        CASE WHEN NOT vd.stay_id IS NULL THEN 1 ELSE 0 END AS isvent
    FROM mimiciv_icu.icustays AS ie
    LEFT JOIN mimiciv_derived.bg AS bg
        ON ie.subject_id = bg.subject_id
        AND bg.charttime >= ie.intime - INTERVAL '6' HOUR
        AND bg.charttime <= ie.intime + INTERVAL '1' DAY
        AND bg.specimen = 'ART.'
    LEFT JOIN mimiciv_derived.ventilation AS vd
        ON ie.stay_id = vd.stay_id
        AND bg.charttime >= vd.starttime
        AND bg.charttime <= vd.endtime
        AND vd.ventilation_status = 'InvasiveVent'
)

, pafi2 AS (
    SELECT
        stay_id,
        MIN(CASE WHEN isvent = 0 THEN pao2fio2ratio ELSE NULL END) AS pao2fio2_novent_min,
        MIN(CASE WHEN isvent = 1 THEN pao2fio2ratio ELSE NULL END) AS pao2fio2_vent_min
    FROM pafi1
    GROUP BY
        stay_id
)

, scorecomp AS (
    SELECT
        ie.stay_id,
        v.mbp_min,
        mv.rate_norepinephrine,
        mv.rate_epinephrine,
        mv.rate_dopamine,
        mv.rate_dobutamine,
        l.creatinine_max,
        l.bilirubin_total_max AS bilirubin_max,
        l.platelets_min AS platelet_min,
        pf.pao2fio2_novent_min,
        pf.pao2fio2_vent_min,
        uo.urineoutput,
        gcs.gcs_min
    FROM mimiciv_icu.icustays AS ie
    LEFT JOIN vaso_mv AS mv
        ON ie.stay_id = mv.stay_id
    LEFT JOIN pafi2 AS pf
        ON ie.stay_id = pf.stay_id
    LEFT JOIN mimiciv_derived.first_day_vitalsign AS v
        ON ie.stay_id = v.stay_id
    LEFT JOIN mimiciv_derived.first_day_lab AS l
        ON ie.stay_id = l.stay_id
    LEFT JOIN mimiciv_derived.first_day_urine_output AS uo
        ON ie.stay_id = uo.stay_id
    LEFT JOIN mimiciv_derived.first_day_gcs AS gcs
        ON ie.stay_id = gcs.stay_id
)

, scorecalc AS (
    SELECT
        stay_id,
        CASE
            WHEN pao2fio2_vent_min < 100
            THEN 4
            WHEN pao2fio2_vent_min < 200
            THEN 3
            WHEN pao2fio2_novent_min < 300
            THEN 2
            WHEN pao2fio2_novent_min < 400
            THEN 1
            WHEN COALESCE(pao2fio2_vent_min, pao2fio2_novent_min) IS NULL
            THEN NULL
            ELSE 0
        END AS respiration,
        CASE
            WHEN platelet_min < 20
            THEN 4
            WHEN platelet_min < 50
            THEN 3
            WHEN platelet_min < 100
            THEN 2
            WHEN platelet_min < 150
            THEN 1
            WHEN platelet_min IS NULL
            THEN NULL
            ELSE 0
        END AS coagulation,
        CASE
            WHEN bilirubin_max >= 12.0
            THEN 4
            WHEN bilirubin_max >= 6.0
            THEN 3
            WHEN bilirubin_max >= 2.0
            THEN 2
            WHEN bilirubin_max >= 1.2
            THEN 1
            WHEN bilirubin_max IS NULL
            THEN NULL
            ELSE 0
        END AS liver,
        CASE
            WHEN rate_dopamine > 15 OR rate_epinephrine > 0.1 OR rate_norepinephrine > 0.1
            THEN 4
            -- Deviates from mimic-code which uses <= 0.1 (true for any
            -- non-NULL rate). We use the clinically correct > 0 AND <= 0.1.
            -- No effect on derived values: vasopressor tables only contain
            -- rows with positive rates, so the conditions are equivalent.
            WHEN rate_dopamine > 5 OR (rate_epinephrine > 0 AND rate_epinephrine <= 0.1) OR (rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1)
            THEN 3
            WHEN rate_dopamine > 0 OR rate_dobutamine > 0
            THEN 2
            WHEN mbp_min < 70
            THEN 1
            WHEN COALESCE(mbp_min, rate_dopamine, rate_dobutamine, rate_epinephrine, rate_norepinephrine) IS NULL
            THEN NULL
            ELSE 0
        END AS cardiovascular,
        CASE
            WHEN (gcs_min >= 13 AND gcs_min <= 14)
            THEN 1
            WHEN (gcs_min >= 10 AND gcs_min <= 12)
            THEN 2
            WHEN (gcs_min >= 6 AND gcs_min <= 9)
            THEN 3
            WHEN gcs_min < 6
            THEN 4
            WHEN gcs_min IS NULL
            THEN NULL
            ELSE 0
        END AS cns,
        CASE
            WHEN (creatinine_max >= 5.0)
            THEN 4
            WHEN urineoutput < 200
            THEN 4
            WHEN (creatinine_max >= 3.5 AND creatinine_max < 5.0)
            THEN 3
            WHEN urineoutput < 500
            THEN 3
            WHEN (creatinine_max >= 2.0 AND creatinine_max < 3.5)
            THEN 2
            WHEN (creatinine_max >= 1.2 AND creatinine_max < 2.0)
            THEN 1
            WHEN COALESCE(urineoutput, creatinine_max) IS NULL
            THEN NULL
            ELSE 0
        END AS renal
    FROM scorecomp
)

SELECT
    ie.subject_id, ie.hadm_id, ie.stay_id
    -- Combine all the scores to get SOFA
    -- Impute 0 if the score is missing
    , COALESCE(respiration, 0)
    + COALESCE(coagulation, 0)
    + COALESCE(liver, 0)
    + COALESCE(cardiovascular, 0)
    + COALESCE(cns, 0)
    + COALESCE(renal, 0)
    AS sofa
    -- DEVIATION from mimic-code: COALESCE component scores to 0.
    -- The original SQL leaves them NULL when underlying data is missing.
    -- We impute 0 here so the ground truth matches the task instruction
    -- ("treat missing data as normal, score 0") and agents are not
    -- penalised for following the instruction. The NULL→0 semantics are
    -- already applied to the sofa total above; this extends it to the
    -- individual components for consistency.
    , COALESCE(respiration, 0) AS respiration
    , COALESCE(coagulation, 0) AS coagulation
    , COALESCE(liver, 0) AS liver
    , COALESCE(cardiovascular, 0) AS cardiovascular
    , COALESCE(cns, 0) AS cns
    , COALESCE(renal, 0) AS renal
FROM mimiciv_icu.icustays ie
LEFT JOIN scorecalc s
          ON ie.stay_id = s.stay_id
;

Read the full file on GitHub · 272 lines

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. 10d ago First seen · 272 lines · 0 tokens per session scan A f83028155d98

Subscribe to this mod's changes

mimic-sofa-24h is a skill published in the GitHub repository hannesill/m4 (43 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,621 tokens. A static security scan graded it A with 0 findings. It is 100% identical to mimic-apsiii-24h-raw, differing in 1,135 lines, and is treated as a copy.

Related

Other skills, from other repositories

arbor-agent-orchestrator

Top-level controller for recreating the open-source AutoResearch workflow as a suite of skills. Use when the user asks to run, emulate, extract, validate, or refine Arbor/AutoResearch behavior, especially when a coordinator must load phase skills for setup, ideation, executors, merge evaluation, novelty search…

RUC-NLPIR/Arbor · 77 tokens

dfam-check

Measure mesh files against Design for Additive Manufacturing (DfAM) rules and report printability findings per process (FDM, SLS, SLA/DLP, metal PBF, MJF). Use when the user asks whether a part is printable, wants overhang/wall-thickness/support analysis of an .stl, .obj, .ply, or .3mf mesh, wants a build-orientation…

earthtojake/text-to-cad · 111 tokens

tooluniverse-gene-enrichment

Gene-set enrichment analysis — GO (Biological Process, Molecular Function, Cellular Component), KEGG, Reactome pathway enrichment via clusterProfiler, gseapy, ORA, GSEA. Use for interpreting DEG lists, screen hit lists, or any gene-list-to-pathways query. Includes simplify-cutoff handling and union-vs-total…

mims-harvard/ToolUniverse · 82 tokens

tooluniverse-phylogenetics

Phylogenetic analysis — de novo multiple sequence alignment (Clustal Omega/MUSCLE/MAFFT via EBImsaalign) and neighbour-joining/UPGMA tree building (EBIbuildphylogenetictree) from your own sequences, plus tree analysis, treeness, saturation (PhyKIT), parsimony-informative sites, alignment gap analysis, DVMC…

mims-harvard/ToolUniverse · 155 tokens

tooluniverse-cell-line-profiling

Cancer cell-line selection and profiling for experimental model choice. Cross-references DepMap, Cellosaurus, COSMIC, PharmacoDB to deliver identity verification, mutation/CNV profile, gene dependencies, drug sensitivities, and druggable targets. Use to answer 'which cell line should I use for studying gene X?' or 'is…

mims-harvard/ToolUniverse · 100 tokens

tooluniverse-pharmacogenomics

Pharmacogenomics (PGx) research — drug-gene interactions (CPIC, PharmGKB), CPIC dosing guidelines, variant-drug-response associations, ethnic-allele-frequency considerations, and metabolizer-status scoring. Use for PGx-informed dosing recommendations, CYP/HLA pharmacogenomic allele interpretation, and…

mims-harvard/ToolUniverse · 80 tokens