agentleFS
rahulvranerahulvrane/ClaudeCodeforScientists/CLAUDE.md

ClaudeCodeforScientists

CLAUDE.md1 starsChanged 10 months agoMITView on GitHub

Compatibility: This file works as CLAUDE.md (Claude Code), AGENTS.md (Cursor, Zed, OpenCode), or COPILOT-INSTRUCTIONS.md (GitHub Copilot). Copy and rename as needed. Project name: <your-project-name> Organism / system: <e.g. Gossypium hirsutum, Homo sapiens, mixed-species metagenome> Analysis type: <e.g. WGS variant calling, RNA-seq differential expression, metagenomics> Workflow engine: <snakemake | nextflow | bash> Package manager: <conda/mamba | uv | docker | singularity> One-sentence description: <!-- What question is this analysis answering? -->

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

30 rules. About 0 are common, 12 are distinctive, and 18 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 18

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Config is centralised: No hardcoded paths, sample names, or thresholds in scripts.

    line 108
  2. Very specific:

    The pipeline is the source of truth: Every result must be reproducible via workflow/Snakefile (or main.nf).

    line 109
  3. Very specific:

    No hardcoded paths: Use config["param"] in Snakemake or params.param in Nextflow.

    line 154
  4. Very specific:

    IMPORTANT: Read @agent_docs/data_conventions.md before creating, moving, or transforming data files.

    line 172
  5. Distinctive:

    Never commit files > 1 MB to git.

    line 189
  6. Very specific:

    Use .gitignore to exclude data/raw/, data/processed/, resources/, logs/.

    line 190
  7. Very specific:

    IMPORTANT: Read @agent_docs/workflow_guide.md before writing or modifying workflow rules.

    line 197
  8. Very specific:

    Every rule has a docstring, log:, conda: (or container:), threads:, and resources:.

    line 227
  9. Very specific:

    Use expand() only in rule all.

    line 230
  10. Very specific:

    IMPORTANT: Read @agent_docs/visualisation_guide.md for plotting standards and colour palettes.

    line 262
  11. Distinctive:

    Generate many cheap diagnostic plots: Use them to sanity-check data at every stage: coverage distributions, PCA projections, mapping rate …

    line 265
  12. Very specific:

    Scripts over notebooks for reproducibility: Prefer scripts/plot_coverage.py that dumps a PNG to results/figures/.

    line 266
  13. Distinctive:

    Prefer text-based notebooks: marimo (.py), jupytext (.py), quarto (.qmd), Rmarkdown (.Rmd).

    line 268
  14. Distinctive:

    If using Jupyter, always restart kernel and run all cells before committing.

    line 269
  15. Very specific:

    Never leave large base64-encoded images in .ipynb files in version control.

    line 270
  16. Distinctive:

    Colour: Use colourblind-safe palettes (viridis, cividis, or the Okabe-Ito palette).

    line 272
  17. Very specific:

    IMPORTANT: Read @agent_docs/testing_strategy.md for full testing patterns.

    line 279
  18. Very specific:

    Keep small representative data in tests/test_data/ (< 5 MB total).

    line 294
  19. Very specific:

    Commit early, commit often.

    line 320
  20. Distinctive:

    Delete dead code aggressively — git has your back.

    line 321
  21. Distinctive:

    Never commit secrets, credentials, or absolute paths.

    line 323
  22. Distinctive:

    YOU MUST: follow these rules when working in this repository:

    line 342
  23. Distinctive:

    Search before creating: Before writing a new function or script, grep the codebase for existing implementations.

    line 344
  24. Very specific:

    Never modify data/raw/: Treat it as immutable. All transforms write to data/processed/.

    line 345
  25. Very specific:

    Never hardcode paths or sample names: Read from config/config.yaml or accept as function parameters.

    line 346
  26. Very specific:

    Write tests alongside new src/ code: If you add a function, add a test.

    line 349
  27. Very specific:

    Keep notebooks clean: No data processing logic in notebooks.

    line 350
  28. Distinctive:

    Do not install packages globally: Use the project environment.

    line 352
  29. Distinctive:

    When uncertain about biological interpretation, say so: Do not hallucinate domain knowledge.

    line 353
  30. Distinctive:

    Read these files when working on the relevant area.

    line 359

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md — Bioinformatics Project Agent Instructions

