| name | data-analysis |
| description | End-to-end data analysis dispatching the Coder agent for implementation and Debugger agent for code review. Supports R, Stata, Python, and Julia. Produces scripts, tables, figures, and results summary. |
| disable-model-invocation | true |
| argument-hint | [dataset path or description of analysis goal] |
| allowed-tools | ["Read","Grep","Glob","Write","Edit","Bash","Task"] |
Data Analysis Workflow
Run an end-to-end data analysis by dispatching the Coder (implementer) and Debugger (code critic).
Input: $ARGUMENTS — a dataset path (e.g., data/build/01_clean/panel.csv) or a description of the analysis goal.
Workflow
Step 1: Context Gathering
- Read
.claude/rules/domain-profile.md for field conventions
- Read any strategy memo in
quality_reports/ (if analysis implements a pre-specified design)
- Check
CLAUDE.md for language preference (R/Stata/Python/Julia)
- Scan existing scripts in
code/build/ and code/analysis/ for project patterns
Step 2: Launch Coder Agent
Delegate to the coder agent via Task tool:
Prompt: Implement analysis for "[goal]" using data at "[path]".
Follow 4 stages:
Stage 0: Data cleaning (if raw data provided)
Stage 1: Main specification (from strategy memo or user description)
Stage 2: Robustness checks
Stage 3: Publication-ready output (tables to output/NN_issue/tables/, figures to output/NN_issue/figures/)
Produce results_summary.md with all estimates, SEs, and key statistics.
Save scripts to code/build/NN_issue/ or code/analysis/NN_issue/ (numbered by GitHub issue).
The Coder follows these principles:
- Script structure: Header, setup, data loading, analysis, output, export
- Packages:
fixest for panel data, modelsummary for tables, ggplot2 for figures
- Standard errors: Cluster at appropriate level (match treatment assignment)
- Output:
.tex tables for LaTeX, .pdf/.png figures, .rds for intermediate objects
- No hardcoded paths. All paths relative to repository root.
Step 3: Launch Debugger Agent (Code Critic)
After Coder returns, delegate to the debugger agent:
Prompt: Review the script(s) at code/analysis/NN_issue/[script_name].R.
Run all 12 check categories:
Strategic (1-3): code-strategy alignment, sanity checks, robustness sufficiency
Code Quality (4-12): structure, console hygiene, reproducibility, functions,
figure quality, RDS pattern, comments, error handling, polish
If strategy memo exists, cross-reference code against stated design.
Save report to quality_reports/[script]_code_review.md
Step 4: Fix Issues
If Debugger finds Critical or Major issues:
- Re-dispatch Coder with specific fixes (max 3 rounds per
three-strikes.md)
- Re-run Debugger to verify fixes
Step 5: Present Results
Show the user:
- Results summary — key estimates with SEs and interpretation
- Scripts created — paths and descriptions
- Output files — tables in
output/NN_issue/tables/, figures in output/NN_issue/figures/
- Code review score — from Debugger
- Any TODO items — missing data, additional specifications needed
Script Structure Template
library(tidyverse)
library(fixest)
library(modelsummary)
set.seed(42)
dir.create("Tables", recursive = TRUE, showWarnings = FALSE)
dir.create("Figures", recursive = TRUE, showWarnings = FALSE)
Principles
- Reproduce, don't guess. If the user specifies a regression, run exactly that.
- Show your work. Print summary statistics before jumping to regressions.
- Strategy alignment. If a strategy memo exists, the code MUST implement it faithfully.
- Worker-critic pairing. Coder creates, Debugger critiques. Never skip the review.
- saveRDS everything. Every computed object gets saved for downstream use.
- Publication-ready output. Tables and figures should be directly includable in the paper.