Skip to content
Agentmart
Submit a tool

CLAUDE.md · MIC-DKFZ/nnUNet

CLAUDE.md from MIC-DKFZ/nnUNet: 117 lines covering Before you merge a branch into master, The one rule that matters most, Environment variables, Layout and…

Template by MIC-DKFZ

IndexedApache-2.0★ 8,983
Write a review

Chalk Labs

Need help deploying CLAUDE.md · MIC-DKFZ/nnUNet?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code. Read the repository before you give any tool access to your data.

curl -fsSL https://raw.githubusercontent.com/MIC-DKFZ/nnUNet/master/CLAUDE.md -o CLAUDE.md

Read it and adapt it to your project before use.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

The CLAUDE.md file that MIC-DKFZ/nnUNet (8,983 stars) keeps for coding agents. It has 117 lines in 7 sections: Before you merge a branch into master; The one rule that matters most; Environment variables; Layout; Distributed training: ranks; Tests; Conventions. Use it as a model for your own project's instructions.

Use cases: code-generation, testing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

What's in it

A CLAUDE.md file: project memory Claude Code loads at the start of every session.

For
Claude Code
Length
117 lines
File
CLAUDE.md

Sections

  1. Before you merge a branch into master
  2. The one rule that matters most
  3. Environment variables
  4. Layout
  5. Distributed training: ranks
  6. Tests
  7. Conventions