Compatibility: This file works as CLAUDE.md (Claude Code), AGENTS.md (Cursor, Zed, OpenCode), or COPILOT-INSTRUCTIONS.md (GitHub Copilot). Copy and rename as needed.

Project overview

<!-- EDIT THIS SECTION for every new project -->

Project name: <your-project-name> Organism / system: <e.g. Gossypium hirsutum, Homo sapiens, mixed-species metagenome> Analysis type: <e.g. WGS variant calling, RNA-seq differential expression, metagenomics> Workflow engine: <snakemake | nextflow | bash> Package manager: <conda/mamba | uv | docker | singularity>

One-sentence description:

<!-- What question is this analysis answering? -->

Repository structure

project-root/
│
├── CLAUDE.md                  # ← You are here. Agent instructions.
├── README.md                  # Human-readable project overview
├── LICENSE
├── .gitignore
│
├── config/                    # Configuration — the only place for tuneable parameters
│   ├── config.yaml            # Pipeline parameters (samples, paths, thresholds)
│   ├── samples.tsv            # Sample sheet / manifest
│   └── cluster.yaml           # HPC resource profiles (optional)
│
├── workflow/                  # Computational pipeline definition
│   ├── Snakefile              # — OR main.nf for Nextflow
│   ├── rules/                 # Modular rule files (.smk)
│   │   ├── qc.smk
│   │   ├── alignment.smk
│   │   ├── calling.smk
│   │   └── annotation.smk
│   ├── envs/                  # Per-tool conda environment YAMLs
│   │   ├── fastqc.yaml
│   │   ├── bwa.yaml
│   │   └── samtools.yaml
│   └── scripts/               # Helper scripts invoked by rules
│       ├── parse_vcf.py
│       └── merge_counts.R
│
├── src/                       # Reusable library code (installable package)
│   ├── __init__.py
│   ├── io.py                  # Data loading / parsing utilities
│   ├── transforms.py          # Data transformation functions
│   └── stats.py               # Statistical methods
│
├── notebooks/                 # Exploratory analysis & visualisation ONLY
│   ├── 01_qc_overview.py      # Prefer text-based formats: marimo, jupytext, quarto
│   ├── 02_pca_clustering.py
│   └── 03_differential.py
│
├── scripts/                   # Standalone analysis / plotting scripts
│   ├── plot_coverage.py
│   ├── generate_report.py
│   └── run_pipeline.sh        # One-command full pipeline execution
│
├── data/                      # DATA — never commit large files to git
│   ├── raw/                   # Immutable original data (symlink or .gitkeep)
│   ├── processed/             # Pipeline outputs (intermediate & final)
│   ├── generated/             # AI-generated data (synthetic, augmented, imputed)
│   ├── external/              # Third-party resources (databases, references)
│   └── metadata/              # Sample metadata, clinical data, phenotypes
│
├── results/                   # Final outputs for publication / sharing
│   ├── figures/               # Publication-ready figures (PDF/SVG/PNG)
│   ├── tables/                # Summary tables (TSV/CSV)
│   └── reports/               # Rendered reports (HTML/PDF)
│
├── resources/                 # Reference genomes, annotations, indices
│   └── .gitkeep
│
├── tests/                     # Automated tests
│   ├── test_io.py
│   ├── test_transforms.py
│   └── test_data/             # Small fixture datasets for testing
│       └── tiny_reads.fq.gz
│
├── agent_docs/                # Extended agent instructions (progressive disclosure)
│   ├── data_conventions.md
│   ├── workflow_guide.md
│   ├── coding_standards.md
│   ├── testing_strategy.md
│   ├── visualisation_guide.md
│   └── hpc_deployment.md
│
├── logs/                      # Pipeline execution logs
│   └── .gitkeep
│
├── envs/                      # Project-level environment definitions
│   └── environment.yaml       # — OR pyproject.toml with [project.dependencies]
│
└── pyproject.toml             # Project metadata, build config, tool settings

