A structured knowledge file (SKILL.md) that gives AI assistants knowledge of NONMEM, covering control-stream authoring, dataset conventions, estimation method selection and output interpretation for population PK/PD modeling.
SKILL.md is a plain-Markdown convention for packaging domain knowledge so AI assistants can load it as context. It is not tied to any specific tool — the file can be used with Claude Code, cursor rules, system prompts, or any assistant that supports injecting structured context files.
For more information about the SKILL.md convention, see https://agentskills.io/home.
This skill is a proof of concept to study AI pair programming for pharmacometricians. It does not take modeling decisions can create an evaluate NONMEM code based on natural language.
It covers the cases that come up in practice: NONMEM, NM-TRAN, PREDPP, control streams, $PROBLEM/$PK/$ESTIMATION blocks, ADVAN/TRANS routines, estimation methods (FOCE, SAEM, IMP, BAYES, NUTS), dataset items (EVID, AMT, RATE, ADDL, SS, MDV), output files (.lst, .ext, .phi, .cov, .cor), and VPCs/pcVPCs.
nonmem-skill/
├── SKILL.md # Main daily-driver reference (load first)
└── references/
├── advan-trans.md # ADVAN/TRANS selection guide and parameter tables
├── control-records.md # Detailed $-record syntax reference
├── diagnostics-vpc.md # VPC, pcVPC, CWRES, NPDE, shrinkage
└── common-errors.md # Error messages and recovery playbook
SKILL.md is the entry point. It covers:
- Workflow: read the existing model before suggesting changes; check data layout; make minimal, syntactically valid edits
- Control-stream skeleton (two-compartment IV example with all common records)
- Dataset conventions — EVID codes, dose/observation interleaving, bolus vs infusion, SS/II/ADDL, MDV, CMT, sort order
- MU referencing — when it is required (EM/Bayes methods) and how to write it correctly
- Estimation method choice — FOCE/FOCEI, Laplace, ITS, SAEM, IMP, BAYES, NUTS, and common multi-method chains
- Output file guide —
.lst,.ext,.phi,.cov,.cor,.tab,.shk,.xml - VPC and pcVPC overview
The reference files are pulled in as needed for deeper tasks.
Point your AI assistant at nonmem-skill/SKILL.md as a context or system file. The frontmatter (name, description) tells the assistant when to activate the skill; the body is the knowledge it uses. The reference files under references/ are cross-linked from SKILL.md and can be loaded on demand when a task needs that depth.
The example/ directory contains a worked theophylline one-compartment oral PK example:
theophylline.original.txt— the source dataset downloaded from https://novartis.schloerke.com/datasets/theophylline.html.prompt.txt— the user prompt that triggered the skilltheophylline.ctl— the generated NONMEM control streamtheophylline.res— the run output (.lstequivalent)
The skill handles:
- Writing and editing control streams (
.ctl,.mod,.nm) - Fixing NM-TRAN translation errors and NONMEM runtime errors
- Choosing the right ADVAN/TRANS for a given PK/PD model structure
- MU-referencing for EM and Bayesian methods
- Dataset construction and event-record encoding
- Setting up multi-method estimation chains (ITS → SAEM → IMP)
- Interpreting
.lst,.ext,.phi,.cov,.coroutputs - Diagnosing convergence problems and covariance step failures
- Setting up VPC and pcVPC simulation control streams
- Reading shrinkage, CWRES, NPDE diagnostics
The skill cross-references the standard NONMEM documentation set:
- NONMEM User Guides I–VIII
intro7.pdf(NONMEM 7.6.0 introduction)NONMEM7_Technical_Guide.pdf- Bauer 2019 CPT-PSP Tutorial Parts I and II
- Bergstrand 2011 pcVPC paper and the PMX Solutions step-by-step VPC guide
These are not bundled here; the skill points to them when a question needs authoritative detail beyond what the reference files cover.