Skip to content
Research
Skill

/batch-cohort

Use when one validated cohort analysis must be repeated across many exposure/outcome pairs. Generates one R/Python script per combination from a single methodology template, changing only the variables, and aggregates the results into a summary matrix.

From plugin
medsci-skills
38162 skills

Claude Code

$ npx -y skills add Aperivue/medsci-skills --skill batch-cohort --agent claude-code

SKILL.md

batch-cohort.SKILL.md
name: batch-cohort
description: Use when one validated cohort analysis must be repeated across many exposure/outcome pairs. Generates one R/Python script per combination from a single methodology template, changing only the variables, and aggregates the results into a summary matrix.
model: opus
metadata:
  triggers: "batch cohort, batch analysis, 대량 분석, 변수 교체, variable swap, mass production, 80명 팀, batch generate, 일괄 코드 생성, exposure outcome matrix, combinatorial analysis"

Batch Cohort Analysis Skill

Generate one analysis script per exposure/outcome combination from a single validated methodology template; only the variables change between scripts.

Inputs

1. **Database path(s)**: CSV/SAS data files (KNHANES, NHANES, NHIS, or any cleaned cohort) 2. **Methodology template**: One of:

  • Path to a validated R/Python analysis script (from /replicate-study or /cross-national)
  • A paper type template name: `nhis_cohort`, `cross_national`, `survey_weighted`
  • A source paper to extract methodology from (falls back to /replicate-study Phase 1)

3. **Combination spec**: A list of exposure/outcome pairs, provided as:

  • Inline list: `exposures: [depression, obesity, smoking]; outcomes: [diabetes, hypertension, CVD]`
  • CSV file with columns: `exposure`, `outcome`, (optional) `subgroup_vars`
  • `"all"` keyword: generates all pairwise combinations from the lists