First lines (shown under the repo's Apache-2.0 license)

# Working in the nnU-Net repository

Notes for coding agents and new contributors. This file is about *how to change this codebase safely*;
it does not duplicate the user documentation.

- **Users start here:** [`readme.md`](readme.md) and [`documentation/`](documentation/).
- **Contributors start here:** [`CONTRIBUTING.md`](CONTRIBUTING.md). It says what we do and do not accept.
- **Deliberately deferred simplifications:** [`DEFERRED_CLEANUPS.md`](DEFERRED_CLEANUPS.md).

## Before you merge a branch into master

This file ships to everyone who clones nnU-Net, so it has to read as guidance about *the codebase*, not as a
record of whatever branch it came from. Feature branches accumulate the opposite: cluster and host names, job
ids, absolute paths on someone's machine, links to internal reports, and status notes about work in progress.
That is fine while the branch is alive — it is how the notes travel between machines — but **none of it may
reach master**.

So when you merge, re-read `CLAUDE.md` (and `AGENTS.md`, if present) and strip anything internal or
branch-specific before the merge lands: paths, infrastructure names, internal links, and anything that is
about one experiment rather than about working in this repository. If a note is only true for your branch, it
belongs on your branch. Keep the branch history out of it too — squash, or drop the commits that carried the
internal notes, because cleaning the file does not clean the commits that introduced it.

## The one rule that matters most

**nnU-Net is used by a lot of people, and much of that use happens in custom trainers and custom code that
lives outside this repository.** They subclass `nnUNetTrainer`, read its attributes, import our utilities and
parse our output files. A rename or a signature change that looks harmless here silently breaks them, and
they will not find out until a training crashes hours in.

So: prefer additive changes. If a change does break third-party code, it needs an entry in
[`documentation/changelog.md`](documentation/changelog.md) under "Changes that affect custom trainers",
spelling out the old and the new way. If the right cleanup cannot be done without breaking people, do not do
it quietly and do not leave it in a commit message — add it to `DEFERRED_CLEANUPS.md` under the release that
can execute it, saying what to do, why it is deferred and what breaks.

## Environment variables

nnU-Net locates everything through three variables; nothing works without them. See
[`documentation/set_environment_variables.md`](documentation/set_environment_variables.md) and
[`documentation/setting_up_paths.md`](documentation/setting_up_paths.md).

| variable | holds |
|---|---|
| `nnUNet_raw` | datasets in nnU-Net raw format |
| `nnUNet_preprocessed` | fingerprints, plans, preprocessed data |
| `nnUNet_results` | trained models, logs, checkpoints, validation output |

`nnUNet_compile`, `nnUNet_n_proc_DA` and friends are optional and documented in the same place.

## Layout

| path | what |
|---|---|
| `nnunetv2/experiment_planning/` | fingerprint extraction, planners, preprocessing |
| `nnunetv2/training/nnUNetTrainer/` | `nnUNetTrainer` and its variants. Most extension happens here. |
| `nnunetv2/training/` | loss functions, dataloading, data augmentation, LR schedules |
| `nnunetv2/inference/` | sliding-window prediction, export |
| `nnunetv2/evaluation/` | metrics, best-configuration selection |
| `nnunetv2/run/` | `nnUNetv2_train` and the DDP launch paths |
| `nnunetv2/utilities/` | shared helpers, including `ddp.py` |
| `nnunetv2/tests/` | unit tests and `integration_tests/` |

Every user-facing command is a console entry point declared in `pyproject.toml` — that table is the quickest
map from a command name to the code behind it.

## Distributed training: ranks

DDP runs on one node (`-num_gpus X`, where nnU-Net spawns the workers itself) or across several
(`torchrun`, which spawns them). Both funnel into the same code path, so code below the launcher never needs
to know which was used. User-facing details: [`documentation/multi_gpu_training.md`](documentation/multi_gpu_training.md).

`get_ddp_topology()` in `nnunetv2/utilities/ddp.py` provides four values, and the distinction is load-bearing:

| attribute | meaning |
|---|---|
| `self.local_rank` | index within the node → **the CUDA device index** |
| `self.global_rank` | index within the whole job → **decides who writes files** |
| `self.world_size` | processes in the job |
| `self.local_world_size` | processes on this node |

**Guard every write to `nnUNet_results` with `global_rank == 0`.** On one node the two ranks coincide, so a
mistake here is invisible until someone trains across nodes: there is one `local_rank == 0` *per node*, and on
a shared filesystem they all write the same log file, checkpoints and progress plot. Use `local_rank` only
where you mean the GPU.

Other things that are easy to get wrong:

- Collectives must be reached by **all** ranks. A `return` or an exception inside a rank-0 branch that skips a
  barrier hangs the job until the NCCL watchdog fires.
- Order barriers so that ranks wait *before* reading what other ranks wrote, not after.
- `SIGUSR1` sets a flag that is reduced across the job at the epoch boundary, so one signalled rank stops all
  of them. Do not log from the signal handler.

## Tests

```bash
pytest nnunetv2/tests                     # unit tests, fast
nnunetv2/tests/integration_tests/run_integration_test.sh            # full pipeline, slow
nnunetv2/tests/integration_tests/run_integration_test_trainingOnly_DDP.sh   # DDP path
```

Integration tests need the environment variables above and real data; see
`nnunetv2/tests/integration_tests/readme.md`. Anything touching planning, preprocessing or training should be
checked against them, because unit tests do not cover the pipeline end to end.

## Conventions

- Match the surrounding style rather than imposing a new one; the codebase predates most current formatters
  and a reformat-in-passing buries the actual change in a large diff.
- Training must stay reproducible: seeds, plans and preprocessed data determine the result. A change that
  moves segmentation quality needs numbers against the previous behaviour, not an argument that it should be
  equivalent.
- Performance claims need a measurement. `documentation/benchmarking.md` and
  `nnUNetTrainerBenchmark_5epochs` exist for this; compare the fastest epoch, not the mean, and never compare
  across different GPU models.

Signals

Stars
8,983
Forks
2,506
Open issues
73
Last commit (this folder)
Sep 22, 2026 (1 month ago)
Last release
Apr 21, 2024 (2 years ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get CLAUDE.md · MIC-DKFZ/nnUNet running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying CLAUDE.md · MIC-DKFZ/nnUNet?

CallGet help
Cite this page

CLAUDE.md · MIC-DKFZ/nnUNet. Agent Mart. https://agentmart.dev/templates/mic-dkfz-nnunet-claude-md (last updated 2026-10-24)