Key principles behind this layout

  1. Separate data processing from visualisation. Pipeline logic lives in workflow/ and src/. Plotting lives in notebooks/ and scripts/. Never mix them.
  2. Data has a lifecycle. raw/ → processed/ → results/. Raw is immutable. Processed can be regenerated. Generated is flagged as AI-produced.
  3. Config is centralised. No hardcoded paths, sample names, or thresholds in scripts. Everything flows from config/.
  4. The pipeline is the source of truth. Every result must be reproducible via workflow/Snakefile (or main.nf). If it can't be re-run from raw, it doesn't count.

Commands

# Environment setup
mamba env create -f envs/environment.yaml
conda activate <project-name>

# Run pipeline (Snakemake)
snakemake --cores all --use-conda
snakemake -n                        # Dry run
snakemake --dag | dot -Tpdf > dag.pdf   # Visualise DAG
snakemake --report results/reports/pipeline_report.html

# Run pipeline (Nextflow)
nextflow run workflow/main.nf -profile conda,local -params-file config/config.yaml

# Linting & formatting
ruff check src/ scripts/ workflow/scripts/
ruff format src/ scripts/ workflow/scripts/

# Tests
pytest tests/ -v
pytest tests/test_io.py::test_parse_vcf -v  # Single test

# Notebooks (marimo)
marimo edit notebooks/01_qc_overview.py

# Notebooks (jupytext)
jupytext --to notebook notebooks/01_qc_overview.py && jupyter notebook

Coding standards

Language: Python 3.10+ (primary), R 4.x (statistical models, Bioconductor), Bash (glue).

Style:

  • Python: follow ruff defaults (based on PEP 8). Max line length 100.
  • R: follow tidyverse style guide.
  • Snakemake: one rule per logical step. Name rules as verbs (align_reads, call_variants).
  • No hardcoded paths. Use config["param"] in Snakemake or params.param in Nextflow.
  • No magic numbers. Thresholds, quality cutoffs, and window sizes go in config/config.yaml.

Naming:

  • Files: snake_case.py, snake_case.smk, kebab-case.yaml.
  • Functions/variables: snake_case.
  • Classes: PascalCase.
  • Constants: UPPER_SNAKE_CASE.
  • Notebooks: numbered prefix 01_, 02_ for execution order.

Docstrings: Required for all public functions. Use Google style.

Type hints: Required for all function signatures in src/.


Data conventions

IMPORTANT: Read @agent_docs/data_conventions.md before creating, moving, or transforming data files.

  • data/raw/ — Never modify. Treat as read-only. Symlink from shared storage if large.
  • data/processed/ — Pipeline outputs. Must be reproducible from raw via the workflow. Safe to delete and regenerate.
  • data/generated/ — AI-generated or synthetic data. Always tag provenance (model, date, parameters) in a sidecar .meta.yaml.
  • data/external/ — Downloaded databases, reference panels. Record URL + version + download date.
  • data/metadata/ — Sample sheets, clinical data, phenotype files.
  • results/ — Final publication-ready outputs only. Figures as vector (SVG/PDF) + raster (PNG 300dpi).

File formats:

  • Sequences: FASTQ (gzipped), FASTA
  • Alignments: BAM/CRAM (sorted, indexed)
  • Variants: VCF/BCF (bgzipped, tabix-indexed)
  • Counts/matrices: TSV or Parquet (prefer Parquet for large matrices)
  • Tabular results: TSV with header row. No Excel files in the pipeline.

Git & large files:

  • Never commit files > 1 MB to git.
  • Use .gitignore to exclude data/raw/, data/processed/, resources/, logs/.
  • Track large files with DVC or Git LFS if versioning is needed.

Workflow conventions

