/open-scholar-skill:scholar-analyze [data source + model spec, e.g., 'NHANES 2017-2018, OLS of BMI on physical activity by race for Demography' or 'data.csv, fixed effects of education on earnings for ASR']from open-scholar-skill
Runs statistical analyses for social science research, producing publication-ready regression tables (HTML/TeX/docx), figures (PDF/PNG), and Results documents. Supports local files, pasted data, or online datasets (NHANES, IPUMS, GSS, World Bank) with verification subagents.
Ships in open-scholar-skill. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert quantitative sociologist who runs executable analyses, produces publication-quality tables and figures, and writes journal-ready Results sections. You follow reporting standards for ASR, AJS, Demography, Science Advances, and Nature journals.
The user has provided: $ARGUMENTS
Parse this carefully across three possible input modes:
Mode 1 — File path: a local path to a dataset (.csv, .dta, .rds, .parquet). Load directly in A1.
Mode 2 — Inline/pasted data: the user has pasted rows of data, a data frame summary, or variable descriptions directly in the argument. Write the data to a temp file or reconstruct the data frame from the description, then proceed to A1.
Mode 3 — Online source: the user names a public dataset (NHANES, IPUMS, GSS, ACS/Census, FRED, World Bank, etc.) without providing a local file. Fetch the data in A1 using the appropriate R package or API (see A1 Online Data section). Confirm the fetch succeeded before proceeding.
Mode 4 — Revise figure: the user wants to modify an existing figure without re-running analysis. Keywords: revise, fix, adjust, resize, relabel, rotate labels, add reference line, change colors, refacet, restyle. Jump directly to the REVISE-FIGURE workflow below — skip Components A and C.
Regardless of mode (1-3), identify: outcome variable (Y), key predictor(s) (X), controls (C), grouping variable (G), and target journal.
Create output directories before any analysis:
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
mkdir -p "${OUTPUT_ROOT}/tables" "${OUTPUT_ROOT}/figures" "${OUTPUT_ROOT}/scripts" "${OUTPUT_ROOT}/logs"
Process Logging (REQUIRED) — Reasoning · Action · Observation trace:
This skill emits an append-only RAO trace at ${OUTPUT_ROOT}/logs/trace-scholar-analyze-<date>.ndjson — the source of truth. The human-readable process-log-scholar-analyze-<date>.md is rendered from it. Full protocol + privacy rule: _shared/process-logger.md.
At each meaningful step (a decision, a script/tool run, a gate call, a subagent dispatch), append one record. emit-trace.sh derives seq from the file, so no state is tracked across the stateless Bash blocks:
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/emit-trace.sh" --skill scholar-analyze --step "<label>" \
--reasoning "<the WHY — stated rationale, 1–2 lines>" \
--action "<the WHAT — tool/script/gate call + key args>" \
--observation "<the RESULT — verdict/metric/count/error/file ref>" --status ok # ok|fail|skipped
At the end (Save Output), render the human-readable log and self-check:
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/render-trace.sh" "${OUTPUT_ROOT}/logs/trace-scholar-analyze-$(date +%Y-%m-%d).ndjson"
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/trace-coverage-check.sh" "${OUTPUT_ROOT}" --skill scholar-analyze
Privacy (C-01 / LOCAL_MODE): the trace carries aggregate metrics, verdicts, counts, and file refs ONLY — never raw data rows, verbatim quotes, or PII.
Before any Component A step that loads data, follow the mandatory gate defined in .claude/skills/_shared/data-handling-policy.md. This is non-optional for Modes 1 and 2 (local file or pasted data). Mode 3 (online public data fetched by the skill itself, e.g., NHANES/IPUMS via package APIs) may skip the gate — public APIs return data directly into the R session, not into Claude's context.
Skip the gate only if: the skill is invoked from an upstream orchestrator and an earlier phase has already set SAFETY_STATUS in PROJECT_STATE. In that case, read the existing status and propagate it — never re-run the gate downgraded, and never upgrade LOCAL_MODE to CLEARED.
Otherwise, for every data-file argument:
# ── Step 0: Safety Gate ──
# See _shared/data-handling-policy.md §1 for the full spec.
GATE_SCRIPT="${SCHOLAR_SKILL_DIR:-.}/scripts/gates/safety-scan.sh"
for FILE in [DATA_FILE_PATHS]; do
[ -f "$FILE" ] || { echo "missing: $FILE"; continue; }
bash "$GATE_SCRIPT" "$FILE"
echo "gate exit: $? file: $FILE"
done
Set SAFETY_STATUS ∈ {CLEARED, LOCAL_MODE, ANONYMIZED, OVERRIDE, HALTED} per the state machine in _shared/data-handling-policy.md §2. Present the options to the user and wait for their selection when the gate returns YELLOW or RED. Log the gate result, the user's choice, and any OVERRIDE rationale to the process log (§6 of the policy).
Downstream branching in Component A:
SAFETY_STATUS ∈ {CLEARED, ANONYMIZED, OVERRIDE} → use the standard A1 loader (Read-compatible, head() / in-context dataframes allowed).SAFETY_STATUS = LOCAL_MODE → use the A1 LOCAL_MODE loader (single Rscript -e Bash call, summary-only output, no head(), no print(df), no Read on the data file). See component-a-core.md A1.SAFETY_STATUS = HALTED → stop the skill. Do not proceed to A1.Any sub-skill invoked from Component A (e.g., /scholar-causal, /scholar-compute) MUST inherit SAFETY_STATUS — pass it forward in the invocation arguments.
The M1→M4 ladder is a publication convention for observational-descriptive sociology — not a universal inferential scaffold. Other designs (RCT, DiD/RD/IV, Oaxaca/Kitagawa/APC, ML) need different specification sets. Before assembling any regression ladder, read the Design Type and route to the correct template:
SKILL_DIR="${SCHOLAR_SKILL_DIR:-.}/.claude/skills/scholar-analyze/references"
# 1) Consult the router table
cat "$SKILL_DIR/design-router.md"
# 2) Read Design Type from project-state.md (emitted by scholar-design);
# fall back to "observational-descriptive" with a WARN if absent.
. "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/derive-proj.sh" 2>/dev/null || PROJ="${OUTPUT_ROOT:-output}/${PROJ_SLUG:-.}"
DESIGN_TYPE=$(grep -E "^Design Type:" "${PROJ}/logs/project-state.md" 2>/dev/null | tail -1 | sed 's/^Design Type:[[:space:]]*//')
DESIGN_TYPE="${DESIGN_TYPE:-observational-descriptive}"
echo "Design Type → ${DESIGN_TYPE}"
# 3) Load the matching ladder file named by the router table
case "$DESIGN_TYPE" in
observational-descriptive) LADDER="ladder-observational-descriptive.md" ;;
observational-causal-with-DAG) LADDER="ladder-observational-causal.md" ;;
RCT) LADDER="ladder-rct.md" ;;
quasi-experimental:*) LADDER="ladder-quasi-experimental.md" ;;
decomposition:*) LADDER="ladder-decomposition.md" ;;
predictive-ML) LADDER="ladder-predictive-ml.md" ;;
*) echo "Unrecognized Design Type — defaulting to observational-descriptive"; LADDER="ladder-observational-descriptive.md" ;;
esac
cat "$SKILL_DIR/$LADDER"
The selected ladder defines the specification set, robustness battery, and adjudication hint. Component A (below) is then loaded on demand for the estimators those specs require.
Component A (Data Analytics) is split into loadable reference files. Load only the sections relevant to the analysis task:
SKILL_DIR="${SCHOLAR_SKILL_DIR:-.}/.claude/skills/scholar-analyze/references"
cat "$SKILL_DIR/component-a-SECTION.md"
| Section | File | When to load |
|---|---|---|
| Core (A0-A2b): setup, data loading, Table 1, MI | component-a-core.md | Always |
| Regression (A3-A5): OLS, logit, FE, diagnostics | component-a-regression.md | Standard regression models |
| Bayesian (A3b): brms / rstanarm | component-a-bayesian.md | Bayesian analysis requested |
| Export + Robustness (A6-A7) | component-a-export-robustness.md | Always (after models) |
| Specialized (A8*): LCA, quantile, SEM, GAMLSS, growth curves, MSEM, FMR, spec curve, BART | component-a-specialized.md | When outcome type or method matches A8 dispatch |
| Verification (A9) | component-a-verification.md | Always (final step) |
Always load: component-a-core.md + component-a-export-robustness.md + component-a-verification.md
Load conditionally: regression, bayesian, and/or specialized based on the analysis type.
Component A execution is SPLIT by sub-stage A2.5 (below). A0–A2b (setup, data loading, descriptives/Table 1, MI) execute as loaded. The model ladder A3–A8 does NOT execute inline: its scripts are DRAFTED first, reviewed at A2.5, and then the reviewed files are executed directly. After Component A completes, continue with Components B, C, D below.
Standalone counterpart of scholar-auto-research's Phase 6 pre-execution review. Protocol: _shared/pre-execution-review.md (state sequence DRAFTED → REVIEWED+HASHED → EXECUTABLE; pilot exemption §2; phase tag pre-exec-analyze). Model bugs are cheap to fix here (edit a script) and expensive after execution (re-run analysis, re-draft, re-verify).
04-main-models, 05-marginal-effects, 06-diagnostics, 07-export-tables, 08-robustness, 09*-decomposition/specialized — as applicable to the design; D1 version-check before each Write). Each script self-contained per D1 (explicit library(), data load, set.seed()). Do NOT run any model-bearing block inline — including blocks from component-a-regression.md / -bayesian.md / -specialized.md / -export-robustness.md.scholar-code-review in pre-execution mode, fast 3 subset (statistics data-handling correctness), passing the design blueprint/codebook. Three SEPARATE parallel Agent dispatches; each recorded via emit-task-dispatch.sh --phase pre-exec-analyze. Already-executed A1/A2 scripts (01-*, 03-*) and E-scripts enter the CODE REVIEW PACKAGE as context and are listed in the manifest's out_of_scope[]._shared/code-review-fix-loop.md (auto-fix mechanical, escalate design-level, max 2 iterations, re-review after fixes per scholar-code-review Step 6)._b="$HOME/.claude/scholar-skill-bootstrap.sh"; [ -f "$_b" ] || _b="${SCHOLAR_SKILL_DIR:-.}/scripts/scholar-skill-bootstrap.sh"; [ -f "$_b" ] && . "$_b"; unset _b
. "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/derive-proj.sh" 2>/dev/null || PROJ="${OUTPUT_ROOT:-output}"
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/pre-exec-review-check.sh" "$PROJ" \
--required=fast --phase pre-exec-analyze \
|| { echo "HALT: A2.5 gate failed — fix + re-review before executing the model ladder."; exit 1; }
Emit the receipt row immediately before the first model execution: Pre-execution review: report <path> · review_id <id> · scripts N hashed · gate GREEN. Then A3–A8 proceed by INVOKING the reviewed files (Rscript "${OUTPUT_ROOT}/scripts/04-main-models.R" …) — never by re-typing their code into the conversation. Post-hoc edits to a reviewed script send it back through Step 6 re-review + this gate.
--skip-preexec-review (standalone only) skips steps 2–4; the skip is logged in the trace and MUST be justified in the output's Limitations — mirroring --skip-premortem. Under scholar-auto-research orchestration the flag is ignored and Phase 6 supersedes this sub-stage entirely (do not double-review).premortem-protocol.md's "code-review report must be clean" packet precondition, so standalone Mode 5 is now runnable after A2.5.# Source the publication theme
viz_path <- file.path(Sys.getenv("SCHOLAR_SKILL_DIR", unset = "."), ".claude/skills/scholar-analyze/references/viz_setting.R")
if (file.exists(viz_path)) source(viz_path) else stop("viz_setting.R not found at ", viz_path, " — do NOT define theme_Publication inline")
# Provides: theme_Publication(), scale_fill/colour_Publication() (Wong 2011),
# scale_fill_continuous/diverging_Publication(), set_geom_defaults_Publication(),
# assemble_panels(), save_fig_cmyk(), preview_grayscale()
# Output root — set by orchestrator or default to "output"
output_root <- Sys.getenv("OUTPUT_ROOT", "output")
# ── VISUALIZATION RULES (MANDATORY) ──────────────────────────────
# 1. NEVER use ggtitle() or labs(title = ...) — titles go in manuscript captions
# 2. ALWAYS use theme_Publication() — never theme_minimal(), theme_bw(), etc.
# 3. ALWAYS use scale_colour_Publication() or .wong_palette for colors
# 4. ALWAYS save both PDF (cairo_pdf) and PNG (300 DPI) via save_fig()
# 5. Axis labels in plain language, not raw variable names
# 6. For Nature single-col: call set_geom_defaults_Publication("nature_single")
# 7. For multi-panel figures: use assemble_panels(p1, p2, p3) for bold A/B/C tags
# ──────────────────────────────────────────────────────────────────
# Journal dimension presets (width × height in inches)
journal_dims <- list(
default = list(w = 6, h = 4.5, base_size = 12),
asr = list(w = 6.5, h = 4.5, base_size = 12), # single-col ~6.5"
ajs = list(w = 6.5, h = 4.5, base_size = 12),
demography = list(w = 6.5, h = 5, base_size = 12),
nhb_single = list(w = 3.5, h = 3, base_size = 8), # Nature single-col 89mm
nhb_double = list(w = 7.1, h = 4.5, base_size = 10), # Nature double-col 183mm
ncs_single = list(w = 3.5, h = 3, base_size = 8),
ncs_double = list(w = 7.1, h = 4.5, base_size = 10),
sciadv = list(w = 7, h = 4.5, base_size = 10), # Science Advances full-width
pnas = list(w = 3.4, h = 3, base_size = 8) # PNAS single-col 87mm
)
# Export helper — saves PDF (vector) + PNG (300 DPI)
# journal: pass a key from journal_dims to auto-set width/height
# grayscale: if TRUE, also saves a grayscale version (*-gs.pdf/*-gs.png)
save_fig <- function(p, name, width = NULL, height = NULL, dpi = 300,
journal = "default", grayscale = FALSE) {
dims <- if (tolower(journal) %in% names(journal_dims)) journal_dims[[tolower(journal)]] else journal_dims[["default"]]
w <- if (!is.null(width)) width else dims$w
h <- if (!is.null(height)) height else dims$h
# Apply journal-specific base_size so text scales correctly for the target canvas
if (tolower(journal) != "default" && !is.null(dims$base_size)) {
p <- p + theme_Publication(base_size = dims$base_size)
}
ggsave(paste0(output_root, "/figures/", name, ".pdf"),
plot = p, device = cairo_pdf, width = w, height = h)
ggsave(paste0(output_root, "/figures/", name, ".png"),
plot = p, dpi = dpi, width = w, height = h)
if (grayscale) {
p_gs <- p + scale_colour_grey() + scale_fill_grey()
ggsave(paste0(output_root, "/figures/", name, "-gs.pdf"),
plot = p_gs, device = cairo_pdf, width = w, height = h)
ggsave(paste0(output_root, "/figures/", name, "-gs.png"),
plot = p_gs, dpi = dpi, width = w, height = h)
}
message("Saved: ", output_root, "/figures/", name, " (.pdf + .png)",
if (grayscale) " + grayscale" else "")
}
# Colorblind-safe 8-color palette (Wong 2011)
palette_cb <- c("#0072B2","#E69F00","#009E73","#CC79A7",
"#56B4E9","#F0E442","#D55E00","#000000")
Before generating any figure code, produce a Figure Plan table and present it to the user for confirmation. This prevents wasted iterations on the wrong figures.
## Figure Plan
| # | Figure Type | Variables → Aesthetics | Dimensions | Style Preset | Purpose |
|---|-------------|----------------------|------------|-------------|---------|
| 1 | Coefficient plot | m2 coefficients → x, CIs → errorbar | 6×4.5 | default | Main results |
| 2 | Marginal effects | x conditional on moderator → line+ribbon | 6×4.5 | default | Interaction |
| 3 | Distribution | outcome → histogram+density, group → fill | 6×4.5 | default | Descriptive |
Rules:
After confirmation, generate figures in the order specified in the plan.
After each save_fig() call, Claude Code must inspect the rendered PNG and auto-fix issues. This is the key advantage of running visualization inside Claude Code — the model can see the output and iterate.
Protocol (up to 3 iterations per figure):
Read tool on the saved .png file to visually inspect the rendered figuretheme() elements, coord_flip(), scale_x_discrete(guide = guide_axis(angle = 45)), legend position, etc.), re-run, re-save, re-inspect| B-inspect | [time] | Inspected [fig-name].png | [clean / fixed: axis overlap] | iteration [N] | ✓ |Common auto-fixes:
+ theme(axis.text.x = element_text(angle = 45, hjust = 1))+ theme(legend.position = "bottom")base_size = 8 from journal_dims+ scale_x_discrete(labels = function(x) str_wrap(x, width = 15))facet_wrap instead of color encodingDistribution:
p_dist <- ggplot(df, aes(x = outcome)) +
geom_histogram(aes(y = after_stat(density)), bins = 30, fill = palette_cb[1], alpha = 0.7) +
geom_density(linewidth = 0.8) +
labs(x = "Outcome", y = "Density") +
theme_Publication()
save_fig(p_dist, "fig-dist-outcome")
Grouped violin + boxplot (preferred for NHB):
p_violin <- ggplot(df, aes(x = group, y = outcome, fill = group)) +
geom_violin(alpha = 0.6) +
geom_boxplot(width = 0.1, fill = "white", outlier.shape = NA) +
scale_fill_Publication() +
labs(x = NULL, y = "Outcome") +
theme_Publication() + theme(legend.position = "none")
save_fig(p_violin, "fig-violin-by-group")
Bar chart with percentages:
p_bar <- df |>
count(group, category) |>
mutate(pct = n / sum(n), .by = group) |>
ggplot(aes(x = group, y = pct, fill = category)) +
geom_col(position = "dodge") +
scale_y_continuous(labels = scales::percent) +
scale_fill_Publication() +
labs(x = NULL, y = "Percent") +
theme_Publication()
save_fig(p_bar, "fig-bar-grouped")
Correlation heatmap:
library(ggcorrplot)
p_corr <- ggcorrplot(cor(select(df, where(is.numeric)), use = "pairwise"),
lab = TRUE, type = "lower",
colors = c(palette_cb[1], "white", palette_cb[7])) +
theme_Publication()
save_fig(p_corr, "fig-correlation-heatmap", width = 7, height = 6)
Single model:
library(modelsummary)
p_coef <- modelplot(m2, coef_omit = "Intercept") +
geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
labs(x = "Coefficient (HC3 SE)", y = NULL) +
theme_Publication()
save_fig(p_coef, "fig-coef-plot")
Multi-model comparison:
p_coef_multi <- modelplot(
list("Baseline" = m1, "+Controls" = m2, "+FE" = m_fe),
coef_omit = "Intercept"
) +
geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
scale_color_Publication() +
theme_Publication()
save_fig(p_coef_multi, "fig-coef-multimodel", width = 7, height = 5)
library(marginaleffects)
# AME with CIs — for all key predictors
p_ame <- plot_slopes(m_logit, variables = "x") +
geom_hline(yintercept = 0, linetype = "dashed", color = "gray50") +
labs(x = "Covariate Value", y = "Marginal Effect on P(Y=1)") +
theme_Publication()
save_fig(p_ame, "fig-ame-x")
# Interaction — effect of X conditional on moderator
p_int <- plot_slopes(m_logit, variables = "x", condition = "moderator") +
scale_color_Publication() + scale_fill_Publication() +
theme_Publication()
save_fig(p_int, "fig-interaction-ame")
# Predicted probabilities by group
p_pred <- plot_predictions(m_logit, condition = list("x", "group")) +
scale_color_Publication() + scale_fill_Publication() +
theme_Publication()
save_fig(p_pred, "fig-predicted-prob")
library(fixest)
# Estimate event study
m_es <- feols(y ~ i(year_rel, treated, ref = -1) | unit_id + year,
data = df,
cluster = ~unit_id)
# Extract coefficients and CIs
es_df <- broom::tidy(m_es, conf.int = TRUE) |>
filter(str_detect(term, "year_rel")) |>
mutate(year_rel = as.numeric(str_extract(term, "-?\\d+")))
p_es <- ggplot(es_df, aes(x = year_rel, y = estimate)) +
geom_point(size = 2) +
geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "gray40") +
geom_vline(xintercept = -0.5, linetype = "dotted", color = "red") +
labs(x = "Years Relative to Treatment", y = "Estimated Effect (95% CI)") +
theme_Publication()
save_fig(p_es, "fig-event-study")
library(rdrobust); library(rddensity)
# Main RD plot
rdplot(y = df$outcome, x = df$running_var, c = cutoff,
title = "RD Plot", x.label = "Running Variable", y.label = "Outcome")
# McCrary density test for manipulation
rdd <- rddensity(df$running_var, c = cutoff)
rdplotdensity(rdd, df$running_var)
library(MatchIt); library(cobalt)
# After running matchit:
# m_match <- matchit(treatment ~ x1 + x2 + x3, data = df, method = "nearest")
p_love <- love.plot(m_match,
thresholds = c(m = 0.1),
abs = TRUE,
var.order = "standardized",
colors = palette_cb[c(1,7)]) +
theme_Publication()
save_fig(p_love, "fig-love-plot")
library(survival); library(survminer)
km_fit <- survfit(Surv(time, event) ~ group, data = df)
ggsurvplot(km_fit,
pval = TRUE,
conf.int = TRUE,
risk.table = TRUE,
palette = palette_cb[1:2],
legend.labs = levels(df$group),
ggtheme = theme_Publication())
# Save manually via ggsave after ggsurvplot renders
Use Python when the user requests it, when R is unavailable, or for interactive/web figures. The VIZ_ENGINE env var can be set to python to default to this path.
import os, matplotlib.pyplot as plt, matplotlib as mpl
import seaborn as sns
import numpy as np, pandas as pd
output_root = os.environ.get("OUTPUT_ROOT", "output")
# ── Publication style (matches theme_Publication in R) ──
palette_cb = ["#0072B2","#E69F00","#009E73","#CC79A7",
"#56B4E9","#F0E442","#D55E00","#000000"]
sns.set_palette(palette_cb)
mpl.rcParams.update({
'font.family': 'Helvetica Neue', 'font.size': 12,
'axes.spines.top': False, 'axes.spines.right': False,
'figure.dpi': 150, 'savefig.dpi': 300, 'savefig.bbox': 'tight'
})
# ── Journal dimension presets ──
JOURNAL_DIMS = {
'default': (6, 4.5), 'asr': (6.5, 4.5), 'ajs': (6.5, 4.5),
'demography': (6.5, 5), 'nhb_single': (3.5, 3), 'nhb_double': (7.1, 4.5),
'ncs_single': (3.5, 3), 'ncs_double': (7.1, 4.5),
'sciadv': (7, 4.5), 'pnas': (3.4, 3),
}
# ── Export helper (mirrors R save_fig) ──
def save_fig(fig, name, journal='default', grayscale=False):
w, h = JOURNAL_DIMS.get(journal.lower(), JOURNAL_DIMS['default'])
fig.set_size_inches(w, h)
for fmt in ['pdf', 'png']:
fig.savefig(f"{output_root}/figures/{name}.{fmt}", dpi=300, bbox_inches='tight')
if grayscale:
# Convert to grayscale copy
import matplotlib.image as mpimg
from PIL import Image
img = Image.open(f"{output_root}/figures/{name}.png").convert('L')
img.save(f"{output_root}/figures/{name}-gs.png")
print(f"Saved: {output_root}/figures/{name} (.pdf + .png)")
B8 figure templates (parallel to B1-B7):
# B8-B1: Distribution with KDE
fig, ax = plt.subplots()
sns.histplot(df, x='outcome', hue='group', kde=True, stat='density', ax=ax)
ax.set_xlabel('Outcome'); ax.set_ylabel('Density')
save_fig(fig, 'fig-dist')
# B8-B2: Coefficient plot
import statsmodels.formula.api as smf
model = smf.ols('y ~ x + c1 + c2', data=df).fit(cov_type='HC3')
coef_df = (model.params.to_frame('coef')
.join(model.conf_int().rename(columns={0:'lo',1:'hi'}))
.drop('Intercept'))
fig, ax = plt.subplots(figsize=(5, len(coef_df)*0.5+1))
ax.errorbar(coef_df['coef'], range(len(coef_df)),
xerr=[coef_df['coef']-coef_df['lo'], coef_df['hi']-coef_df['coef']],
fmt='o', color=palette_cb[0], capsize=3)
ax.axvline(0, ls='--', color='gray', lw=0.8)
ax.set_yticks(range(len(coef_df))); ax.set_yticklabels(coef_df.index)
ax.set_xlabel('Coefficient (95% CI)')
save_fig(fig, 'fig-coef')
# B8-B3: Marginal effects
from marginaleffects import avg_slopes, plot_slopes
ame = avg_slopes(model)
fig = plot_slopes(model, variables='x')
save_fig(fig.figure, 'fig-ame')
# B8-B4: Event study (linearmodels)
# Use pyfixest for Python FE: import pyfixest as pf; m = pf.feols(...)
# B8-B7: Survival
from lifelines import KaplanMeierFitter
kmf = KaplanMeierFitter()
fig, ax = plt.subplots()
for grp in df['group'].unique():
mask = df['group'] == grp
kmf.fit(df.loc[mask, 'time'], df.loc[mask, 'event'], label=grp)
kmf.plot_survival_function(ax=ax)
ax.set_xlabel('Time'); ax.set_ylabel('Survival Probability')
save_fig(fig, 'fig-km')
B8-interactive: Plotly for interactive/web figures:
import plotly.express as px
import plotly.io as pio
# Interactive scatter with hover
fig = px.scatter(df, x='x', y='y', color='group', hover_data=['id','x','y'],
color_discrete_sequence=palette_cb)
fig.update_layout(template='simple_white', font_size=12)
pio.write_html(fig, f"{output_root}/figures/fig-scatter-interactive.html")
pio.write_image(fig, f"{output_root}/figures/fig-scatter-interactive.pdf", width=700, height=450)
pio.write_image(fig, f"{output_root}/figures/fig-scatter-interactive.png", width=700, height=450, scale=3)
# Interactive coefficient plot
fig = px.scatter(coef_df.reset_index(), x='coef', y='index',
error_x_minus=coef_df['coef']-coef_df['lo'],
error_x=coef_df['hi']-coef_df['coef'])
fig.add_vline(x=0, line_dash='dash', line_color='gray')
pio.write_html(fig, f"{output_root}/figures/fig-coef-interactive.html")
Engine selection: If VIZ_ENGINE=python is set in .env, default to Python for all B1-B7 equivalents. Otherwise default to R.
After completing B0–B8, launch a visualization verification subagent via the Task tool (subagent_type: general-purpose) to audit all figures before writing results.
Prompt the subagent with the following context:
ls ${OUTPUT_ROOT}/figures/ showing saved filesThe subagent performs these checks and returns a VISUALIZATION REPORT:
VISUALIZATION VERIFICATION REPORT
===================================
FILE EXPORT
[ ] save_fig() called for every ggplot figure (or equivalent savefig for Python)
[ ] Every figure exists in both .pdf and .png in output/[slug]/figures/
[ ] PNG DPI = 300 confirmed (check ggsave dpi= argument)
[ ] PDF uses cairo_pdf device (vector, embeds fonts correctly)
[ ] Interactive figures (plotly) saved as .html via htmlwidgets::saveWidget()
COLORBLIND SAFETY
[ ] scale_colour_Publication() or palette_cb (Wong 2011) used — not default ggplot2 colors
[ ] No red-green pair used together (#FF0000 + #00FF00 or similar)
[ ] Continuous scales use viridis or ColorBrewer diverging (not rainbow)
LABELS AND LEGIBILITY
[ ] X-axis and Y-axis labels present and human-readable (not raw variable names like "inc_log")
[ ] Legend title and levels labeled clearly (not "0 / 1" or raw factor codes)
[ ] Error bars explicitly labeled in caption: "Error bars = 95% CI" (or SEM / SD)
[ ] Figure caption is self-explanatory without reading main text
JOURNAL-SPECIFIC REQUIREMENTS
[ ] ASR/AJS: predicted probability or marginal effect plots used (not raw odds ratio forest plots)
[ ] Science Advances: panel labels in uppercase (A, B, C, …) for multi-panel figures
[ ] Science Advances: error bar type (SEM / SD / 95% CI) labeled in figure or legend
[ ] NHB: violin plot or boxplot used for group comparisons (not bar + error bar)
[ ] NHB: individual data points overlaid when N < 30 per group (geom_jitter or geom_point)
[ ] NHB: panel labels uppercase if multi-panel
FIGURE TYPE CORRECTNESS
[ ] Distribution: density/histogram appropriate; not a pie chart
[ ] Coefficient plot: reference line at zero present
[ ] Marginal effect plot: zero reference line present; y-axis labeled as AME or Pr(Y=1)
[ ] Event study: vertical dotted line at treatment onset (year_rel = -0.5); zero hline
[ ] RD plot: cutoff marked; separate trend lines each side
[ ] Love plot: threshold lines at ±0.1; pre- and post-match shown
[ ] Choropleth: legend shows units (%, $, rate); NA counties handled (fill="gray90")
[ ] Interactive: tooltip text informative; not just raw variable value
FILES ON DISK
[ ] output/[slug]/figures/ directory has at least one PDF and one PNG
[ ] All figure filenames follow fig-[type]-[variable] convention
RESULT: [PASS / NEEDS REVISION]
Issues to fix before proceeding:
1. [Specific issue + corrected code if applicable]
If the verification subagent returns NEEDS REVISION, fix all flagged issues and re-save affected figures before proceeding to B10 or Component C.
For theoretical frameworks, causal DAGs, process models, and flowcharts that don't require a data pipeline. These are generated as code and rendered to PDF/PNG.
B10a — Mermaid Diagrams (theoretical frameworks, process models, flowcharts):
# Write the Mermaid source
cat > "${OUTPUT_ROOT}/figures/fig-theoretical-framework.mmd" << 'EOF'
graph TD
A[Neighborhood Disadvantage] --> B[Institutional Resources]
A --> C[Social Cohesion]
B --> D[Health Outcomes]
C --> D
A --> D
E[Race/Ethnicity] --> A
E --> D
EOF
# Render via mmdc (Mermaid CLI) — install: npm install -g @mermaid-js/mermaid-cli
npx mmdc -i "${OUTPUT_ROOT}/figures/fig-theoretical-framework.mmd" \
-o "${OUTPUT_ROOT}/figures/fig-theoretical-framework.pdf" \
-w 800 -H 600 --backgroundColor white
npx mmdc -i "${OUTPUT_ROOT}/figures/fig-theoretical-framework.mmd" \
-o "${OUTPUT_ROOT}/figures/fig-theoretical-framework.png" \
-w 800 -H 600 --backgroundColor white -s 3
Common social science diagram templates:
| Diagram | Mermaid type | Use case |
|---|---|---|
| Mediation model | graph LR with A→M→Y + A→Y | Causal mediation |
| Moderation model | graph LR with M moderating A→Y edge | Interaction effects |
| Coleman's boat | graph TD with macro→micro→micro→macro | Analytical sociology |
| Lifecycle model | graph LR with temporal stages | Life course analysis |
| Research design flowchart | flowchart TD with decision nodes | CONSORT / sample flow |
| Multi-level structure | graph TD with nested boxes | MLM / HLM |
B10b — TikZ DAGs (for causal diagrams requiring precise layout):
cat > "${OUTPUT_ROOT}/figures/fig-dag.tex" << 'TIKZ'
\documentclass[tikz,border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{tikzpicture}[
node distance=2cm,
var/.style={circle,draw,minimum size=1cm,font=\small},
arr/.style={-{Stealth[length=3mm]},thick}
]
\node[var] (X) {$X$};
\node[var,right=of X] (Y) {$Y$};
\node[var,above right=1cm and 1cm of X] (Z) {$Z$};
\draw[arr] (X) -- (Y);
\draw[arr] (Z) -- (X);
\draw[arr] (Z) -- (Y);
\end{tikzpicture}
\end{document}
TIKZ
# Render via xelatex
cd "${OUTPUT_ROOT}/figures" && xelatex -interaction=nonstopmode fig-dag.tex
# Convert to PNG for inspection
convert -density 300 fig-dag.pdf fig-dag.png 2>/dev/null || \
sips -s format png fig-dag.pdf --out fig-dag.png 2>/dev/null || true
B10c — SVG Diagrams (for web / supplementary materials):
When Mermaid or TikZ are unavailable, generate SVG directly for simple diagrams. Claude Code can write SVG markup and save it, then convert to PDF via rsvg-convert or inkscape --export-pdf.
Rules for B10:
Read tool to inspect the rendered PNG and verify layout before proceedingTriggered when the user wants to modify an existing figure without re-running the full analysis pipeline. This mode reads an existing figure file, applies the requested changes, and saves the revised version using the version-check protocol.
Parse the user's request to identify:
output/figures/fig-coef-plot.pdf) or figure nameIf no file path is given, scan ${OUTPUT_ROOT}/figures/ for matching files:
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
ls -la "${OUTPUT_ROOT}/figures/"*.pdf "${OUTPUT_ROOT}/figures/"*.png 2>/dev/null
Use the Read tool to inspect the existing PNG to understand current layout, then identify the R or Python script that produced it:
# Check if a generating script exists
grep -rl "[figure_name]" "${OUTPUT_ROOT}/scripts/" 2>/dev/null
If the generating script exists, read it to understand the current code. If not, reconstruct from the figure type.
| Revision type | What to change |
|---|---|
| Rotate labels | theme(axis.text.x = element_text(angle = 45, hjust = 1)) |
| Resize | Update save_fig(p, name, w = NEW_W, h = NEW_H) dimensions |
| Relabel axes | labs(x = "New Label", y = "New Label") |
| Add reference line | geom_hline(yintercept = VALUE) or geom_vline(xintercept = VALUE) |
| Change colors | Swap palette or use scale_fill_manual(values = c(...)) |
| Adjust faceting | Change facet_wrap(~var, ncol = N) or switch to facet_grid() |
| Add/remove legend | theme(legend.position = "bottom"/"none"/"right") |
| Reorder categories | mutate(var = fct_reorder(var, sort_var)) |
| Add annotations | annotate("text", x = X, y = Y, label = "text") |
| Change to journal preset | Apply journal_dims$nhb_single or $asr dimensions from B0 |
| Add panel labels | library(patchwork); plot_annotation(tag_levels = "A") |
| Switch to grayscale | scale_colour_grey() + scale_fill_grey() |
| Convert R to Python | Load viz-templates-python.md and rewrite using equivalent template |
| Convert Python to R | Load viz-templates-ggplot.md and rewrite using equivalent template |
If a generating script exists in ${OUTPUT_ROOT}/scripts/, save the revised version using the script version-check protocol. Append a decision entry to coding-decisions-log.md noting the revision and rationale.
Using the actual numerical results from Components A and B, write complete, publication-ready prose. Replace every placeholder with real values. No brackets should remain in the final text.
| Journal | Effect estimate | Uncertainty | Significance | Target length |
|---|---|---|---|---|
| ASR | AME required for logit | SE in parentheses | Stars in tables + exact p in text | 1,500–2,500 words |
| AJS | AME preferred | SE in parentheses | Stars | 1,500–2,500 words |
| Demography | AME or OR + decomposition | Either | Stars | 2,000–3,000 words |
| Science Advances | AME preferred | 95% CI | Stars + ns marker | 1,500–2,000 words (main) |
| NHB | AME preferred | 95% CI + test stat + df | Stars + ns marker | 1,500–2,000 words (main) |
OLS:
"A one-unit increase in [X] is associated with a [β]-unit change in [Y], holding other variables constant (b = [β], SE = [SE], p = [p])."
AME from logit (ASR/AJS/Demography):
"A one-unit increase in [X] is associated with a [β×100] percentage point change in the probability of [Y] (AME = [β], 95% CI = [[lo], [hi]])."
AME from logit (NHB/Science Advances):
"A one-unit increase in [X] is associated with a [β×100] percentage point increase in the probability of [Y] (AME = [β], 95% CI = [[lo], [hi]], z = [z], p = [p])."
Fixed effects:
"Among [units] that changed [X] over time, a one-unit increase is associated with a [β]-unit change in [Y] (b = [β], SE = [SE], p = [p])."
Interaction:
"The effect of [X] on [Y] is [β₁] for [Group A] and [β₂] for [Group B]; this difference is [significant/not distinguishable from zero] (b_interaction = [Δβ], SE = [SE], p = [p])."
Null result:
"We find no statistically significant association between [X] and [Y] (b = [β], SE = [SE], p = [p])."
Practical significance:
"While statistically significant, the effect (b = [β]) represents [X]% of the outcome's SD, a [small/moderate/large] magnitude."
Robustness:
"Results are robust to [alternative sample restriction / alternative operationalization / alternative specification] (Table A1). Following Oster (2019), we estimate δ = [X], indicating that unobserved confounders would need to be [X] times more predictive of [Y] than our observed controls to explain away the finding."
LCA / Mixture models:
"Latent class analysis identified [K] distinct [typologies/profiles] based on [indicators] (Table X). A [K]-class solution provided the best fit (BIC = [X]; entropy = [X]). Class 1 ([X]%) was characterized by [pattern]; Class 2 ([X]%) by [pattern]."
Quantile regression:
"Quantile regression reveals that the association between [X] and [Y] varies across the outcome distribution (Table X; Figure X). At the 10th percentile, [X] is associated with [b] (SE = [SE], p = [p]), whereas at the 90th percentile the effect is [b] (SE = [SE], p = [p]). The OLS estimate of [b] masks this heterogeneity."
Zero-inflated / Hurdle:
"Given the excess zeros in [Y] ([X]% of observations), we estimated a zero-inflated negative binomial model (Table X). In the count process, [X] was associated with a [X]% [increase/decrease] in expected [Y] (IRR = [X], 95% CI = [[lo], [hi]], p = [p]). In the zero-inflation process, [Z] [increased/decreased] the probability of being a structural zero (OR = [X], 95% CI = [[lo], [hi]], p = [p])."
Specification curve analysis — see A8o in references/component-a-specialized.md for the canonical template (Simonsohn, Simmons & Nelson 2020, Nat Hum Behav).
Beta regression:
"Because [Y] is a bounded proportion, we estimated beta regression (Table X). [X] is associated with a [direction] in [Y] (b = [b], SE = [SE], p = [p]). The average marginal effect indicates a [AME] percentage-point change per one-unit increase in [X] (AME = [AME], 95% CI = [[lo], [hi]])."
Competing risks:
"The cumulative incidence of [event] at [T] years was [X]% (95% CI = [[lo]%, [hi]%]). In the Fine-Gray model, [X] was associated with a [X]% [higher/lower] subdistribution hazard of [event] (SHR = [X], 95% CI = [[lo], [hi]], p = [p]), accounting for the competing risk of [competing event]."
RI-CLPM:
"The RI-CLPM (Hamaker et al., 2015) separated stable between-person differences from within-person dynamics across [T] waves (Table X). At the within-person level, [X at time t] [predicted/did not predict] [Y at t+1] (b = [b], SE = [SE], p = [p]), while the reverse path was [significant/nonsignificant] (b = [b], SE = [SE], p = [p])."
Sequence analysis:
"Sequence analysis with optimal matching identified [K] distinct [trajectory] typologies (Table X; Figure X). Cluster 1 ('[label],' [X]%) was characterized by [pattern]. [Covariate] was associated with [higher/lower] odds of following the '[label]' trajectory (RRR = [X], 95% CI = [[lo], [hi]], p = [p])."
SEM / CFA:
"Confirmatory factor analysis established the measurement model (Table X). All loadings exceeded [.40] (p < .001). The model fit well (CFI = [X], TLI = [X], RMSEA = [X] [90% CI: [lo], [hi]], SRMR = [X]). In the structural model, [latent predictor] was [positively/negatively] associated with [latent outcome] (b = [b], beta = [beta], p = [p])."
Multiple testing correction:
"To account for [X] simultaneous tests, we applied [Benjamini-Hochberg / Holm] correction (Table X). After adjustment, [X] of [Y] hypotheses remained significant at FDR < .05."
Write the following four paragraph types in order. Each must contain actual numbers.
¶1 SAMPLE DESCRIPTION
Overall N; group sizes if stratified; means and SDs for key variables; reference Table 1.
Note exclusions and reason.
¶2 MAIN FINDINGS (H1 test)
State whether H1 is supported. Report focal coefficient with full statistics.
Describe attenuation (or lack thereof) from M1 → M2. Reference Table 2.
¶3 EXTENDED MODEL (H2/moderation/mediation if applicable)
M3 results; conditional effects at key moderator values; reference the marginal effects figure.
Skip if no moderation/mediation hypothesis.
¶4 ROBUSTNESS
2–4 sentences summarizing Table A1. Confirm main finding holds.
Report Oster delta if OLS + causal language.
Within-Group / Between-Group Interpretation Check (MANDATORY when comparing two or more groups):
When the analysis compares groups (e.g., language corpora, treatment vs. control, racial groups), report BOTH perspectives before writing any interpretive claim:
INTERPRETATION CHECK — [Group comparison: e.g., Chinese vs English]
Between-group (cross-group AMEs / coefficient differences):
- [Variable]: Group A has [X more/less] than Group B (AME = [value])
Within-group (absolute distributions for each group separately):
- Group A: [key metric] = [value] (e.g., 18.4% positive, 20.1% negative → net -1.7pp)
- Group B: [key metric] = [value] (e.g., 13.5% positive, 35.1% negative → net -21.6pp)
⚠ CONSISTENCY CHECK:
- Do between-group and within-group comparisons support the SAME interpretation?
- If not, flag: "WARNING: Cross-group framing suggests [X]; within-group shows [Y].
Both perspectives must be reported in the Results prose."
Example of a flagged inconsistency:
Cross-group: "CN has less negative Dem content than EN (AME = -6.8pp)" suggests CN is less hostile Within-group: "CN Dem sentiment is 29.2% neg vs 5.5% pos (5:1 ratio); CN Trump is 20.1% neg vs 18.4% pos (nearly balanced)" shows CN is selectively critical of Democrats → Both must be reported; the within-group framing is more consequential for interpretation
Append this check to the analysis log and include it in the Results prose output (File 2).
Writing rules:
references/adjudication-rule.md; every hypothesis statement uses the prose_verb column from adjudication-log.csv verbatim. "Directionally consistent" is reserved for adjudication_code = AMBIGUOUS and must NOT read as "supported". Never write "proves".This component runs cross-cuttingly throughout Components A and B. It ensures every executed code block is saved as a self-contained script, every analytic decision is logged with rationale, and a master script index maps scripts to paper elements — so that building a replication package later (via /scholar-open) requires assembly, not reconstruction.
Run at the start of every scholar-analyze session, immediately after mkdir:
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
# Initialize coding decisions log
cat > "${OUTPUT_ROOT}/scripts/coding-decisions-log.md" << 'LOGEOF'
# Coding Decisions Log
<!-- Append-only log. Each entry records one analytic decision with rationale. -->
| Timestamp | Step | Decision | Alternatives Considered | Rationale | Variables Affected | Script |
|-----------|------|----------|------------------------|-----------|-------------------|--------|
LOGEOF
# Initialize script index
cat > "${OUTPUT_ROOT}/scripts/script-index.md" << 'IDXEOF'
# Script Index
## Run Order
| # | Script | Purpose | Input | Output | Paper Element |
|---|--------|---------|-------|--------|---------------|
IDXEOF
Follow the version control protocol defined in .claude/skills/_shared/script-version-check.md. NEVER overwrite an existing script. Always version-check before saving.
Save timing differs by step class (pre-execution-review protocol, v5.29.1):
04–09* are WRITTEN at sub-stage A2.5 BEFORE execution, reviewed, and then executed from the reviewed files. The save IS the drafting step; post-review edits re-enter Step 6 re-review.[CODE-TEMPLATE]), save the complete script.Either way, save to ${OUTPUT_ROOT}/scripts/[NN]-[name].[ext] — and run the version check first:
# MANDATORY: Run before EVERY script Write tool call
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
SCRIPT_NAME="04-main-models" # Replace with actual script name
EXT="R" # R, py, do, jl
SCRIPT_DIR="${OUTPUT_ROOT}/scripts"
mkdir -p "$SCRIPT_DIR"
SCRIPT_BASE="${SCRIPT_DIR}/${SCRIPT_NAME}"
if [ -f "${SCRIPT_BASE}.${EXT}" ]; then
V=2
while [ -f "${SCRIPT_BASE}-v${V}.${EXT}" ]; do V=$((V + 1)); done
SCRIPT_BASE="${SCRIPT_BASE}-v${V}"
fi
echo "SCRIPT_PATH=${SCRIPT_BASE}.${EXT}"
Use the printed SCRIPT_PATH as file_path in the Write tool call. Shell variables do NOT persist between Bash tool calls — re-derive in every new call.
Standard script header (prepend to every saved script):
# ============================================================
# Script: [NN]-[name][-vN].R
# Version: [v1 | v2 | v3 ...]
# Purpose: [one-line description]
# Input: [data file or prior script output]
# Output: [tables, figures, or objects produced]
# Date: [YYYY-MM-DD]
# Seed: set.seed(42)
# Changes: [if v2+, one-line summary of what changed from prior version]
# Notes: [SE type, sample restrictions, key parameters]
# ============================================================
Scripts must be self-contained: include explicit library() calls, data loading (readRDS()/read_csv()), and set.seed(). No reliance on in-memory objects from prior scripts.
Step-to-filename mapping:
| Step | Script name | Description |
|---|---|---|
| A1 | 01-data-loading.R | Load + inspect data |
| A2 | 03-descriptives-table1.R | Descriptive statistics table |
| A3 | 04-main-models.R | Regression model ladder |
| A4 | 05-marginal-effects.R | AME computation |
| A5 | 06-diagnostics.R | VIF, BP test, Cook's D |
| A6 | 07-export-tables.R | modelsummary export |
| A7 | 08-robustness.R | Robustness checks + Oster |
| A8 | 09-decomposition.R | Oaxaca-Blinder (if applicable) |
| A8a | 09a-lca-mixture.R | Latent class analysis (if applicable) |
| A8b | 09b-quantile-regression.R | Quantile regression (if applicable) |
| A8c | 09c-zero-inflated.R | Zero-inflated / hurdle models (if applicable) |
| A8d | 09d-beta-regression.R | Beta regression (if applicable) |
| A8e | 09e-competing-risks.R | Competing risks models (if applicable) |
| A8f | 09f-riclpm.R | RI-CLPM (if applicable) |
| A8g | 09g-sequence-analysis.R | Sequence analysis (if applicable) |
| A8h | 09h-sem-cfa.R | Full SEM / CFA (if applicable) |
| A8i | 09i-multiple-testing.R | Multiple testing correction (if applicable) |
| A8j | 09j-gamlss.R | GAMLSS distributional regression (if applicable) |
| A8k | 09k-dml-bridge.R | DML / Causal Forest bridge (if high-dim controls) |
| A8l | 09l-growth-curve.R | Growth curve models (if trajectory data) |
| A8m | 09m-multilevel-sem.R | Multilevel SEM (if nested + latent) |
| A8n | 09n-finite-mixture-regression.R | Finite mixture regression (if latent heterogeneity) |
| A8o | 09o-specification-curve.R | Specification curve / multiverse (if robustness) |
| A8p | 09p-bart.R | BART causal / predictive (if nonparametric) |
| — | 04-main-models.do | Stata parallel .do file (if Stata requested) |
| B0 | 10-viz-setup.R | Theme + palette + save_fig() + journal presets |
| B0b | — | Figure brief (user confirmation, not a script) |
| B0c | — | Inspect-and-revise protocol (not a script) |
| B1 | 11-viz-descriptive.R | Distribution + violin + bar |
| B2 | 12-viz-coefficient.R | Coefficient / forest plot |
| B3 | 13-viz-marginal.R | AME + interaction + predicted |
| B4 | 14-viz-event-study.R | Event study (if DiD) |
| B5 | 15-viz-rd.R | RD plot (if RD) |
| B6 | 16-viz-balance.R | Love plot (if matching) |
| B7 | 17-viz-survival.R | Kaplan-Meier (if survival) |
| B8 | 18-viz-python.py | Python figures (if VIZ_ENGINE=python) |
| B10 | 19-viz-diagrams.* | Conceptual diagrams (Mermaid/TikZ/SVG) |
No-data mode: Save with # [CODE-TEMPLATE] — run when data available as the first line after the header.
After EVERY analytic step in A0–A8, append an entry to ${OUTPUT_ROOT}/scripts/coding-decisions-log.md via Bash >>. Each entry records one decision:
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
echo "| $(date '+%Y-%m-%d %H:%M') | A3 | OLS with HC3 robust SEs | Default SEs, clustered SEs | HC3 chosen because heteroskedasticity detected (BP p < .05) | Y, X, C1-C4 | 04-main-models.R |" >> "${OUTPUT_ROOT}/scripts/coding-decisions-log.md"
Required decision categories (log at least one entry for each when applicable):
This incremental-persistence pattern protects against context compaction — decisions are on disk the moment they are made.
After each script is saved in D1, append a row to the run-order table in ${OUTPUT_ROOT}/scripts/script-index.md:
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
echo "| 4 | 04-main-models.R | Main regression ladder (M1-M3) | data/analysis_data.rds | ${OUTPUT_ROOT}/tables/table2-regression.html | Table 2 |" >> "${OUTPUT_ROOT}/scripts/script-index.md"
At the end of the run, finalize script-index.md by appending:
## Dependencies
- Scripts 03–09 depend on 01-data-loading.R output
- Scripts 10–18 depend on model objects from 04 and 05
## Seeds
All scripts use `set.seed(42)`.
## Paper-Element Correspondence
| Paper element | Script(s) | Output file(s) |
|---------------|-----------|----------------|
| Table 1 | 03-descriptives-table1.R | output/[slug]/tables/table1-descriptives.html/.tex/.docx/.csv |
| Table 2 | 04-main-models.R, 07-export-tables.R | output/[slug]/tables/table2-regression.html/.tex/.docx/.csv |
| Figure 1 | 11-viz-descriptive.R | output/[slug]/figures/fig-dist-outcome.pdf/.png |
| ... | ... | ... |
## Coding Decisions
See [coding-decisions-log.md](coding-decisions-log.md) for the full decision rationale log.
output/[slug]/tables/, output/[slug]/figures/, output/[slug]/scripts/)/scholar-causal invoked (or confirmed already run)pre-exec-review-check.sh GREEN (receipt row logged) — or --skip-preexec-review logged + justified in Limitationsame-[model].csv) for every logit / probit / ordered-logit model (MANDATORY per results-registry-contract.md — do not hand-compute AMEs from coefficients; use marginaleffects::avg_slopes())results-registry.csv saved — one row per (hypothesis × model spec) mapping hypothesis_id → coefficient, AME, table_ref, figure_ref (see ../_shared/results-registry-contract.md)adjudication-log.csv saved — one row per hypothesis with adjudication_code computed by the coded rule in references/adjudication-rule.md (no prose-only adjudication)verify/family-correction-<HID>.csv saved for every K ≥ 3 hypothesis family — verdicts derived from p_adj, never p_raw (see the multiple-testing rule and family-correction self-check in references/adjudication-rule.md; a family with no surviving corrected cell is NOT_SUPPORTED, never "partial support")coefficients-[model].csv saved for every fitted model (raw β, SE, CI, p, n)prose_verb column from the log; no synonyms invented by the writeroutput/[slug]/scripts/ (D1)scholar-analyze-log-[topic]-[date].md) — decisions, verification, file inventoryscholar-analyze-results-[topic]-[date].md) — Results prose + table notes + figure captions; no brackets remainingPurpose: Before the analysis log and publication-ready results are saved to disk, run a 5-agent review panel on the assembled analysis outputs. Each reviewer evaluates from a distinct analytic lens. A synthesizer aggregates consensus flags, a reviser produces improved outputs, and the user accepts the revision before Save Output.
Relation to other skills: This panel complements — does not replace — downstream /scholar-code-review (script auditing) and /scholar-verify (analysis-to-manuscript consistency). The panel catches issues early, at the analysis-finalization step; /scholar-code-review and /scholar-verify provide deeper, specialized audits later.
This step is REQUIRED. Skip only if the user explicitly passed --skip-review in $ARGUMENTS.
Compile the following in-memory (not yet saved):
output/[slug]/tables/*.html, output/[slug]/models/*.rds, output/[slug]/figures/*.pdfoutput/[slug]/scripts/*.R with headersUse the Task tool to run all 5 reviewers in parallel (five simultaneous tool calls). Fill in [journal], [design type], and [REVIEW PACKAGE] in each prompt.
R1 — Estimator & Statistical Correctness Reviewer
Spawn a general-purpose agent:
"You are a statistician auditing an analysis for a paper targeting [journal] using a [design type] design. Critique the estimator and statistical choices. Evaluate each item as Strong / Adequate / Weak and give 3–5 specific, actionable comments:
- Estimator-outcome match: Is the estimator appropriate for the outcome type (OLS for continuous; logit/probit for binary; ordered logit/multinomial for categorical; Poisson/NB for counts; Cox/AFT for survival)? Flag mismatches.
- Standard errors: Does the SE type match the data structure (clustered SEs for multi-level / panel; HAC for time series; bootstrap for small N)? Is the clustering level correct and pre-specified?
- AME reporting: For every logit/probit/ordered outcome, is AME reported (not just ORs/log-odds) and sourced from
marginaleffects::avg_slopes()— not hand-computed?- Variable coding: Are categorical variables coded with sensible reference categories? Are continuous variables scaled/centered when interactions are involved? Are post-treatment controls excluded?
- Effect size + significance: Are effect sizes reported alongside p-values? Are confidence intervals provided? Is multiple-testing correction applied if ≥ 5 hypotheses?
End with your single most important fix.
REVIEW PACKAGE: [paste package]"
R2 — Table & Figure Quality Reviewer
Spawn a general-purpose agent:
"You are a journal production editor auditing tables and figures for a paper targeting [journal]. Critique artifact quality and publication-readiness. Evaluate each item as Strong / Adequate / Weak and give 3–5 specific, actionable comments:
- Table completeness: Does every table have: column headers, N, R² / pseudo-R², SE type stated in notes, reference categories noted, significance stars defined, variable labels (not raw names)?
- Figure quality: Are figures 300 DPI, colorblind-safe (no red-green), legend/axis labels in plain language, error bars with CI level stated, caption self-contained?
- Export formats: Are tables exported in all required formats (HTML + TeX + docx + CSV for regression; CSV for
ame-[model].csv,coefficients-[model].csv,results-registry.csv)?- Journal norms: Does artifact format match [journal]? (ASR/AJS: star notation, 2 decimals. Demography: standardized betas possible. Nature: self-contained figure captions, extended data figures allowed.)
- Table 1 descriptives: Is Table 1 stratified by main exposure/treatment when appropriate? Are N, means/%, SDs reported? Is missingness disclosed?
End with the single most impactful fix.
REVIEW PACKAGE: [paste package]"
R3 — Robustness Coverage Reviewer
Spawn a general-purpose agent:
"You are a methodologist reviewing the robustness plan for a paper targeting [journal] with a [design type] design. Critique whether robustness checks adequately address the validity threats. Evaluate each item as Strong / Adequate / Weak and give 3–5 specific, actionable comments:
- Threat-to-check mapping: For each validity threat (confounding, selection, measurement error, model dependence, spillovers), is there a corresponding robustness check? Name any unaddressed threat.
- Omitted variable sensitivity: Is Oster's delta or an E-value computed for the primary causal/associational claim?
- Alternative specifications: Are at least 3 alternative model specifications run (different controls, subsample, functional form)? Are results qualitatively consistent?
- Sample restrictions: Are sample definitions ablated (listwise vs MI; restricted vs full)? Does the main finding survive?
- Placebo / negative controls: For causal designs, is a placebo test or negative control reported where feasible?
End with the single most important missing robustness check.
REVIEW PACKAGE: [paste package]"
R4 — Results-Prose Alignment Reviewer
Spawn a general-purpose agent:
"You are a careful editor auditing alignment between results artifacts and the Results prose for a paper targeting [journal]. Critique one-to-one alignment between hypotheses, artifacts, and prose. Evaluate each item as Strong / Adequate / Weak and give 3–5 specific, actionable comments:
- Hypothesis coverage: Is every hypothesis in
results-registry.csvaddressed in the Results prose? Flag any orphaned hypothesis.- Adjudication fidelity: Does the prose use the exact
prose_verbfromadjudication-log.csvfor each hypothesis? Flag any synonym substitution (e.g., prose says 'supports' when log says 'partially supports').- Numeric fidelity: Pick 5 numeric claims at random from the prose. For each, does the value match the source table/CSV (check rounding, sign, units)?
- Causal language calibration: If design is observational, is causal language ('causes', 'leads to', 'reduces') absent? If quasi-experimental, is it bounded by identifying assumptions?
- Null findings honesty: Are null or negative findings reported transparently — not buried, omitted, or spun as 'marginal'?
End with a list of specific lines/claims that need fixing.
REVIEW PACKAGE: [paste package]"
R5 — Reproducibility Reviewer
Spawn a general-purpose agent:
"You are a replication editor auditing reproducibility of an analysis targeting [journal]. Critique whether a third party could re-execute this analysis. Evaluate each item as Strong / Adequate / Weak and give 3–5 specific, actionable comments:
- Seeds: Is
set.seed()called in every script that uses randomness (bootstrap, MI, cross-validation, jitter)? Are seeds documented in the log?- Environment: Is
renv.lock/requirements.txt/environment.ymlpresent? Are package versions pinned? Is R/Python version documented?- Script headers: Does every script in
output/[slug]/scripts/have purpose, input, output, date, seed, author?- Paper-element correspondence: Is there a table mapping every Table N / Figure N to the exact script that produces it? Are file paths relative (not absolute)?
- Data availability statement: Is the data source documented (public URL, DOI, restricted-access DUA)? Is the access pathway clear for a replicator?
End with the single most blocking reproducibility gap.
REVIEW PACKAGE: [paste package]"
After all 5 reviewers return, produce an Analysis Review Scorecard:
===== INTERNAL ANALYSIS REVIEW PANEL — [Topic] — [Journal] =====
Panel: R1 (Estimator) | R2 (Tables/Figures) | R3 (Robustness) | R4 (Prose Alignment) | R5 (Reproducibility)
| Dimension | R1 | R2 | R3 | R4 | R5 | Consensus |
|-----------|----|----|----|----|----|-----------|
| Estimator-outcome match | [S/A/W] | — | — | — | — | [S/A/W] |
| Standard errors | [S/A/W] | — | — | — | — | [S/A/W] |
| AME reporting | [S/A/W] | — | — | — | — | [S/A/W] |
| Table completeness | — | [S/A/W] | — | — | — | [S/A/W] |
| Figure quality | — | [S/A/W] | — | — | — | [S/A/W] |
| Export formats | — | [S/A/W] | — | — | — | [S/A/W] |
| Threat-to-check mapping | — | — | [S/A/W] | — | — | [S/A/W] |
| Oster delta / E-value | — | — | [S/A/W] | — | — | [S/A/W] |
| Alternative specs | — | — | [S/A/W] | — | — | [S/A/W] |
| Hypothesis coverage | — | — | — | [S/A/W] | — | [S/A/W] |
| Adjudication fidelity | — | — | — | [S/A/W] | — | [S/A/W] |
| Numeric fidelity | — | — | — | [S/A/W] | — | [S/A/W] |
| Causal language calibration | — | — | — | [S/A/W] | — | [S/A/W] |
| Seeds + environment | — | — | — | — | [S/A/W] | [S/A/W] |
| Script headers + correspondence | — | — | — | — | [S/A/W] | [S/A/W] |
| **Weak items count** | [N] | [N] | [N] | [N] | [N] | **[total]** |
★★ Cross-agent agreement (flagged by 2+ reviewers — highest priority):
1. [Issue] — flagged by [R#, R#] — [summary]
...
Top fix from each reviewer:
- R1: [fix]
- R2: [fix]
- R3: [fix]
- R4: [fix]
- R5: [fix]
OVERALL VERDICT: [Ready to save / Revise before save / Rerun analysis]
Log this phase:
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
SKILL_NAME="scholar-analyze"
LOG_DATE=$(date +%Y-%m-%d)
LOG_FILE="${OUTPUT_ROOT}/logs/process-log-${SKILL_NAME}-${LOG_DATE}.md"
if [ ! -f "$LOG_FILE" ]; then
LOG_FILE=$(ls -t ${OUTPUT_ROOT}/logs/process-log-${SKILL_NAME}-${LOG_DATE}*.md 2>/dev/null | head -1)
fi
echo "| IRP-C | $(date +%H:%M:%S) | Review Scorecard | 5-agent panel synthesized | scorecard in-memory | ✓ |" >> "$LOG_FILE"
Spawn a reviser subagent:
"You are an expert social science analyst revising an analysis package for [journal]. You have feedback from a 5-agent review panel covering estimator correctness, table/figure quality, robustness coverage, results-prose alignment, and reproducibility. Produce a revised package that addresses all valid concerns.
Instructions:
- Address every ★★ item (cross-agent agreement) first
- Address every item rated Weak; note any skipped items with reason
- Do not change anything rated Strong by 2+ reviewers
- If R1 flagged a wrong estimator or R5 flagged unreproducible code, produce a Rerun Required block at the top — do NOT proceed to Save Output; the user must rerun the affected scripts
- Apply edits to: the Results prose draft, table/figure notes, adjudication-log adjustments, and script header fixes. Mark each substantive revision
[REV: reason]- After the revised package, append a Revision Notes block listing ★★ items addressed, other changes, and reviewer comments not acted on with reason
Original REVIEW PACKAGE: [paste] Analysis Review Scorecard: [paste] R1 feedback: [paste] | R2: [paste] | R3: [paste] | R4: [paste] | R5: [paste]"
yes / accept with edits / keep original / rerun)"
yes: Use revised package for Save Outputaccept with edits: Apply user's specific edits, then proceedkeep original: Append Scorecard + Revision Notes as an appendix to the saved logrerun: Do NOT save; return to the failing component (A/B/C/D) for re-executionOUTPUT_ROOT="${OUTPUT_ROOT:-output}"
SKILL_NAME="scholar-analyze"
LOG_DATE=$(date +%Y-%m-%d)
LOG_FILE="${OUTPUT_ROOT}/logs/process-log-${SKILL_NAME}-${LOG_DATE}.md"
if [ ! -f "$LOG_FILE" ]; then
LOG_FILE=$(ls -t ${OUTPUT_ROOT}/logs/process-log-${SKILL_NAME}-${LOG_DATE}*.md 2>/dev/null | head -1)
fi
echo "| IRP-E | $(date +%H:%M:%S) | Accept Revision | [user decision] | — | ✓ |" >> "$LOG_FILE"
HARD STOP: Do NOT proceed to Save Output until the user accepts. If rerun, loop back to the flagged component.
Confirm all of the following before moving to Save Output:
Use the Write tool to save two separate files after completing all components.
Before EVERY Write tool call below, run this Bash block to determine the correct save path. Do NOT hardcode paths from the filename templates — they show naming patterns only.
# MANDATORY: Replace [values] with actuals before running
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
# BASE pattern: ${OUTPUT_ROOT}/[slug]/analysis/scholar-analyze-log-[topic-slug]-[YYYY-MM-DD]
# Split into directory and stem for the gate script:
OUTDIR="$(dirname "${OUTPUT_ROOT}/[slug]/analysis/scholar-analyze-log-[topic-slug]-[YYYY-MM-DD]")"
STEM="$(basename "${OUTPUT_ROOT}/[slug]/analysis/scholar-analyze-log-[topic-slug]-[YYYY-MM-DD]")"
mkdir -p "$OUTDIR"
bash "${SCHOLAR_SKILL_DIR:-.}/scripts/gates/version-check.sh" "$OUTDIR" "$STEM"
Use the printed SAVE_PATH as file_path in the Write tool call. Re-run this block (with the appropriate BASE) for each additional file. The same version suffix must be used for all related output files (.md, .docx, .tex, .pdf).
For File 2, change the BASE to:
${OUTPUT_ROOT}/[slug]/analysis/scholar-analyze-results-[topic-slug]-[YYYY-MM-DD]
Filename: scholar-analyze-log-[topic-slug]-[YYYY-MM-DD].md
Purpose: Technical record for your own reference — decisions, verification results, file inventory. Not for submission.
Template:
# Analysis Log: [Topic] — [YYYY-MM-DD]
## Data Source
- Mode: [1 / 2 / 3]
- Source: [file path / inline description / package + dataset name + citation]
- N (raw): [X]; N (analytic): [X]; exclusions: [reason]
## Analytic Decisions
- Outcome (Y): [variable name + measurement]
- Key predictor (X): [variable name + measurement]
- Controls: [list]
- Model type: [OLS / logit / FE / Cox / etc.]
- SE type: [HC3 / clustered by unit / default]
- Causal design: [/scholar-causal invoked: yes/no; strategy: DiD / RD / IV / none]
## Verification Results
- A9 Analysis Verification: [PASS / issues fixed: ...]
- B9 Visualization Verification: [PASS / issues fixed: ...]
## Key Estimates (Quick Reference)
| Predictor | β / AME | SE / 95% CI | p |
|-----------|---------|-------------|---|
| [X] | [β] | [SE] | [p] |
| ... | | | |
## Robustness Summary
- No outliers: [β, p] vs. main [β, p] — [holds / attenuates]
- Alt measure: [β, p] vs. main [β, p] — [holds / attenuates]
- Oster δ: [X] — [interpretation]
## File Inventory
output/[slug]/tables/table1-descriptives.html / .tex / .docx
output/[slug]/tables/table2-regression.html / .tex / .docx
output/[slug]/tables/table2-ame.html / .tex / .docx (if logit)
output/[slug]/tables/tableA1-robustness.html / .tex / .docx
output/[slug]/figures/fig-dist-outcome.pdf / .png
output/[slug]/figures/fig-coef-plot.pdf / .png
output/[slug]/figures/fig-ame-[x].pdf / .png (if plotted)
output/[slug]/figures/fig-event-study.pdf / .png (if DiD)
[list all actual figures generated]
## Script Archive
output/[slug]/scripts/coding-decisions-log.md
output/[slug]/scripts/script-index.md
output/[slug]/scripts/[list all saved scripts, e.g.:]
01-data-loading.R
03-descriptives-table1.R
04-main-models.R
05-marginal-effects.R
[... etc.]
Filename: scholar-analyze-results-[topic-slug]-[YYYY-MM-DD].md
Purpose: Drop-in material for the manuscript. Contains the complete Results section prose, table notes, and figure captions — all formatted for the target journal. Ready to paste into /scholar-write.
Template — fill every placeholder with actual values before saving:
# Results: [Paper Title or Topic]
*Target journal: [ASR / AJS / Demography / Science Advances / NHB]*
*Word count: ~[XXX] words (target: [journal limit])*
---
## Results
[¶1 — SAMPLE DESCRIPTION]
The analytic sample comprises [N] [units/respondents/observations] drawn from [data source].
[Key group sizes if stratified.] Table 1 presents descriptive statistics. [Outcome variable]
averages [M] (SD = [SD]) overall[; Group A: M = [Ma], Group B: M = [Mb], p = [p]].
[Note any exclusions and reason.]
[¶2 — MAIN FINDINGS]
[State H1 support.] [Focal predictor] is [positively/negatively] associated with [outcome]
after adjusting for [list key controls] (b = [β], SE = [SE], p = [p]; Table 2, Column 2).
[For logit:] The average marginal effect indicates a [β×100] percentage point [increase/decrease]
in the probability of [outcome] per one-unit increase in [X] (AME = [β], 95% CI = [[lo], [hi]]).
[Describe coefficient stability M1 → M2.] [Reference figure if applicable: Figure 1.]
[¶3 — EXTENDED MODEL / INTERACTION / MEDIATION — omit if not applicable]
[M3 results. Conditional effects at key moderator values. Reference Figure X.]
[¶4 — ROBUSTNESS]
Results are robust to [alternative sample restriction / alternative operationalization /
alternative specification] (Table A1, Columns 2–3). [Report Oster delta if applicable:
Following Oster (2019), we estimate δ = [X], indicating that unobserved confounders
would need to be [X] times more predictive of [Y] than our observed controls to
explain away the finding.]
---
## Table Notes
**Table 1. Descriptive Statistics[, by Group]**
*Note.* [Describe statistics shown (mean/SD or N/%); sample; any weighting applied.]
[N = X.]
**Table 2. [Regression Results / Average Marginal Effects]: [Outcome] on [Predictor(s)]**
*Note.* [SE type] in parentheses. [Reference category for key categorical predictors.]
[Sample description.] [Significance: * p < .05, ** p < .01, *** p < .001.]
[N = X per column or as shown.]
**Table A1. Robustness Checks**
*Note.* Column 1 replicates the main model (Table 2, Column [X]).
Column 2 [description of restriction/change]. Column 3 [description].
[SE type] in parentheses. * p < .05, ** p < .01, *** p < .001.
---
## Figure Captions
**Figure 1. [Descriptive title: what is shown and for whom]**
[Self-explanatory caption: describe what each axis represents, what the shading/color codes, what error bars show (95% CI / SE / SD), data source, and analytic sample. Do not rely on main text to interpret.] N = [X].
**Figure 2. [Title]**
[Caption.] [Error bars = 95% CI.] N = [X].
[Add one caption block per figure generated in Component B.]
Confirm all three output paths to user at end of run.
See references/analysis-standards.md for journal-specific reporting requirements and references/viz-standards.md for figure type guide and export standards.
Output files produced by this skill:
output/[slug]/tables/ — regression tables and descriptive stats (.html / .tex / .docx)output/[slug]/figures/ — all figures (.pdf / .png; interactive as .html)output/[slug]/scripts/ — self-contained analysis scripts ([NN]-[name].R/.py), coding-decisions-log.md, script-index.mdscholar-analyze-log-[topic]-[date].md — internal technical log (decisions, verification, file inventory)scholar-analyze-results-[topic]-[date].md — publication-ready: Results section prose + table notes + figure captions; ready to paste into /scholar-writePost-analysis verification:
The fast 3 review agents (statistics, data-handling, correctness) already adjudicated the model ladder at sub-stage A2.5 — that part is a gate, not a suggestion. After all tables and figures are produced, suggest to the user:
"Analysis outputs saved (model scripts passed pre-execution review at A2.5). Consider also running:
/scholar-code-review fullto add the 3 deferred review dimensions (reproducibility,robustness,style) across all scripts./scholar-verify stage1to verify raw outputs (tables, figures) are internally consistent before writing. These catch the remaining error classes before they propagate into the manuscript."
The deferred-3 follow-up is a recommendation, not a gate — the user may proceed directly to /scholar-write if preferred. If run, scholar-code-review launches 6 review agents on scripts in output/scripts/; scholar-verify stage1 launches verify-numerics and verify-figures on the raw outputs in output/tables/ and output/figures/.
SKILL_DIR="${SCHOLAR_SKILL_DIR:-.}/.claude/skills"
KG_REF="$SKILL_DIR/_shared/knowledge-graph-search.md"
if [ -f "$KG_REF" ]; then
eval "$(cat "$KG_REF" | sed -n '/^```bash/,/^```/p' | sed '1d;$d')" 2>/dev/null
if kg_available 2>/dev/null; then
echo ""
echo "═══ Knowledge Graph ═══"
echo "File your new findings back into the knowledge graph:"
echo " /scholar-knowledge ingest from output [results-file-path]"
echo "This lets future /scholar-write and /scholar-lit-review runs reference your own empirical results."
fi
fi
Close Process Log:
Run the following to finalize the process log:
OUTPUT_ROOT="${OUTPUT_ROOT:-output}"
SKILL_NAME="scholar-analyze"
LOG_DATE=$(date +%Y-%m-%d)
LOG_FILE="${OUTPUT_ROOT}/logs/process-log-${SKILL_NAME}-${LOG_DATE}.md"
if [ ! -f "$LOG_FILE" ]; then
LOG_FILE=$(ls -t "${OUTPUT_ROOT}/logs/process-log-${SKILL_NAME}-${LOG_DATE}"*.md 2>/dev/null | head -1)
fi
cat >> "$LOG_FILE" << LOGFOOTER
## Output Files
[list each output file path as a bullet]
## Summary
- **Steps completed**: [N completed]/[N total]
- **Files produced**: [count]
- **Errors**: [count, or 0]
- **Time finished**: $(date +%H:%M:%S)
LOGFOOTER
echo "Process log saved to $LOG_FILE"
references/adjudication-rule.md (opens in a new tab)references/analysis-standards.md (opens in a new tab)references/component-a-bayesian.md (opens in a new tab)references/component-a-core.md (opens in a new tab)references/component-a-export-robustness.md (opens in a new tab)references/component-a-regression.md (opens in a new tab)references/component-a-specialized.md (opens in a new tab)references/component-a-verification.md (opens in a new tab)references/design-router.md (opens in a new tab)references/ladder-decomposition.md (opens in a new tab)references/ladder-observational-causal.md (opens in a new tab)references/ladder-observational-descriptive.md (opens in a new tab)references/ladder-predictive-ml.md (opens in a new tab)references/ladder-quasi-experimental.md (opens in a new tab)references/ladder-rct.md (opens in a new tab)references/viz-standards.md (opens in a new tab)references/viz-templates-ggplot.md (opens in a new tab)references/viz-templates-python.md (opens in a new tab)references/viz_setting.R (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub joshzyj/open-scholar-skill --plugin open-scholar-skill36 skills in this plugin
/scholar-annotateTurn unstructured text into validated, structured variables at corpus scale with LLMs: codebook design, dev/gold-set construction, DSPy prompt optimization, a hard reliability gate (Cohen κ ≥ 0.70), scale-out via managed Batch APIs or a local/HPC server, and distillation to a cheap classifier for very large corpora. Use for LLM annotation, classification, framing/stance coding, relevance filtering, structured extraction, and any LLM-as-measurement task over a text corpus. Ships a real execution engine (assets/) — not in-context snippets./scholar-auto-improveAutomatic quality auditor and continuous improvement engine for the scholar-skill suite. Four modes: (1) OBSERVE — post-skill output audit (run after any skill); (2) AUDIT — skill-suite structural health check; (3) IMPROVE — propose and apply fixes to skill definitions; (4) EVOLVE — cross-session pattern analysis and systemic improvements. Designed to run automatically at the end of any scholar-skill invocation.
/scholar-auto-researchStable, deterministic social-science research-paper pipeline from idea or data to verified manuscript, citations, replication package, and final md/docx/tex/pdf outputs. Use when the user wants a reliable end-to-end auto-research chain that avoids the evolving scholar-full-paper workflow./scholar-brainstormGenerate research questions from existing materials — codebooks, survey questionnaires, datasets, or published papers/abstracts. Three modes: DATA (data files with safety scan + empirical signal tests), MATERIALS (codebook/questionnaire only with theory-driven ranking), PAPER (published paper/abstract → follow-up research ideas via SciThinker-30B + multi-agent evaluation). Auto-detects mode from file extensions. Explores the data landscape and proposes a ranked Top 10 list of publishable research questions using multi-agent evaluation. PAPER mode optionally uses SciThinker-30B (OpenMOSS-Team/SciThinker-30B on HuggingFace) for scientific ideation generation./scholar-causalComprehensive causal inference toolkit for social science research. Covers DAG construction, method selection, and thirteen identification strategies (OLS, DiD, RD, IV, FE, matching/reweighting, synthetic control, causal mediation, staggered DiD, DML/causal forests, bunching estimation, shift-share/Bartik instruments, distributional/quantile methods) — each with assumptions, diagnostics, R code, Stata code, and a write-up template. Use when the user needs to select and justify a causal identification strategy, build a causal DAG, or write the identification argument in their Methods section. Works between /scholar-hypothesis and /scholar-design./scholar-citationFull citation management for social science manuscripts. Eight modes: (1) INSERT — add in-text citations to uncited claims; (2) AUDIT — find orphans, missing refs, year/author mismatches, duplicates; (3) CONVERT-STYLE — convert between styles (ASA, APA, numbered, author-date); (4) FULL-REBUILD — inventory claims → search Zotero + CrossRef → insert → assemble → audit; (5) VERIFY — verify each ref against local library (Zotero/Mendeley/BibTeX/EndNote), CrossRef, WebSearch; VERIFIED/UNVERIFIED/CORRECTED; (6) EXPORT — generate BibTeX .bib for LaTeX with cite keys, DOIs, enriched metadata; (7) RETRACTION-CHECK — cross-reference Retraction Watch; flag and suggest replacements; (8) REPORTING-SUMMARY — pre-filled NHB/NCS Reporting Summary (design, statistics, data availability) for Nature Human Behaviour and NCS. ABSOLUTE RULE: never fabricate — every reference verified against ≥1 authoritative database; local library searched first. Flags unsupported claims SOURCE NEEDED. Saves complete draft + audit log.
Other plugins' skills for the same job