# ClinicalTrialAgent
> **Clinical Trial Design & Simulation Ecosystem** — A Claude Code plugin for power analysis, sample size determination, group sequential designs, and multiplicity optimization
[](LICENSE)
## Overview
ClinicalTrialAgent is a comprehensive [Claude Code](https://docs.claude.com/en/docs/claude-code/overview) plugin for clinical trial simulations using R. It provides AI-assisted workflows for:
- **Power Analysis** — Calculate statistical power across treatment effect scenarios
- **Sample Size Determination** — Find minimum sample sizes via simulation-based search
- **Group Sequential Designs** — Interim analyses with alpha spending and futility stopping
- **Multiplicity Optimization** — Select and tune multiple testing procedures
- **Clinical Scenario Evaluation** — Multi-scenario simulations with automated reporting
### Supported R Frameworks
| Framework | Purpose | Key Features |
|-----------|---------|--------------|
| **simtrial** | Time-to-event/survival | Piecewise exponential, weighted logrank, MaxCombo, RMST |
| **Mediana** | Clinical Scenario Evaluation | Multi-scenario power, multiplicity, Word reports |
| **gsDesign2** | Group sequential | Alpha spending, futility boundaries |
## Quick Start
### 1. Add the Marketplace
```bash
/plugin marketplace add choxos/ClinicalTrialAgent
```
### 2. Install the Plugin
```bash
/plugin install clinical-trial-simulation
```
### 3. Install R Dependencies
```r
install.packages(c("simtrial", "Mediana", "gsDesign2", "survival", "dplyr", "data.table", "mvtnorm"))
```
### 4. Start Using
```
Calculate power for a survival trial with HR=0.7, 300 events, alpha=0.025
```
## Components
### Agents (7)
| Agent | Model | Purpose |
|-------|-------|---------|
| `simulation-architect` | Haiku | Routes requests to specialists |
| `tte-specialist` | Sonnet | Time-to-event simulations (simtrial) |
| `cse-specialist` | Sonnet | Clinical Scenario Evaluation (Mediana) |
| `multiplicity-expert` | Sonnet | Multiple testing procedures |
| `gs-design-specialist` | Sonnet | Group sequential designs |
| `power-optimizer` | Opus | Sample size/power optimization |
| `code-reviewer` | Sonnet | R code validation |
### Commands (5)
| Command | Description |
|---------|-------------|
| `/power-analysis` | Calculate power across scenarios |
| `/sample-size` | Find minimum sample size for target power |
| `/gs-design` | Design group sequential trials |
| `/multiplicity-optimization` | Select and optimize testing procedures |
| `/cse-analysis` | Full Clinical Scenario Evaluation workflow |
### Skills (7)
- `simtrial-fundamentals` — Core simtrial package reference
- `mediana-fundamentals` — CSE framework reference
- `multiplicity-methods` — Holm, Hochberg, Chain, Gatekeeping
- `time-to-event-methods` — Weighted logrank, MaxCombo, RMST
- `group-sequential-methods` — Alpha spending, futility
- `power-optimization-patterns` — Direct/tradeoff optimization
- `clinical-trial-design-patterns` — Multi-arm, adaptive designs
## Repository Structure
```
ClinicalTrialAgent/
├── .claude-plugin/
│ └── marketplace.json # Plugin manifest
├── plugins/
│ └── clinical-trial-simulation/
│ ├── agents/ # 7 specialized agents
│ ├── commands/ # 5 workflow commands
│ ├── skills/ # 7 knowledge skills
│ ├── README.md # Detailed plugin documentation
│ └── LICENSE
└── refs/ # Reference materials
├── simtrial-main/ # simtrial R package source
├── Mediana-master/ # Mediana R package source
└── clinical-trial-optimization-using-r.md
```
## Usage Examples
### Power Analysis (Time-to-Event)
```
Calculate power for a two-arm survival trial:
- Hazard ratio: 0.7
- Target events: 300
- Alpha: 0.025 one-sided
```
### Sample Size (Continuous Endpoint)
```
What sample size for 90% power to detect a 5-unit difference (SD=15)?
```
### Group Sequential Design
```
Design a 3-look trial with O'Brien-Fleming spending and non-binding futility
```
### Multiplicity
```
I have 2 doses vs control with PFS (primary) and OS (secondary).
Help me select a gatekeeping procedure.
```
See the [plugin README](plugins/clinical-trial-simulation/README.md) for detailed examples with R code.
## Related Plugins
This plugin is part of a suite of Claude Code plugins for statistical modeling:
- [BayesianAgent](https://github.com/choxos/BayesianAgent) — Bayesian modeling with Stan, PyMC, JAGS
- [ITC-agents](https://github.com/choxos/ITC-agents) — Indirect treatment comparisons (NMA, MAIC, STC)
- [TidyRModelling](https://github.com/choxos/TidyRModelling) — Tidy modeling workflows in R
## References
- Dmitrienko A, D'Agostino RB (2018). *Clinical Trial Optimization Using R*. Chapman & Hall/CRC.
- Anderson KM, et al. (2022). "simtrial: Clinical Trial Simulation." R package.
- Benda N, et al. (2010). "Clinical scenario planning and evaluation." *Drug Information Journal*.
## License
MIT License — see [LICENSE](plugins/clinical-trial-simulation/LICENSE) for details.
## Acknowledgments
- [Merck & Co.](https://github.com/Merck/simtrial) for simtrial
- [Mediana Inc.](https://github.com/medianasoft/Mediana) for Mediana
- [Anthropic](https://www.anthropic.com/) for Claude Code