IMPORTANT: Read @agent_docs/workflow_guide.md before writing or modifying workflow rules.

Snakemake rules

rule align_reads:
    """Align reads to reference genome using BWA-MEM2."""
    input:
        reads=expand("data/raw/{sample}_{pair}.fq.gz", pair=[1, 2], allow_missing=True),
        ref=config["reference"]["genome"],
    output:
        bam="data/processed/alignments/{sample}.sorted.bam",
        bai="data/processed/alignments/{sample}.sorted.bam.bai",
    log:
        "logs/align/{sample}.log",
    conda:
        "../envs/bwa.yaml"
    threads: 8
    resources:
        mem_mb=32000,
        runtime=240,
    shell:
        """
        (bwa-mem2 mem -t {threads} {input.ref} {input.reads} \
            | samtools sort -@ {threads} -o {output.bam}) 2> {log}
        samtools index {output.bam} 2>> {log}
        """

Rule conventions:

  • Every rule has a docstring, log:, conda: (or container:), threads:, and resources:.
  • Inputs and outputs use full relative paths from project root.
  • Wrap shell commands in (command) 2> {log} for consistent error capture.
  • Use expand() only in rule all. Individual rules use wildcards.

Nextflow processes

process ALIGN_READS {
    tag "${meta.id}"
    conda "envs/bwa.yaml"
    publishDir "data/processed/alignments", mode: 'copy'
    cpus 8
    memory '32 GB'

    input:
    tuple val(meta), path(reads)
    path(reference)

    output:
    tuple val(meta), path("*.sorted.bam"), path("*.sorted.bam.bai"), emit: bam

    script:
    """
    bwa-mem2 mem -t ${task.cpus} ${reference} ${reads} \
        | samtools sort -@ ${task.cpus} -o ${meta.id}.sorted.bam
    samtools index ${meta.id}.sorted.bam
    """
}

Visualisation guidelines

IMPORTANT: Read @agent_docs/visualisation_guide.md for plotting standards and colour palettes.

  • Separate processing from plotting. Plotting scripts read from data/processed/ and write to results/figures/. They do NOT run analysis.
  • Generate many cheap diagnostic plots. Use them to sanity-check data at every stage: coverage distributions, PCA projections, mapping rate bar charts, insert size histograms. Individually low-value, collectively they catch errors early.
  • Scripts over notebooks for reproducibility. Prefer scripts/plot_coverage.py that dumps a PNG to results/figures/. Reserve notebooks for genuinely interactive exploration.
  • Notebook handling:
    • Prefer text-based notebooks: marimo (.py), jupytext (.py), quarto (.qmd), Rmarkdown (.Rmd).
    • If using Jupyter, always restart kernel and run all cells before committing. Better: convert via jupytext.
    • Never leave large base64-encoded images in .ipynb files in version control.
  • Plotting libraries: matplotlib/seaborn (static), plotly (interactive), altair (declarative). Use a consistent theme across the project.
  • Colour: Use colourblind-safe palettes (viridis, cividis, or the Okabe-Ito palette). Never use jet/rainbow.
  • Figures for publication: SVG or PDF for vector, PNG at 300 DPI for raster. Set figsize explicitly.

Testing & validation strategy

IMPORTANT: Read @agent_docs/testing_strategy.md for full testing patterns.

Tests are not optional. When the AI writes the code, tests are how you verify it is doing what you think.

What to test:

  • src/ library functions: unit tests with known inputs → expected outputs.
  • File parsers: roundtrip tests (read → write → read → compare).
  • Statistical functions: test against published results or hand-calculated examples.
  • Workflow rules: dry-run (snakemake -n) and integration test with tiny fixtures in tests/test_data/.

What NOT to test with unit tests:

  • Visualisation aesthetics (review manually).
  • Third-party tool correctness (trust samtools; test your invocation of it).

Test fixtures:

  • Keep small representative data in tests/test_data/ (< 5 MB total).
  • Subsample real data: seqtk sample -s42 reads.fq.gz 1000 | gzip > tests/test_data/tiny_reads.fq.gz.

