replicate-study skill
✓ VerifiedApplies published cohort study methodologies to new databases by extracting designs, mapping variables, and generating reproducible analysis code.
- GitHub stars
- 378
- Files
- 5
- Last commit
- Nov 10, 2026
- License
- MIT
- Allowed tools
- —
What does the replicate-study skill do?
replicate-study applies published cohort study methodologies to new databases by extracting designs, mapping variables, and generating reproducible analysis code.
Summary generated from the skill's SKILL.md.
About the replicate-study skill
Researchers aiming to apply published cohort study methodologies to new datasets can use this tool to automate the transition from a source paper to a target database. The process begins by extracting study designs, population criteria, and statistical methods from a PDF or markdown source paper using a specific methodology extraction template. It then maps variables from the original study to the new database by utilizing harmonization tables, such as the KNHANES to NHANES mapping, to identify direct matches or necessary recoding.
Once variables are aligned, the skill generates reproducible analysis code in Python and R, specifically designed to handle survey-weighted analysis and complex survey designs like strata and PSU. It ensures statistical accuracy by preventing row deletion before design declaration and applying population-specific standards, such as Asian BMI cutoffs. The final output includes a detailed replication report that documents every forced deviation, a variable mapping table, and the complete analysis scripts and results files.
What an agent can do with it
- 1Replicate a study methodologyApply the design and statistical methods from a specific research paper to a different database.
- 2Map variables between databasesCreate a mapping table to align variables from a source paper with a target CSV or SAS data file.
- 3Generate survey-weighted analysis codeProduce Python and R scripts that correctly implement survey weights and design objects for datasets like KNHANES.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the replicate-study skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the replicate-study skill in Plugin
/plugin marketplace add Aperivue/medsci-skills /plugin install medsci-analysis@medsci-skills
Install the replicate-study skill in Claude Code
~/.claude/skills/replicate-study/SKILL.md
$ npx degit Aperivue/medsci-skills/skills/replicate-study ~/.claude/skills/replicate-studyInstall the replicate-study skill in Claude Code (project)
.claude/skills/replicate-study/SKILL.md
$ npx degit Aperivue/medsci-skills/skills/replicate-study .claude/skills/replicate-studyInstall the replicate-study skill in Codex
~/.agents/skills/replicate-study/SKILL.md
$ npx degit Aperivue/medsci-skills/skills/replicate-study ~/.agents/skills/replicate-studyInstall the replicate-study skill in Gemini CLI
~/.gemini/skills/replicate-study/SKILL.md
$ npx degit Aperivue/medsci-skills/skills/replicate-study ~/.gemini/skills/replicate-studyInstall the replicate-study skill in Claude.ai
npx degit Aperivue/medsci-skills/skills/replicate-study replicate-study && zip -r replicate-study.zip replicate-study # claude.ai → Customize → Skills → + → Create skill → Upload a skill → replicate-study.zip
Automated checks
Ran Nov 15, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work
- Source repository linked and reachableaperivue/medsci-skills/skills/replicate-study is public and reachablegithub.com/aperivue/medsci-skills/tree/HEAD/skills/replicate ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-10github.com/aperivue/medsci-skills/commits ↗Pass
- No download-and-run or credential theft in scriptsNo scripts in the skill folderPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/aperivue/medsci-skills/blob/HEAD/skills/replicate ↗Pass
- Pre-approved tools are scopedNo pre-approved tools; the agent asks before using onegithub.com/aperivue/medsci-skills/blob/HEAD/skills/replicate ↗Pass
- SKILL.md follows the Agent Skills formatValid name and description; says when to use it; 126 linesgithub.com/aperivue/medsci-skills/blob/HEAD/skills/replicate ↗Pass
SKILL.md
View on GitHubReplicate Study Skill
Apply a published study's methodology to a different database and report every place the target database forced a deviation.
Inputs
- Source paper: PDF, DOI, or markdown of the paper to replicate
- Target database path: CSV/SAS data file(s) to use
- Harmonization table (optional): CSV mapping source → target variables
- Default:
${CLAUDE_SKILL_DIR}/references/harmonization_knhanes_nhanes.csv(if KNHANES↔NHANES)
- Default:
Reference Files
${CLAUDE_SKILL_DIR}/references/methodology_extraction_template.md— checklist for extracting study design${CLAUDE_SKILL_DIR}/references/harmonization_knhanes_nhanes.csv— KNHANES↔NHANES variable mapping (67 rows)${CLAUDE_SKILL_DIR}/references/harmonization_3country.csv— KNHANES+NHANES+CHNS 3-country mapping (46 rows)- Upstream templates (read on demand):
${CLAUDE_SKILL_DIR}/../write-paper/references/paper_types/nhis_cohort.md${CLAUDE_SKILL_DIR}/../write-paper/references/paper_types/cross_national.md${CLAUDE_SKILL_DIR}/../analyze-stats/references/analysis_guides/survey_weighted.md${CLAUDE_SKILL_DIR}/../analyze-stats/references/analysis_guides/propensity_score.md
Workflow
Phase 1: Source Paper Analysis
- Read the source paper (PDF → text, or markdown).
- Extract the methodology by filling
methodology_extraction_template.md: study design, database (name, country, years, N), population (inclusion/exclusion, age range), exposure and outcome (variable, definition, coding), covariates with definitions, statistical methods (regression type, adjustment models, subgroup analyses), survey design (weights, strata, PSU), and every sensitivity analysis. - Outdated source definitions: if the source used a pre-2023 definition that has since been
superseded (e.g., NAFLD → MASLD 2023, CKD-EPI 2009 → 2021 race-free), call
/define-variablesto cross-check whether to mirror the legacy definition (pure replication) or upgrade to the current one (extension). Record the choice in the difference report. - Output: structured extraction summary for user review.
Phase 2: Variable Mapping
- Load the harmonization table (columns:
domain,concept,concept_en, one variable/label column set per database such asknhanes_var/nhanes_var, andharmonization_notes). - For each extracted variable (exposure, outcome, covariates), find the matching row and flag it
DIRECT_MATCH / RECODE_NEEDED / NOT_AVAILABLE / PROXY_AVAILABLE. 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. - Generate a mapping report:
- Green: directly available (no recoding)
- Yellow: available but needs recoding (document transformation)
- Red: not available in target DB (propose proxy or exclusion)
- Output: variable mapping table (
variable_mapping.csv) for user approval.
Phase 3: Code Generation
- Generate self-contained, reproducible analysis code (Python with
pandas+ R viasubprocessfor survey-weighted analysis): a. Data loading & cleaning: read target DB, derive inclusion/exclusion flags (keep every row) b. Variable derivation: recode variables per mapping table c. Survey design setup: define svydesign object (strata, PSU, weights) on the full file, then restrict it withsubset(design, <inclusion flag>); deleting rows before the design is declared gives wrong standard errors (/analyze-statssurvey_weighted.md, subpopulation analysis). Weighted analysis is mandatory for KNHANES/NHANES — never run unweighted models. Never pool data across surveys; analyze each country's data with its own survey design. d. Table 1: demographics by exposure group (weighted) e. Main analysis: replicate the primary model (logistic/Cox/linear regression) f. Subgroup analyses: if specified in source paper g. Sensitivity analyses: replicate all listed in source paper - Use
/analyze-statstemplates where available (survey_weighted, propensity_score). - Use Asian BMI cutoffs (≥25 for obesity) for Korean data, even if the source used WHO (≥30).
- Run the code on the target data; every number in
results/and the report comes from that executed output.
Phase 4: Difference Report
Save replication_report.md in the working directory, documenting every deviation from the
source methodology:
| Section | Content |
|---|---|
| Study Design | Same / Modified (explain) |
| Database | Source DB → Target DB (N, years, country) |
| Population | Inclusion/exclusion differences |
| Variable Mapping | Full mapping table with match status |
| Unavailable Variables | What's missing and how handled |
| Methodological Differences | Any forced changes (e.g., BMI cutoffs, LDL direct measurement vs Friedewald) |
| Expected Differences | Why results may differ (population, measurement, cultural) |
Note that KNHANES/NHANES are de-identified public data (IRB exempt or waived). Cite only with a
/search-lit-confirmed DOI/PMID; otherwise mark the reference [UNVERIFIED - NEEDS MANUAL CHECK].
Phase 5: Validation Checklist
Before reporting completion, verify:
- All source paper covariates accounted for (mapped, proxied, or documented as missing)
- Survey weights correctly applied (NEVER analyze unweighted if source used weights)
- Obesity/BMI cutoffs match target population standards (Asian vs WHO)
- Fasting requirements matched (fasting glucose, lipids)
- Age restrictions applied correctly
- Code runs without errors on target data
- Output tables match source paper structure
Output Files
{working_dir}/
├── replication_report.md — Structured difference report
├── variable_mapping.csv — Variable mapping table with match status
├── analysis_code.py — Main analysis script (Python + R calls)
├── analysis_code.R — R script for survey-weighted analysis
└── results/
├── table1.csv — Demographics table
├── main_results.csv — Primary analysis results
└── subgroup_results.csv — Subgroup analysis results (if applicable)
Files in this skill
5replicate-study skill questions
How do I install the replicate-study skill in Claude Code?
Run npx degit Aperivue/medsci-skills/skills/replicate-study ~/.claude/skills/replicate-study. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the replicate-study skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
What inputs are required to replicate a study?
You need the source paper (PDF, DOI, or markdown), the target database path (CSV or SAS files), and an optional harmonization table for variable mapping.
How does the tool handle variable mapping between different databases?
It uses a harmonization table to match variables and flags them as DIRECT_MATCH, RECODE_NEEDED, NOT_AVAILABLE, or PROXY_AVAILABLE, generating a mapping report for user approval.
Does the tool support survey-weighted analysis?
Yes, it generates Python and R code specifically designed for survey-weighted analysis, ensuring that strata, PSU, and weights are correctly applied to avoid incorrect standard errors.
What is included in the final replication report?
The report documents deviations in study design, database details, population inclusion/exclusion, variable mapping, unavailable variables, and methodological differences.