Skip to main content
CLAUDE.md generator

CLAUDE.md for R Data Analysis

Tidyverse analysis project with reproducible figures and a clear data pipeline.

Rtidyverseggplot2renv

How to use this

Save it as CLAUDE.md in your repository root and replace the placeholders in angle brackets. Claude reads it before every task, so keep it short — the Playbooks table at the bottom is how you add detail without paying for it on every unrelated request.

The file

# <project name>

<What question this analysis answers, and for what output — paper, report, dashboard.>

## Commands

- `Rscript scripts/00_run_all.R` — full pipeline, raw data to figures
- `renv::restore()` — restore the package library
- `Rscript -e 'testthat::test_dir("tests")'` — tests

## Project Structure

- `data/raw/` — never edited, never written to
- `data/processed/` — generated; safe to delete and rebuild
- `R/` — functions only, no top-level side effects
- `scripts/` — numbered pipeline steps
- `figures/` — generated output

## Conventions

IMPORTANT: `data/raw/` is read-only. Every cleaning step is code, never a manual edit.
YOU MUST: set a seed for anything stochastic, and state it in the script.
NEVER: use `setwd()` or absolute paths. Use `here::here()`.

- Prefer tidyverse idiom; pipe with `|>`.
- Every figure is produced by a script, never saved by hand from the plot pane.

## Verification

Re-run the full pipeline from a clean `data/processed/`. It must reproduce every figure.

## Working with Claude Code

- Explore the relevant files before proposing a change.
- For anything non-trivial, plan first (Shift+Tab into plan mode) and let me review.
- Run the verification command below before telling me something works.
- Keep commits small and conventional (`feat:`, `fix:`, `docs:`, `chore:`).

## Playbooks

- Producing a publication figure → read `.claude/playbooks/figure-standards.md` first
- Adding or refreshing a raw dataset → read `.claude/playbooks/data-import.md` first

The playbooks it expects

The routing table points at files that don't exist yet. Create them as you need them — each one holds a procedure too long to sit in CLAUDE.md and too rare to justify the context cost.

  • .claude/playbooks/figure-standards.mdProducing a publication figure
  • .claude/playbooks/data-import.mdAdding or refreshing a raw dataset
Why CLAUDE.md should stay thin →

Other starting points

Need something else? Build one from scratch with the generator.