Optional Inputs

  • **Covariate set**: Fixed covariate list for all analyses (default: use template's set)
  • **Subgroup variables**: Variables to stratify by (default: sex, age group)
  • **Output format**: `code_only` (just scripts) | `execute` (run + collect results) | `full` (code + results + summary)
  • **Cross-national mode**: `cross_national: true` generates paired scripts for both countries per combination (see Cross-National Batch Mode)

Example:

/batch-cohort

DB Korea: /path/to/knhanes/HN18.csv
DB US: /path/to/nhanes/
Template: cross_national
Exposures: [depression, obesity, smoking]
Outcomes: [diabetes, hypertension, metabolic_syndrome]
cross_national: true
Mode: execute

Workflow

Phase 1: Template Validation

1. Read the methodology template (R script or paper type reference). 2. Identify the **slot variables** — parts that change per combination: `EXPOSURE_VAR` (raw variable name in the database), `EXPOSURE_LABEL` (label for tables/figures), `EXPOSURE_CODING` (derivation of the binary/categorical exposure), and `OUTCOME_VAR`, `OUTCOME_LABEL`, `OUTCOME_CODING` likewise. 3. Confirm the survey design: weighted analysis is mandatory for KNHANES/NHANES and is inherited from the template; NHIS and other claims databases have no sampling weights (standard regression). 4. Verify the template runs successfully on at least one combination before batch generation. 5. Output: template summary with identified slots → user approval.

Phase 2: Variable Specification

For each exposure and outcome in the combination spec:

1. **Look up** the variable in the database: KNHANES — the name exists in the CSV header; NHANES — which table contains it (codebook.csv if available); NHIS — claims code or variable name. For ICD-10 claims algorithms read `${CLAUDE_SKILL_DIR}/../analyze-stats/references/analysis_guides/nhis_icd10_mapping.md`; for survey variable coding, `survey_weighted.md` in the same folder. If a mapping is uncertain, write `[VERIFY: variable_name]` and ask the user to confirm it against the data dictionary; never guess a variable name, column name or coding. 2. **Define coding**: binary as a threshold or category mapping (e.g., `HE_glu >= 126 → diabetes = 1`); categorical as level definitions (e.g., `smoking: current/former/never`). Outcome definitions MUST include physician diagnosis, because lab-only definitions systematically overestimate exposure→outcome associations: Diabetes = FPG≥126 OR HbA1c≥6.5 OR physician-diagnosed (KNHANES: DE1_dg=1, NHANES: DIQ010="Yes"); Hypertension = SBP≥140 OR DBP≥90 OR physician-diagnosed (KNHANES: DI1_dg=1, NHANES: BPQ020="Yes"). 3. **Set covariates**: the full 8-covariate set (age, sex, education, income, smoking, alcohol, obesity, CVD) is the default unless explicitly justified — minimal models (age+sex+BMI only) leave residual confounding, which can bias effects in either direction. Remove self-adjustment: if the exposure is (or derives from) a covariate, drop that covariate (exposure = BMI → drop obesity; exposure = education/income → drop the same variable); if outcome = MetS, consider dropping obesity. Document every removal in the matrix Notes. 4. Output: **combination matrix** (`combination_matrix.csv`) with all variable specifications.

| # | Exposure | Exposure Coding | Outcome | Outcome Coding | Covariates (adjusted) | Notes |
|---|----------|-----------------|---------|----------------|----------------------|-------|
| 1 | Depression (PHQ≥10) | BP_PHQ sum ≥10 | Diabetes | HE_glu≥126|HbA1c≥6.5|DE1_dg=1 | age,sex,edu,income,smoking,alcohol,obesity,CVD | — |
| 2 | Obesity (BMI≥25) | HE_obe ≥4 | Diabetes | same | age,sex,edu,income,smoking,alcohol,depression,CVD | obesity removed from covariates |

Phase 3: Batch Code Generation

Never modify the core methodology across combinations — only swap exposure/outcome/covariates. For each combination in the matrix:

1. **Clone** the template script. 2. **Replace** slot variables with the combination-specific values. 3. **Apply** the combination's adjusted covariate set from the matrix. 4. **Set output paths**: each combination gets its own results subdirectory. 5. **Generate a master runner script** (`run_all.R` or `run_all.sh`) that executes all N scripts sequentially (or in parallel via `future`/`parallel`), captures errors per script without stopping the batch, and logs execution time per analysis. 6. **Generated-code quality gate**: one reproducibility slip (a missing seed, an absolute path, a hand-typed data literal) r

Read more
@aperivue
Ships withmedsci-skills

Created & maintained by Yoojin Nam, MD Department of Radiology and Research Institute of Radiology, University of Ulsan College of Medicine, Asan Medical Center, Seoul, Republic of Korea MedSci Skills is a set of Agent Skills for clinical research: literature

Stars on GitHub

Momentum

stars in total
381
Star history of Aperivue/medsci-skills on GitHub, a chart by star-history.com

Other skills on medsci-skills.

academic-aio

academic-aio

Use when a medical AI paper should be found and cited by AI search engines and RAG tools. Optimizes the title, abstract, summary…

add-journal

add-journal

Use when a target journal has no profile yet. Reads the journal's author guidelines and writes a detailed /write-paper profile…

analyze-stats

analyze-stats

Use when data needs statistical analysis. Runs reproducible Python/R code for Table 1, diagnostic accuracy, agreement,…

author-strategy

author-strategy

Use when analyzing a researcher's publication record from PubMed. Fetches an author's papers, classifies study types and author…

calc-sample-size

calc-sample-size

Use when planning how many patients or cases a study needs before data collection (power analysis, IRB justification). Walks a…

More skills from other plugins.

academic-paper-review

academic-paper-review

Use this skill when the user requests to review, analyze, critique, or summarize academic papers, research articles, preprints,…

@bytedance@bytedanceInstall Skill
last30days

last30days

Research what people actually say about any topic in the last 30 days. Pulls posts and engagement from Reddit, X, YouTube,…

@mvanhorn@mvanhornInstall Skill

Questions about batch-cohort.

Which coding agents can use batch-cohort?
batch-cohort installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.