Data Science for Economists
2026-03-01
CLAUDE.md / AGENTS.mdThe AI-Assisted Coding Landscape
LLMs are code editors, pair programmers, and research assistants
Conversational
IDE-integrated
CLI agents
ggplot2 from natural language descriptionsdata.table syntax (:=, .SD, by)CLAUDE.md context files# Ask Claude Code to fix an error
claude "Fix the merge error in 03-analysis.R — the county
identifier has missing values causing observation drops"
# Scaffold a new analysis
claude "Create a gravity model estimation script following
our project conventions in CLAUDE.md"
# Review code
claude "Review the diff on this branch for econometric issues"Excels at
ggplot2 from descriptionsStruggles with
1. AI is an experience good
2. AI triggers repugnance
3. Frontier models cost money
Two levers: experience and subsidy
The adoption recipe (Cunningham 2026):
Once they adopt for one task, everything else follows.
In R, the standard framework is testthat:
# tests/test-gravity.R
library(testthat)
test_that("merge preserves all observations", {
dt_left <- data.table(iso3 = c("DEU", "FRA", "USA"), gdp = c(3.8, 2.7, 21.4))
dt_right <- data.table(iso3 = c("DEU", "FRA"), pop = c(83, 67))
dt_merged <- merge(dt_left, dt_right, by = "iso3", all.x = TRUE)
expect_equal(nrow(dt_merged), nrow(dt_left))
})✔ | F W S OK | Context
✔ | 2 | test-gravity
✔ | 3 | test-cleaning
══ Results ═══════════════════════════
[ PASS: 5 | FAIL: 0 | WARN: 0 | SKIP: 0 ]
CLAUDE.md build commands so AI agents run them tooProject Context Files
Result: generic suggestions that don’t match your project
This idea is documented and championed by Chris Blattman (UChicago):
| File | Audience | Purpose |
|---|---|---|
README.md |
Humans | Project overview, reproduction instructions |
CLAUDE.md |
LLM assistants | Project-specific context for code generation |
AGENTS.md |
LLM assistants | Specialized agent roles with different rules |
STYLEGUIDE.md |
Both | Generic coding conventions (write once, reuse) |
skills/ |
LLM assistants | Reusable slash commands for recurring tasks |
What goes in it:
Start small — 10–20 lines of project description. Add detail as you discover what the LLM gets wrong.
# Project: Gravity Model of Trade
Bilateral trade flows estimated with PPML. Data from CEPII (BACI).
## Structure
- `code/`: R scripts numbered 01-05
- `input/`: raw BACI data (do NOT modify)
- `output/figures/`: all plots saved here
- `temp/`: intermediate files, gitignored
## Build
- Run all: `Rscript code/00-master.R`
- Render paper: `quarto render paper/paper.qmd`
## Conventions
- data.table for all data manipulation
- Native pipe |> (not %>%)
- Figures: ggplot2 + theme_minimal() + ggsave()
## Data notes
- BACI uses HS6 product codes, reporter/partner ISO3
- Distance and contiguity from CEPII GeoDist
- Zeros matter: use PPML, not OLS on log tradeDefine specialized roles with different rules and context:
## Data Engineer
- Works only in `code/01-*.R` to `code/03-*.R`
- Focus: data cleaning, merges, consistency checks
- Never modifies `input/` files
## Analyst
- Works in `code/04-*.R` and `code/05-*.R`
- Focus: estimation, robustness, visualization
- Must document every regression specification
## Reviewer
- Read-only access to all files
- Checks: code/slide consistency, missing topics
- Flags reproducibility issuesWrite once, copy to every project:
## R Style Guide
### Packages
- Use pacman: `p_load(data.table, ggplot2, fixest)`
- Pin versions in renv.lock for reproducibility
### Data
- data.table for all manipulation
- Native pipe |> throughout
- Never use attach() or <<-
### Output
- Figures: 1600x900 PNG, theme_minimal()
- Tables: modelsummary or kableExtra
- File names: YYMMDD_description.extWithout context files:
tidyverse when you use data.tableWith context files:
Skills & Slash Commands
.claude/skills/ in your project/skill-name in a Claude Code sessionExamples:
/done — wrap up a task, summarize changes, update docs/review-plan — stress-test a plan with a fresh agent/commit — stage, write message, commit following conventionsBlattman’s foundational workflow for AI-assisted research:
Each step can be a skill — reusable, consistent, auditable
A skill is just a markdown file:
Save as .claude/skills/done.md → use with /done
Chris Blattman’s open-source collection:
skills/ directory with research-oriented commandsSelected skills:
/review-plan — adversarial review of implementation plans/done — session wrap-up with change summary/lessons — extract and record lessons learned/deep-research — structured literature/data investigationAutonomous Code Review
Key detail: Copilot always leaves “Comment” reviews, never “Approve”
Workflow:
| Tool | What it does | When to use |
|---|---|---|
| Copilot Review | Inline PR comments | Every PR — fast, free feedback |
| Copilot Agent | Background implementation | Issues with clear specs |
| Claude Code | Interactive review | Complex refactoring, research code |
Research Life Hacks
Use CLI agents as your day-to-day research coding companion:
CLAUDE.md templates.md filesWhy this matters for research:
Not just code — version control everything:
.tex, .qmd)Version control = safety net + collaboration tool
Overleaf exposes a Git remote for every project:
Wrap Up
CLAUDE.md, AGENTS.md, STYLEGUIDE.md) make LLMs project-awareStart today: create a CLAUDE.md for your current project. 10 lines is enough.
Questions?