nlmixr2llm

LLM-facing documentation for the nlmixr2 pharmacometric modeling ecosystem in R, distributed as an R package and as a Claude Code plugin.
The content is organized around the tasks a pharmacometrician performs rather than around individual packages: a single nlmixr2verse agent routes work across four task skills — simulation, estimation, reporting, and interop (NONMEM / Monolix / PKNCA). The same content is shipped two ways:
- As an R package, with accessor functions for use as a system prompt with any LLM client (
ellmer, the Anthropic SDK, the OpenAI SDK, ...) and installers that write the files into the locations expected by Claude Code, OpenAI Codex CLI, Positron Assistant, and other tools that follow the AGENTS.md convention.
- As a Claude Code plugin via the
.claude-plugin/ directory at the repo root, so users who already use the Claude Code plugin marketplace can install without touching R.
Coverage
| Task | What it covers | Packages |
|---|
simulation | Author and debug ODE PK/PD models, event tables, single-subject / population / clinical-trial simulation, parameter uncertainty, resampling fitted subjects, the model library | rxode2, nlmixr2lib |
estimation | Fit population PK/PD models (SAEM, FOCEi, nlme), model building, covariates, standard errors, bootstrap, likelihood profiling, model comparison, neural networks inside models | nlmixr2, nlmixr2extra, nlmixr2lib, nlmixr2nn, nlmixr2auto |
reporting | Goodness-of-fit diagnostics, VPCs, augmented predictions, parameter tables, Word / PowerPoint / R Markdown reports, interactive review | nlmixr2plot, xpose.nlmixr2, ggPMX, nlmixr2rpt, shinyMixR |
interop | Run an nlmixr2 model in NONMEM / Monolix / PKNCA; import finished NONMEM or Monolix runs into R and qualify the translation; cross-engine comparison | babelmixr2, nonmem2rx, monolix2rx |
design | Optimal design for a planned study: expected precision (RSE%) and shrinkage, optimizing sampling times and doses, comparing group sizes, Ds / ED criteria, prior information, power | babelmixr2, PopED |
Each skill is a directory: a compact SKILL.md (~7-10 KiB) plus references/*.md files with extra depth (engine-specific NONMEM / Monolix notes, babelmixr2's in-R backends and PopED, population-simulation patterns, uncertainty and priors, adaptive dosing, the full estimation-method list, priors in estimation, model-building and precision recipes, the nlmixr2rpt YAML structure). The nlmixr2verse agent (~10 KiB) holds the ecosystem map by task, routing rules, the shared model-language conventions, and how the stages hand off to one another (simulate ⇄ estimate → report; import → qualify → simulate).
Install (R package)
# install.packages("remotes")
remotes::install_github("john-harrold/nlmixr2llm")
Usage
Use as a system prompt with any LLM client
library(nlmixr2llm)
prompt <- system_prompt(tasks = c("simulation", "estimation"))
# Example: with ellmer
chat <- ellmer::chat_anthropic(system_prompt = prompt)
chat$chat("Write a one-compartment PK model with first-order absorption and simulate 100 mg q12h for 5 days.")
Add references = TRUE to include each skill's supporting reference files.
Install into Claude Code
# User-level (~/.claude/agents/, ~/.claude/skills/)
install_claude_code(scope = "user")
# Or project-local (.claude/agents/, .claude/skills/) under the current project
install_claude_code(scope = "project")
Install into OpenAI Codex CLI