m4-api

m4-api is a skill for Claude Code, Codex from hannesill/m4. It costs 38 tokens per session (1,710 once invoked), scanned A, original, MIT.

A Python interface for querying clinical datasets and working with results as native Python values or pandas tables.

In plain words
What is it for?
Use it to inspect dataset schemas, run SQL, combine query results, and perform analysis with Python, pandas, or numerical libraries.
Why use it?
It supports multi-step analysis, large query results, joins, calculations, and statistics without repeatedly formatting data for display.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/hannesill/m4/m4-api
Any agent
npx skills add hannesill/m4 --skill m4-api
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 m4-api

README.md
[![agentmods](https://agentmods.dev/badge/skills/hannesill/m4/m4-api.svg)](https://agentmods.dev/skills/hannesill/m4/m4-api)
Your own site
<a href="https://agentmods.dev/skills/hannesill/m4/m4-api"><img src="https://agentmods.dev/badge/skills/hannesill/m4/m4-api.svg" alt="Measured on agentmods" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,710 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00038 $0.01710
Opus 5 $0.00019 $0.00855
Sonnet 5 $0.00008 $0.00342
Haiku 4.5 $0.00004 $0.00171

Measured 4d ago against content hash a6ae7b2497b3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

m4-api 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 4d 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/m4-api/SKILL.md · 168 lines

How it starts

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

M4 Python API

The M4 Python API provides programmatic access to clinical datasets for code execution environments. It mirrors the MCP tools but returns native Python types (DataFrames, dicts) instead of formatted strings.

When to Use the API vs MCP Tools

Use the Python API when:

  • Complex clinical analysis - Multi-step analyses that require intermediate results, joins across queries, or statistical computations
  • Large result sets - Query results with thousands of rows can be stored in DataFrames without dumping into context
  • Mathematical operations - Aggregations, percentile calculations, statistical tests, and counting that benefit from pandas/numpy
  • Iterative exploration - Building up analysis through multiple queries where each step informs the next

Use MCP tools when:

  • Simple one-off queries where the result fits comfortably in context
  • Interactive exploration where you want to see results immediately

Required Workflow

You must follow this sequence:

  1. Choose a dataset name and pass it explicitly, or create M4Client(dataset=...)
  2. get_schema(dataset=...) / get_table_info(..., dataset=...) - Explore available tables
  3. execute_query() - Run SQL queries
from m4 import get_schema, get_table_info, execute_query

dataset = "mimic-iv"  # or "mimic-iv-demo", "eicu", "mimic-iv-note"

# Step 1: Explore schema
schema = get_schema(dataset=dataset)
print(schema['tables'])  # List of table names

# Step 2: Inspect specific tables before querying
info = get_table_info("mimiciv_hosp.patients", dataset=dataset)
print(info['schema'])  # DataFrame with column names, types
print(info['sample'])  # DataFrame with sample rows

# Step 3: Execute queries
df = execute_query(
    "SELECT gender, COUNT(*) as n FROM mimiciv_hosp.patients GROUP BY gender",
    dataset=dataset,
)
# Returns pd.DataFrame - use pandas operations freely

API Reference

Dataset Management

Function Returns Description
list_datasets() list[str] Available dataset names
M4Client(dataset=...) M4Client Preferred explicit client for one dataset
client.with_dataset(name) M4Client New client with the same session context and a different dataset
client.switch_dataset(name) M4Client Mutate a client to another dataset for notebook-style sessions

Read the full file on GitHub · 168 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. 4d ago First seen · 168 lines · 38 tokens per session scan A a6ae7b2497b3

Subscribe to this mod's changes

m4-api is a skill published in the GitHub repository hannesill/m4 (43 stars, last pushed 1mo ago), licensed MIT. It adds 38 tokens to every session and 1,710 once invoked, about $0.0002 per session on Opus 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

Other skills, from other repositories

experiment_management

Set up and manage the experiment folder structure. This is Phase 0 — it runs before any analysis begins. All bookkeeping files are JSON (never markdown).

Upsonic/Upsonic · 0 tokens

evaluate

Compare baseline and new implementation results. Produce the machine-readable final report result.json, update experiments.json, and append a row to comparison.json.

Upsonic/Upsonic · 0 tokens

implement

Create a new Jupyter notebook implementing the method from the research paper, using the same data as the baseline. Record implementation details and measured metrics as a structured JSON entry.

Upsonic/Upsonic · 0 tokens

progress

Maintain a machine-readable progress file so dashboards, CLIs, and notebooks can poll the experiment's state at any time. The file is a JSON document — never markdown, never human-prose-first.

Upsonic/Upsonic · 0 tokens

optimize

Drive structured autoresearch iteration after evo:discover and the baseline commit. Use when the user invokes /evo:optimize or asks to try ideas, try variants, run experiments, use available GPUs, improve the current best/frontier, continue an evo search, or compare candidate changes in an evo workspace. The…

evo-hq/evo · 113 tokens

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