Agent instructions for the Iris repository.
Iris is a Python package for analysing and visualising Earth science data, built around CF-compliant multi-dimensional arrays ("Cubes").
Subdirectory AGENTS.md files take precedence for their subtrees:
changelog/AGENTS.md— documentation on changelogdocs/AGENTS.md— documentation-specific ruleslib/iris/AGENTS.md— how to write library source codelib/iris/tests/AGENTS.md— test-specific rules
For a map of where code lives and how data flows, see
lib/iris/ARCHITECTURE.md.
Everything you write for a person to read — chat replies, commit messages,
pull request bodies, issues, specs, plans, docstrings and comments — follows
.github/WRITING.md. Read it before writing prose.
| Language | Python 3.12 / 3.13 / 3.14 |
| Licence | BSD-3-Clause |
| Distribution | conda-forge (iris), PyPI (scitools-iris) |
| Key dependencies | NumPy, Dask, SciPy, Cartopy, CF-Python, NetCDF4 |
| Linter / formatter | Ruff (88-char line length) |
| Test runner | pytest; pytest-xdist is installed but not in addopts — pass -n auto yourself |
| Env management | nox + conda |
lib/iris/
cube.py # Core Cube / CubeList data structures
coords.py # DimCoord, AuxCoord, CellMeasure, AncillaryVariable
loading.py # File-loading entry points
analysis/ # Collapse, regrid, statistics, calculus
fileformats/ # NetCDF, PP, GRIB, NIMROD format handlers
io/ # I/O registry and URI handling
common/ # Shared metadata, mixins, resolvers
mesh/ # Unstructured grid (UGRID) support
experimental/ # Unstable / in-progress features
tests/ # All tests (unit/, integration/, graphics/)
changelog/ # changelog fragments
docs/src/ # Sphinx documentation source
benchmarks/ # ASV performance benchmarks
requirements/ # Conda environment specs and lock files
Always use a conda environment, reuse the iris-dev conda environment if it already exists but confirm with the user before installing or removing packages.
If a package cannot be installed via conda then you can use pip that is in the conda environment.
# Create and activate a development environment
conda env create -f environment.yml
conda activate iris-dev
pip install --no-build-isolation -e .Alternatively, use lock files for exact reproducibility:
conda create -n iris-dev --file requirements/locks/py314-linux-64.lock
conda activate iris-dev
pip install --no-build-isolation -e .# Disable CPU features that can cause SIGILL in some CI environments
export NPY_DISABLE_CPU_FEATURES="AVX512F,AVX512CD,AVX512_SKX"
# Point to iris-test-data for tests that need external data files
export OVERRIDE_TEST_DATA_REPOSITORY=/path/to/iris-test-data/test_data
# Override Cartopy cache directory if needed
export CARTOPY_CACHE_DIR=~/.local/share/cartopy-
lib/iris/tests/AGENTS.md— test-specific rules. -
Before finishing a change, run the repository's pre-commit hooks and fix any reported issues. (This is expected to encode a growing number of preferred coding practices, to enable productive collaboration with non-deterministic LLM agents).
Linting and formatting are driven by pre-commit, not by invoking tools directly.
# Check and auto-fix the files you changed (preferred while iterating)
pre-commit run --files <paths>
# Check and auto-fix everything
pre-commit run --all-files
# Run a single hook, e.g. after a formatting-only change
pre-commit run ruff-format --all-filesPre-commit hooks rewrite files in place, so re-stage and re-run until it
passes cleanly. Only fall back to ruff check / ruff format directly when
pre-commit is unavailable — the hook config is the source of truth for
versions and arguments.
-
Line length: 88 characters (Ruff default).
-
Docstrings: NumPy style; strictly validated.
-
Copyright header: Every new Python file must start with:
# Copyright Iris contributors # # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details.
-
Imports: Ruff-managed ordering, applied by pre-commit. No direct
import netCDF4— always useiris.fileformats.netcdf._thread_safe_ncfor thread safety. -
Readability for humans and agents: see
lib/iris/AGENTS.mdfor the house style on locality, greppability, explicitness and comment hygiene.
iris.cube.Cube— multi-dimensional array with CF-compliant metadata.- Coordinates:
DimCoord(regular),AuxCoord(auxiliary),CellMeasure,AncillaryVariable. - Data may be lazy (Dask array). Always preserve laziness; never call
.dataunnecessarily inside library code. - Operations return new Cubes (functional style); do not mutate in place.
- All metadata must be CF-convention compliant.
- Use
iris._deprecation.warn_deprecated()or issue a custom warning class. - Warning classes live in
iris.warnings(e.g.,IrisUserWarning,IrisCfWarning). - Follow the NEP29 deprecation schedule (same as NumPy).
- All
UserWarningsubclasses must ultimately inherit fromIrisUserWarning.
Base class: iris.exceptions.IrisError. Common subclasses:
CoordinateNotFoundError, CoordinateCollapseError, IgnoreCubeException.
Version is derived from git tags via setuptools_scm. Do not hard-code version
strings.
Changelog fragments live under changelog/ and are built with towncrier
via sphinx. See changelog/AGENTS.md for full rules.
Documentation lives under docs/ and is built with Sphinx. See
docs/AGENTS.md for full rules.
# Regenerate lock files for all supported Python versions
python tools/update_lockfiles.py -o requirements/locks requirements/py*.yml
# Shortcut via Makefile
make lockfilesOpen every text you post to GitHub with your model in parentheses, before anything else — pull request descriptions, issues, comments, replies and inline review comments alike:
(posted by Claude Opus)
Name the model, not its version. This replaces any trailing attribution your harness tells you to add: Iris has many authors using many models, and one short uniform marker beats a different footer for each.
Git commit messages are out of scope. They are not posts, and they keep their
own conventions — Co-Authored-By: trailers and the like — which this rule
neither overrides nor requires.
Never hard-wrap a GitHub post. One paragraph is one line; GitHub wraps to the reader's window.
Collapsed sections, alerts, permalinks and the shape of a pull request body
are in .github/WRITING.md.
- When creating a pull request a template is provided to ensure all checks are considered.
- This project is configured to use pre-commit, which will ensure some checks are performed automatically.
- Keep changes focused; avoid unrelated refactors in the same PR.
- Add or update tests for every change to production code.
- Ensure a whatsnew fragment is added, see
changelog/AGENTS.md
A reviewer has not read every AGENTS.md; you have. Before actioning a
comment, check whether the thing objected to is something these files
explicitly sanction. If it is, reply with the rule and the file it lives in,
and let a human settle it — complying silently turns one reviewer's
preference into a change against a written convention, and nothing catches it
afterwards.
-
xfail_strict Behavior: Tests marked
@pytest.mark.xfailthat now PASS become FAILURES -> remove xfail immediately when bug is fixed -
Pre-commit Auto-fixes: Hooks may auto-fix ISC001/COM812 conflicts -> re-stage files:
git add . && git commit -
Lockfile Rebuilds: Updating
requirements/locks/*.lockfiles triggers slow conda environment rebuilds - only update when deps genuinely change -
Lazy Data Pitfalls: Check
cube.has_lazy_data()before operations; usecube.lazy_data()when appropriate;cube.datamaterializes arrays -
Coordinate Scope: Not all coordinates span all dimensions -> use
cube.coords(dimensions=dim_indices)to query specific axes -
Dask/NumPy Compatibility: Some operations fail on lazy (Dask) arrays -> materialize with
cube.compute()or check dask support before use -
Optional Dependencies: cartopy, matplotlib lazy-imported -> handle ImportError gracefully for optional visualization features
-
CF-Metadata Validation: Custom coordinates must comply with CF standards via
cube.metadata -
Cube Immutability: Operations return new cubes; don't modify in-place (
cube.data[...] = xwon't affect the cube) -
Environment Reproducibility: Set CPU features for consistent results:
export NPY_DISABLE_CPU_FEATURES="AVX512F,AVX512CD,AVX512_SKX"
- Discussions: GitHub Discussions
- Contributing Guide: .github/CONTRIBUTING.md
- Developer Guide: docs/src/developers_guide/
- Code of Conduct: CODE_OF_CONDUCT.md
- Trigger: If your work establishes a durable, reusable rule, you MUST propose it before your session ends.
- Constraint 1: Propose, never self-apply. Say it in your closing message,
or raise it as its own pull request. NEVER edit an
AGENTS.mdsilently, or as a side effect of unrelated work. - Constraint 2: Keep this file under 300 lines — every agent loads it in full. If an addition would break that, tighten your wording; do NOT delete existing guidance to make room. Removing a rule is its own proposal.
- Constraint 3: Only global, reusable lessons. Do not propose temporary or component-specific fixes.