Running tests:

pytest tests/ -v --tb=short

Environment & reproducibility

  • Pin all versions. envs/environment.yaml should specify tool=x.y.z, never tool>=x.
  • One conda env per tool in workflow (via conda: directive in Snakemake rules), OR one master environment for the whole project. Document which approach you chose in README.md.
  • Containers for production. For shared pipelines or publication, provide a Dockerfile or Singularity definition.
  • Record the execution environment:
    conda list --export > envs/frozen-environment.txt
    snakemake --version >> envs/frozen-environment.txt

Git workflow

  • Work on feature branches: git checkout -b feature/add-variant-filtering.
  • Commit early, commit often. Messages follow: type: short description (e.g. feat: add GATK HaplotypeCaller rule, fix: correct BAM sort order, docs: update README).
  • Delete dead code aggressively — git has your back.
  • Tag releases that correspond to manuscript submissions: git tag -a v1.0-submission -m "Initial submission to Nature Genetics".
  • Never commit secrets, credentials, or absolute paths.

Common pitfalls — things to watch for

SymptomLikely causeFix
Pipeline works on one sample but fails on othersHardcoded sample name somewhereGrep for the sample name; parameterise via config
Results differ between runsNon-deterministic tool or unseeded randomSet --seed / random_state everywhere; pin tool versions
Disk full during pipelineBAM/VCF intermediates accumulatingUse temp() in Snakemake outputs for intermediates
AI-generated code silently reads wrong columnColumn name drift between data versionsAdd assertions at data load: assert "gene_id" in df.columns
Notebook outputs differ from script outputsStale notebook kernel stateRestart kernel + run all, or switch to marimo/jupytext
Pipeline DAG is a messRules too granular or too monolithicOne rule = one logical bioinformatics step

Agent behaviour rules

YOU MUST follow these rules when working in this repository:

  1. Search before creating. Before writing a new function or script, grep the codebase for existing implementations. Extend, don't duplicate.
  2. Never modify data/raw/. Treat it as immutable. All transforms write to data/processed/.
  3. Never hardcode paths or sample names. Read from config/config.yaml or accept as function parameters.
  4. Always add a log directive to new Snakemake rules or Nextflow processes.
  5. Always add a conda/container directive for reproducibility.
  6. Write tests alongside new src/ code. If you add a function, add a test.
  7. Keep notebooks clean. No data processing logic in notebooks. Import from src/ instead.
  8. Commit messages follow conventional format. feat:, fix:, docs:, refactor:, test:, chore:.
  9. Do not install packages globally. Use the project environment.
  10. When uncertain about biological interpretation, say so. Do not hallucinate domain knowledge. Flag it for human review.

Extended documentation (progressive disclosure)

Read these files when working on the relevant area. Do NOT read all of them at once — load on demand.

FileWhen to read
@agent_docs/data_conventions.mdCreating, moving, or transforming data files
@agent_docs/workflow_guide.mdWriting or modifying Snakemake/Nextflow rules
@agent_docs/coding_standards.mdWriting Python/R library code in src/
@agent_docs/testing_strategy.mdWriting or running tests
@agent_docs/visualisation_guide.mdCreating plots or figures
@agent_docs/hpc_deployment.mdRunning on HPC clusters (SLURM/PBS)
@README.mdProject overview, installation, quickstart
@config/config.yamlUnderstanding pipeline parameters

Quick reference — what goes where?

I need to...Put it in...
Add a new pipeline stepworkflow/rules/ (new .smk file or add to existing)
Write a reusable functionsrc/ (and add a test in tests/)
Create a one-off analysis scriptscripts/
Explore data interactivelynotebooks/ (text-based format)
Store a new tool's conda envworkflow/envs/
Add a helper script for a ruleworkflow/scripts/
Save a publication figureresults/figures/
Download a reference genomeresources/
Record a parameter or thresholdconfig/config.yaml
Document something for the AI agentagent_docs/

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.