Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Clinical trial methodology, biostatistics, and study design guidance
.claude/skills/brycewang-stanford-clinical-trial-design-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 40% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 112% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 124% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 118% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 164% | 0% |
A skill for designing and analyzing clinical trials, covering study design selection, sample size calculation, randomization methods, interim analysis, survival endpoints, and regulatory considerations. Essential for pharmaceutical researchers, biostatisticians, and clinical scientists.
| Phase | Objective | Typical N | Duration | Primary Endpoints | |-------|-----------|----------|----------|-------------------| | Phase I | Safety, dose-finding | 20-80 | Months | MTD, DLT, PK profile | | Phase II | Efficacy signal, dosing | 100-300 | 1-2 years | Response rate, biomarker | | Phase III | Confirmatory efficacy | 300-3,000+ | 2-4 years | OS, PFS, clinical outcome | | Phase IV | Post-marketing surveillance | 1,000+ | Ongoing | Safety, real-world effectiveness |
Parallel Group (most common Phase III):
R --> Treatment A --> Outcome assessment
R --> Treatment B --> Outcome assessment
Crossover:
R --> Treatment A --> Washout --> Treatment B --> Outcome
R --> Treatment B --> Washout --> Treatment A --> Outcome
Factorial (2x2):
R --> Drug A + Drug B
R --> Drug A + Placebo B
R --> Placebo A + Drug B
R --> Placebo A + Placebo B
Adaptive:
Stage 1: Enroll n1 patients --> Interim analysis
Stage 2: Modify design (dose, sample size, arm dropping) --> Continue| Factor | Recommended Design | |--------|-------------------| | Chronic disease, stable condition | Crossover (within-subject comparison) | | Acute condition, one-time treatment | Parallel group | | Multiple drugs to evaluate | Factorial or multi-arm | | High uncertainty in effect size | Adaptive (sample size re-estimation) | | Rare disease, limited patients | Bayesian adaptive, single-arm with historical control |
pythonfrom scipy.stats import norm import numpy as np def sample_size_two_means(delta: float, sigma: float, alpha: float = 0.05, power: float = 0.80, ratio: float = 1.0) -> dict: """ Sample size for comparing two group means (two-sided test). delta: minimum clinically important difference sigma: pooled standard deviation alpha: type I error rate power: desired power (1 - beta) ratio: allocation ratio (n2/n1) """ z_alpha = norm.ppf(1 - alpha / 2) z_beta = norm.ppf(power) effect = delta / sigma n1 = ((z_alpha + z_beta) ** 2 * (1 + 1 / ratio)) / effect ** 2 n2 = ratio * n1 return { "n_per_group_1": int(np.ceil(n1)), "n_per_group_2": int(np.ceil(n2)), "total": int(np.ceil(n1) + np.ceil(n2)), "effect_size": round(effect, 3), } # Example: detect 5-point difference, SD=15, 80% power result = sample_size_two_means(delta=5, sigma=15) print(f"Required: {result['total']} total patients")
pythondef sample_size_logrank(hazard_ratio: float, alpha: float = 0.05, power: float = 0.80, ratio: float = 1.0, median_control: float = 12.0, accrual_time: float = 24.0, followup_time: float = 12.0) -> dict: """ Sample size for log-rank test comparing two survival curves. hazard_ratio: expected HR (treatment/control), <1 means treatment better median_control: median survival in control arm (months) """ z_alpha = norm.ppf(1 - alpha / 2) z_beta = norm.ppf(power) # Required number of events (Schoenfeld formula) d = ((z_alpha + z_beta) ** 2 * (1 + ratio) ** 2) / ( ratio * (np.log(hazard_ratio)) ** 2 ) d = int(np.ceil(d)) # Estimate probability of event during study lambda_c = np.log(2) / median_control lambda_t = lambda_c * hazard_ratio # Average probability of event (simplified uniform accrual) p_event_c = 1 - np.exp(-lambda_c * followup_time) p_event_t = 1 - np.exp(-lambda_t * followup_time) p_event_avg = (p_event_c + ratio * p_event_t) / (1 + ratio) n_total = int(np.ceil(d / p_event_avg)) return { "events_required": d, "total_patients": n_total, "hazard_ratio": hazard_ratio, "p_event_avg": round(p_event_avg, 3), }
pythonimport random def stratified_block_randomization(strata: list[str], block_sizes: list[int] = [4, 6], ratio: tuple = (1, 1), seed: int = 42) -> list[str]: """ Stratified permuted block randomization. strata: list of stratum labels for each patient (in enrollment order) block_sizes: list of possible block sizes (randomly selected) ratio: allocation ratio (e.g., (1,1) for 1:1, (2,1) for 2:1) Returns list of treatment assignments ('A' or 'B'). """ rng = random.Random(seed) stratum_queues = {} assignments = [] for stratum in strata: if stratum not in stratum_queues: stratum_queues[stratum] = [] if not stratum_queues[stratum]: # Generate new block block_size = rng.choice(block_sizes) n_a = block_size * ratio[0] // sum(ratio) n_b = block_size - n_a block = ["A"] * n_a + ["B"] * n_b rng.shuffle(block) stratum_queues[stratum] = block assignments.append(stratum_queues[stratum].pop(0)) return assignments
pythondef obrien_fleming_boundary(n_looks: int, alpha: float = 0.05) -> list[float]: """ Compute O'Brien-Fleming spending function boundaries. Provides very conservative early stopping with near-nominal final alpha. """ from scipy.stats import norm boundaries = [] for k in range(1, n_looks + 1): info_fraction = k / n_looks z_boundary = norm.ppf(1 - alpha / 2) / np.sqrt(info_fraction) p_boundary = 2 * (1 - norm.cdf(z_boundary)) boundaries.append({ "look": k, "info_fraction": round(info_fraction, 3), "z_boundary": round(z_boundary, 4), "p_boundary": round(p_boundary, 6), }) return boundaries # Example: 3 interim looks + 1 final boundaries = obrien_fleming_boundary(4) for b in boundaries: print(f"Look {b['look']}: Z={b['z_boundary']}, p={b['p_boundary']}")
pythonfrom lifelines import KaplanMeierFitter from lifelines.statistics import logrank_test def analyze_survival(time: pd.Series, event: pd.Series, group: pd.Series) -> dict: """ Perform Kaplan-Meier estimation and log-rank test. time: follow-up duration event: 1=event occurred, 0=censored group: treatment group labels """ groups = group.unique() kmf_results = {} for g in groups: mask = group == g kmf = KaplanMeierFitter() kmf.fit(time[mask], event[mask], label=str(g)) kmf_results[g] = { "median_survival": kmf.median_survival_time_, "survival_at_12m": kmf.predict(12), } # Log-rank test mask_a = group == groups[0] lr = logrank_test( time[mask_a], time[~mask_a], event[mask_a], event[~mask_a], ) return { "group_results": kmf_results, "logrank_statistic": lr.test_statistic, "logrank_p_value": lr.p_value, }
Key regulatory documents for clinical trial design:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | pass→pass | 15,705 | 18,790 | +20% | 1 | 1 | 0% | 2,336 | 5,091 | +118% | 0 | 0 | — |
case-04 | pass→pass | 14,088 | 20,230 | +44% | 1 | 1 | 0% | 2,212 | 5,832 | +164% | 0 | 0 | — |
case-01 | fail→fail | 22,667 | 20,067 | -11% | 1 | 1 | 0% | 5,012 | 6,099 | +22% | 0 | 0 | — |
case-02 | fail→fail | 38,315 | 41,468 | +8% | 1 | 1 | 0% | 7,085 | 9,292 | +31% | 0 | 0 | — |
case-05 | pass→pass | 16,667 | 22,075 | +32% | 1 | 1 | 0% | 2,515 | 5,743 | +128% | 0 | 0 | — |
case-06 | fail→pass | 15,239 | 9,701 | -36% | 1 | 1 | 0% | 3,277 | 4,596 | +40% | 0 | 0 | — |
case-07 | fail→fail | 22,509 | 17,153 | -24% | 1 | 1 | 0% | 3,696 | 5,641 | +53% | 0 | 0 | — |
case-08 | fail→fail | 14,193 | 21,008 | +48% | 1 | 1 | 0% | 3,025 | 6,468 | +114% | 0 | 0 | — |
case-09 | pass→pass | 3,309 | 6,693 | +102% | 1 | 1 | 0% | 528 | 3,508 | +564% | 0 | 0 | — |
case-10 | pass→pass | 3,613 | 4,922 | +36% | 1 | 1 | 0% | 530 | 3,232 | +510% | 0 | 0 | — |
case-11 | pass→pass | 13,731 | 15,837 | +15% | 1 | 1 | 0% | 2,218 | 4,916 | +122% | 0 | 0 | — |
case-12 | fail→pass | 15,527 | 15,718 | +1% | 1 | 1 | 0% | 2,356 | 4,998 | +112% | 0 | 0 | — |
case-13 | pass→pass | 16,447 | 20,501 | +25% | 1 | 1 | 0% | 2,688 | 5,463 | +103% | 0 | 0 | — |
case-14 | fail→pass | 9,614 | 9,749 | +1% | 1 | 1 | 0% | 1,782 | 3,992 | +124% | 0 | 0 | — |
case-15 | pass→pass | 7,317 | 10,524 | +44% | 1 | 1 | 0% | 1,312 | 4,103 | +213% | 0 | 0 | — |
case-16 | pass→pass | 9,827 | 4,179 | -57% | 1 | 1 | 0% | 1,534 | 3,076 | +101% | 0 | 0 | — |
case-17 | pass→pass | 17,187 | 20,249 | +18% | 1 | 1 | 0% | 2,563 | 5,383 | +110% | 0 | 0 | — |
case-18 | pass→pass | 6,698 | 7,387 | +10% | 1 | 1 | 0% | 991 | 3,563 | +260% | 0 | 0 | — |
case-19 | pass→pass | 18,433 | 18,539 | +1% | 1 | 1 | 0% | 3,314 | 6,178 | +86% | 0 | 0 | — |
case-20 | fail→fail | 11,937 | 14,888 | +25% | 1 | 1 | 0% | 1,969 | 5,066 | +157% | 0 | 0 | — |
case-21 | fail→fail | 15,098 | 22,801 | +51% | 1 | 1 | 0% | 2,578 | 6,604 | +156% | 0 | 0 | — |
case-22 | fail→fail | 11,086 | 9,490 | -14% | 1 | 1 | 0% | 1,816 | 4,018 | +121% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.