$npx -y skills add RConsortium/pharma-skills --skill clinical-trial-simulationDesign and simulate clinical trials using the TrialSimulator R package and produce a QC-ready build-order-spine report that pairs each block of code with rationale, parameters, and operating characteristics.
| 1 | # TrialSimulator Skill |
| 2 | |
| 3 | Help a biostatistician design and simulate a clinical trial using the |
| 4 | TrialSimulator R package, then write a readable report. This skill is |
| 5 | a thinking framework, a cached API reference, a TrialSimulator-specific |
| 6 | function catalog, and a report-writing guide. **It is not a script.** |
| 7 | You bring general engineering, programming, and biostatistics |
| 8 | knowledge; this skill adds what is specific to TrialSimulator. |
| 9 | |
| 10 | ## Loading announcement |
| 11 | |
| 12 | Whenever this skill is loaded, the agent calls |
| 13 | `packageVersion("TrialSimulator")` (fast, local — no network) and |
| 14 | compares the installed version against |
| 15 | `metadata.trialsimulator_min_version` from the YAML frontmatter |
| 16 | above. The first line of the agent's first response reports the |
| 17 | result. |
| 18 | |
| 19 | Three outcomes: |
| 20 | |
| 21 | - **Installed ≥ required** — `clinical-trial-simulation v<metadata.version> loaded — TrialSimulator <ts_version>, R <r_version>`. Proceed. |
| 22 | - **Installed < required** — `clinical-trial-simulation v<metadata.version> loaded — TrialSimulator <ts_version> installed, **≥ <trialsimulator_min_version> required**. R <r_version>.` Then offer to update on the next turn: *"Want me to run `remotes::install_github('zhangh12/TrialSimulator')` now? (y/n)"* — on confirm, run it and re-check; on decline, stop until the user resolves. Do not begin any simulation work until the version requirement is met. |
| 23 | - **Not installed** — `clinical-trial-simulation v<metadata.version> loaded — TrialSimulator not installed. R <r_version>.` Offer to install: *"Want me to run `remotes::install_github('zhangh12/TrialSimulator')` now? (y/n)"* |
| 24 | |
| 25 | Substitutions: |
| 26 | |
| 27 | - `<metadata.version>` from this file's YAML frontmatter. |
| 28 | - `<trialsimulator_min_version>` from this file's YAML frontmatter. |
| 29 | - `<ts_version>` from `packageVersion("TrialSimulator")`. |
| 30 | - `<r_version>` from `R.version.string` (the `x.y.z` portion). |
| 31 | |
| 32 | No network call fires on load. The only network use is the optional |
| 33 | remediation install on user confirmation. |
| 34 | |
| 35 | After the announcement line, briefly greet the user and ask about |
| 36 | the trial setting — never ask what design type, discover it through |
| 37 | conversation (see "Two user modes" below). |
| 38 | |
| 39 | ## Files in this skill |
| 40 | |
| 41 | - `SKILL.md` (this file) — framework, conversation principles, build order, workflow |
| 42 | - `references/building_blocks.md` — cached reference for `endpoint`, `arm`, `trial`, `milestone`, `listener`, `controller`, `regimen`, and the condition system |
| 43 | - `references/helpers.md` — catalog of TrialSimulator-provided functions (RNGs, parameter solvers, analysis wrappers, post-sim utilities), plus non-obvious gotchas |
| 44 | - `references/report.md` — how to write the simulation report (intentionally policy-light; organizations are encouraged to edit this file) |
| 45 | |
| 46 | These files cache the most common things to save tokens. When confused |
| 47 | or when behavior contradicts these notes, consult `?<function>` in R |
| 48 | or the package's pkgdown site at |
| 49 | https://zhangh12.github.io/TrialSimulator/. Don't guess — the manual |
| 50 | is the source of truth. |
| 51 | |
| 52 | ## Package source |
| 53 | |
| 54 | This skill targets a known-good baseline of TrialSimulator declared |
| 55 | in `metadata.trialsimulator_min_version` of the YAML frontmatter |
| 56 | above. **At load, only a local `packageVersion("TrialSimulator")` |
| 57 | check runs — no automatic `install_github`, no network call.** The |
| 58 | load-time check + offer/auto behavior is specified in "Loading |
| 59 | announcement". |
| 60 | |
| 61 | If TrialSimulator is missing or below the minimum, the canonical |
| 62 | remediation is: |
| 63 | |
| 64 | ```r |
| 65 | remotes::install_github("zhangh12/TrialSimulator") |
| 66 | ``` |
| 67 | |
| 68 | The agent offers to run this when the load-time check detects a |
| 69 | shortfall and only runs it on user confirmation. The user can also |
| 70 | update outside the session and reload the skill. |
| 71 | |
| 72 | When bumping `metadata.version`, audit whether |
| 73 | `trialsimulator_min_version` also needs to move — e.g., if the |
| 74 | skill adopts a TS feature or fix landed in a newer release. |
| 75 | |
| 76 | Surface three versions in §0 of the report: TrialSimulator, R, and |
| 77 | the skill. The agent looks each value up once before writing the |
| 78 | report and pastes the literal string into the §0 table. No R chunks, |
| 79 | no runtime lookup, no `readRDS`. Slight staleness on re-renders is |
| 80 | acceptable; the running environment is assumed stable. |
| 81 | |
| 82 | ## Package philosophy |
| 83 | |
| 84 | TrialSimulator decouples a trial into a small set of independent |
| 85 | building blocks: endpoints, arms, the trial object, milestones, the |
| 86 | listener, the controller, and (optionally) regimens for treatment |
| 87 | switching. **A trial design — fixed, seamless, response-adaptive, |
| 88 | dose-ranging, platform, anything — is just a particular composition of |
| 89 | these blocks.** There is no "design type" object; there are only blocks |
| 90 | and how they combine. |
| 91 | |
| 92 | Practical implication: do not pick a design temp |