# pypa/hatch — codebase unpack

> Canonical page: https://codevetter.com/unpack/hatch

This is a deterministic Repo Unpack scan of pypa/hatch — a structural map, not a review, security audit, or maintainer-endorsed description.

- Scanned commit: 7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0 (2026-09-20)
- Last upstream commit: Fix `hatch.cli.application.Application.ensure_plugin_dependencies` PyApp Compatibility (#2390)
- Generated by codevetter 1.15.0 on 2026-10-02
- 526 files scanned · 2.9 MB

Source inspection; upstream code and tests were not executed.

## Languages

- Python: 397 files
- Markdown: 86 files
- YAML: 15 files
- TOML: 7 files
- JSON: 3 files
- CSS: 1 files
- HTML: 1 files
- Shell: 1 files

## Repository structure

- tests/ — 180 files
- src/ — 136 files
- docs/ — 95 files
- backend/ — 76 files
- .github/ — 12 files
- scripts/ — 9 files
- release/ — 5 files

Probable source entrypoint: `pyproject.toml` (inferred from the tree, not upstream docs)

## Package

- pyproject.toml: hatch vsrc/hatch/_version.py — 0 declared dependencies

## Structural health signals

Average score 7.4/10 across 96 files; 12 hotspots. These are deterministic review leads, not proof of a bug.

## Recent history

- 7c26ebeaf8b8 (2026-09-20) Fix `hatch.cli.application.Application.ensure_plugin_dependencies` PyApp Compatibility (#2390)
- c4abc454f908 (2026-09-20) release Hatchling v1.32.4 (#2441)
- cd57f6890dd0 (2026-09-18) Revert type changes for BuildHookInterface (#2440)
- 5c6dc6c67ff9 (2026-09-18) Strip surrounding whitespace from version metadata (#2438)
- 0941887cd24b (2026-09-17) release Hatchling v1.32.3 (#2436)

## Overview

Hatch is a Python developer CLI for creating projects, managing interpreters and environments, running scripts and quality checks, building distributions, and publishing packages. Its separately packaged Hatchling backend implements standard and editable builds, with shared metadata and pluggy-based extension machinery. At commit 7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0, distinctive capabilities include workspace builds, environment matrices, dependency-source overrides, and pluggable PEP 751 lockfile handling.

## System map

The repository ships a project-management frontend and an independently packaged build backend. Hatch coordinates configuration, environments, subprocesses, and publishing, while Hatchling owns distribution construction and packaging metadata. Runtime state resides in configured filesystem locations, and integrations include installers, package indices, keyring, and downloaded Python distributions. Release workflows produce Python packages, standalone executables, installers, and documentation.
- The Hatch distribution requires Python >=3.10 and exposes hatch = hatch.cli:main; src/hatch/__main__.py delegates module execution to that same main function. — [pyproject.toml#L5-L11](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/pyproject.toml#L5-L11) [pyproject.toml#L71-L84](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/pyproject.toml#L71-L84) [src/hatch/__main__.py#L1-L4](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/__main__.py#L1-L4)
- Hatchling is a separate distribution bootstrapped through hatchling.ouroboros with backend-path=['src']; it exposes hatchling.cli:hatchling and standard build/editable backend functions. — [backend/pyproject.toml#L1-L13](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/pyproject.toml#L1-L13) [backend/pyproject.toml#L53-L57](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/pyproject.toml#L53-L57) [backend/src/hatchling/build.py#L6-L13](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/build.py#L6-L13)
- The frontend uses Click command registration and Application(Terminal); the backend CLI uses argparse and dispatches build, dep, metadata, and version handlers. — [src/hatch/cli/__init__.py#L221-L238](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L221-L238) [src/hatch/cli/application.py#L23-L49](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/application.py#L23-L49) [backend/src/hatchling/cli/__init__.py#L9-L28](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/cli/__init__.py#L9-L28)
- Project lazily owns PluginManager, ProjectConfig, ProjectMetadata, a selected build environment, and BuildFrontend; get_environment constructs the plugin selected by configuration type. — [src/hatch/project/core.py#L45-L61](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L45-L61) [src/hatch/project/core.py#L91-L108](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L91-L108) [src/hatch/project/core.py#L141-L180](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L141-L180) [src/hatch/project/core.py#L410-L418](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L410-L418)
- Global configuration defaults to platformdirs' Hatch config.toml; environment hashes use JSON beneath data_dir/env/.metadata, and virtual environments support configured external paths. — [src/hatch/config/user.py#L63-L67](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/config/user.py#L63-L67) [src/hatch/project/core.py#L106-L108](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L106-L108) [src/hatch/project/env.py#L438-L455](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/env.py#L438-L455) [src/hatch/env/virtual.py#L58-L77](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/virtual.py#L58-L77)
- VirtualEnvironment selects VirtualEnv or UVVirtualEnv, PackageIndex uses HTTPX2, AuthenticationCredentials uses keyring, and PythonManager downloads and installs interpreter archives. — [src/hatch/env/virtual.py#L87-L101](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/virtual.py#L87-L101) [src/hatch/index/core.py#L50-L62](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/index/core.py#L50-L62) [src/hatch/publish/auth.py#L39-L58](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/publish/auth.py#L39-L58) [src/hatch/python/core.py#L81-L119](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/python/core.py#L81-L119)
- Repository workflows use hatch test, hatch fmt --check, and hatch run types:check; hatch.toml defines backend builds, coverage reporting, and strict documentation build/link checks. — [.github/workflows/test.yml#L46-L53](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/test.yml#L46-L53) [hatch.toml#L22-L40](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/hatch.toml#L22-L40) [hatch.toml#L78-L100](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/hatch.toml#L78-L100) [docs/community/contributing.md#L29-L60](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/docs/community/contributing.md#L29-L60)
- Hatch release automation builds wheels/sdists, PyApp binaries, Windows installers, and signed/notarized macOS packaging; Hatchling releases publish backend/dist, while documentation workflows publish GitHub Pages. — [.github/workflows/build-hatch.yml#L74-L103](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/build-hatch.yml#L74-L103) [.github/workflows/build-hatch.yml#L283-L378](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/build-hatch.yml#L283-L378) [.github/workflows/build-hatchling.yml#L34-L65](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/build-hatchling.yml#L34-L65) [.github/workflows/docs-release.yml#L70-L92](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/docs-release.yml#L70-L92)

## Feature catalog

Hatch exposes developer workflows through commands rather than application routes or screens. Its main capabilities cover project generation, environment execution, dependency management, interpreter installation, packaging, and publishing. Quality commands add pytest-based testing, Ruff checks, and Pyrefly type checking. Configuration and diagnostic commands support local operation and troubleshooting.
- hatch new supports interactive details, CLI scaffolding, initialization of existing projects, and attempted setuptools metadata migration; selected template plugins generate the resulting files. — [src/hatch/cli/new/__init__.py#L4-L12](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/new/__init__.py#L4-L12) [src/hatch/cli/new/__init__.py#L26-L70](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/new/__init__.py#L26-L70) [src/hatch/cli/new/__init__.py#L102-L137](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/new/__init__.py#L102-L137)
- hatch env registers create, find, lock, prune, remove, run, and show; hatch run adds ENV: command selection and matrix inclusion/exclusion, with an empty environment prefix selecting system execution. — [src/hatch/cli/env/__init__.py#L17-L23](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/env/__init__.py#L17-L23) [src/hatch/cli/run/__init__.py#L132-L163](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/run/__init__.py#L132-L163) [src/hatch/cli/env/run.py#L98-L121](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/env/run.py#L98-L121)
- hatch run recognizes existing .py files with inline metadata, merges their dependencies into a skip-install environment, defaults its installer to uv, and selects a compatible known Python distribution when needed. — [src/hatch/cli/run/__init__.py#L70-L91](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/run/__init__.py#L70-L91) [src/hatch/cli/run/__init__.py#L100-L128](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/run/__init__.py#L100-L128)
- hatch dep provides lock, sync, hash, and dependency display commands; source types include path, Git, URL, index, and workspace, while locked synchronization through the pip locker is explicitly unsupported. — [src/hatch/cli/dep/__init__.py#L11-L64](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/dep/__init__.py#L11-L64) [src/hatch/cli/dep/__init__.py#L67-L107](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/dep/__init__.py#L67-L107) [src/hatch/project/sources.py#L12-L69](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/sources.py#L12-L69) [src/hatch/env/lockers/pip.py#L101-L114](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/lockers/pip.py#L101-L114)
- hatch python registers find/install/remove/show/update; hatch test offers interpreter/matrix selection, randomization, parallel workers, retries, and coverage through the hatch-test environment. — [src/hatch/cli/python/__init__.py#L10-L19](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/python/__init__.py#L10-L19) [src/hatch/cli/test/__init__.py#L12-L34](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/test/__init__.py#L12-L34) [src/hatch/env/internal/test.py#L6-L25](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/internal/test.py#L6-L25)
- hatch check runs code, fmt, then types when no subcommand is given; Ruff supplies lint/format scripts, Pyrefly supplies default type checks, and the separate fmt command remains registered. — [src/hatch/cli/check/__init__.py#L10-L28](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/check/__init__.py#L10-L28) [src/hatch/env/internal/static_analysis.py#L6-L40](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/internal/static_analysis.py#L6-L40) [src/hatch/env/internal/type_check.py#L12-L20](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/internal/type_check.py#L12-L20) [src/hatch/cli/__init__.py#L221-L238](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L221-L238)
- hatch build defaults to sdist and wheel, supports target versions and hook/clean controls, and consolidates workspace builds with --all; clean delegates to build's clean-only path, and publishing supports PyPI, TestPyPI, or custom repositories. — [src/hatch/cli/build/__init__.py#L73-L115](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/build/__init__.py#L73-L115) [src/hatch/cli/clean/__init__.py#L34-L41](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/clean/__init__.py#L34-L41) [backend/src/hatchling/cli/build/__init__.py#L35-L55](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/cli/build/__init__.py#L35-L55) [src/hatch/publish/index.py#L34-L65](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/publish/index.py#L34-L65)
- Administrative commands display/update configuration, inspect project metadata and status, view/set versions, enter shells, and manage Hatch through report/update/restore; the self-management command name follows PYAPP_COMMAND_NAME. — [src/hatch/cli/__init__.py#L221-L238](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L221-L238) [src/hatch/cli/config/__init__.py#L11-L57](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/config/__init__.py#L11-L57) [src/hatch/cli/project/metadata.py#L40-L57](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/project/metadata.py#L40-L57) [src/hatch/cli/self/__init__.py#L7-L22](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/self/__init__.py#L7-L22)

## Data flow

CLI arguments and environment variables first select application configuration, project location, and execution environment. Project metadata and environment settings are evaluated lazily and transformed into installer requirements or shell commands. Filesystem state records configuration, dependency hashes, interpreter installations, and build artifacts. Build helpers exchange JSON across subprocess boundaries, while publishing transforms archive metadata into authenticated HTTP requests.
- Root CLI inputs become Application state: active-environment inheritance applies only when --env retains its default source; configuration supplies data/cache directories unless CLI options override them. — [src/hatch/cli/__init__.py#L127-L153](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L127-L153) [src/hatch/cli/__init__.py#L159-L186](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L159-L186)
- Project.find_project_root walks parents for pyproject.toml or setup.py; raw_config parses the detected TOML and synthesizes a project name when metadata is absent, then ProjectMetadata feeds ProjectConfig. — [src/hatch/project/core.py#L364-L380](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L364-L380) [src/hatch/project/core.py#L410-L449](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L410-L449) [src/hatch/project/core.py#L54-L61](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L54-L61)
- Source tables normalize dependency names, reject normalization collisions, and replace inherited entries by normalized name; path and Git sources render file:// and git+ direct-reference URLs. — [src/hatch/project/sources.py#L214-L234](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/sources.py#L214-L234) [src/hatch/project/sources.py#L237-L254](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/sources.py#L237-L254) [src/hatch/project/sources.py#L257-L284](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/sources.py#L257-L284)
- run partitions environment/matrix selectors before env run resolves selected environments; runner_context yields an ExecutionContext for command population, then prepares and executes it after the caller resumes iteration. — [src/hatch/cli/run/__init__.py#L132-L163](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/run/__init__.py#L132-L163) [src/hatch/cli/env/run.py#L107-L147](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/env/run.py#L107-L147) [src/hatch/cli/application.py#L119-L140](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/application.py#L119-L140)
- dependency_hash hashes all complex dependencies; Project compares it with persisted metadata, conditionally generates a lockfile and synchronizes installations, then writes the resulting hash to environment JSON. — [src/hatch/env/plugin/interface.py#L857-L869](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/plugin/interface.py#L857-L869) [src/hatch/project/core.py#L234-L256](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L234-L256) [src/hatch/project/env.py#L418-L455](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/env.py#L418-L455)
- BuildFrontend writes generated helper scripts into an environment filesystem context, executes Python there, synchronizes output locally, reads output.json, and moves the returned wheel or sdist into the destination. — [src/hatch/project/frontend/core.py#L30-L76](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/frontend/core.py#L30-L76) [src/hatch/env/plugin/interface.py#L937-L945](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/plugin/interface.py#L937-L945)
- WheelBuilder streams selected source files into WheelArchive, records SHA-256 hashes and sizes, writes distribution data and RECORD, then replaces the temporary archive with the final tagged wheel. — [backend/src/hatchling/builders/wheel.py#L115-L145](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/wheel.py#L115-L145) [backend/src/hatchling/builders/wheel.py#L517-L541](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/wheel.py#L517-L541)
- Publishing reads wheel METADATA or sdist PKG-INFO into upload fields; PackageIndex adds protocol fields and three digests before multipart POST, and prompted credentials persist as cached usernames plus keyring passwords. — [src/hatch/index/publish.py#L19-L51](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/index/publish.py#L19-L51) [src/hatch/index/publish.py#L54-L81](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/index/publish.py#L54-L81) [src/hatch/index/core.py#L64-L98](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/index/core.py#L64-L98) [src/hatch/publish/auth.py#L104-L116](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/publish/auth.py#L104-L116)

## Behavior traces

The source supports ordered walkthroughs of startup, command execution, environment persistence, artifact builds, and publishing. Conditions such as existing environments, skip-install, backend selection, and already-uploaded artifacts materially change the sequence. Environment execution is driven by a generator that prepares and runs work after the command handler populates its context. These are source traces, not observed execution results.
- Startup: main → hatch → Application → ConfigFile.restore if the default file is missing → ConfigFile.load → style initialization → storage directory selection → explicit or current-directory Project selection. — [src/hatch/cli/__init__.py#L127-L186](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L127-L186) [src/hatch/cli/__init__.py#L241-L252](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L241-L252) [src/hatch/config/user.py#L35-L57](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/config/user.py#L35-L57)
- Normal command execution: run parses ENV:ARGS → ctx.invoke(env.run) → parse_matrix_variables/select_environments → Application.runner_context → Project.get_environment → compatibility check only if the environment does not exist. — [src/hatch/cli/run/__init__.py#L150-L163](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/run/__init__.py#L150-L163) [src/hatch/cli/env/run.py#L80-L121](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/env/run.py#L80-L121) [src/hatch/cli/application.py#L119-L140](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/application.py#L119-L140) [src/hatch/project/core.py#L141-L180](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L141-L180)
- Missing-environment preparation: managed_environment → metadata.reset → environment.create → optional pre-install commands → normal/editable project installation → optional post-install commands; skip-install bypasses the installation block. — [src/hatch/project/core.py#L182-L232](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L182-L232) [src/hatch/env/virtual.py#L165-L203](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/virtual.py#L165-L203)
- Persistence after preparation: dependency_hash → EnvironmentMetadata.dependency_hash → optional generate_lockfile for locked inputs → dependencies_in_sync → optional sync_dependencies → update_dependency_hash → JSON write. — [src/hatch/project/core.py#L234-L256](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L234-L256) [src/hatch/env/lock.py#L137-L166](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/lock.py#L137-L166) [src/hatch/project/env.py#L418-L443](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/env.py#L418-L443)
- Shell execution: execute_context applies context.env_vars → run_shell_commands enters command_context → resolve_commands/expand_command formats scripts → run_shell_command invokes the platform; parent SIGINT handling is restored in finally and exit-code policy is applied. — [src/hatch/cli/application.py#L54-L104](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/application.py#L54-L104) [src/hatch/cli/application.py#L151-L155](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/application.py#L151-L155) [src/hatch/env/plugin/interface.py#L963-L1010](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/plugin/interface.py#L963-L1010)
- Hatchling build: build → _build_project → prepare_build_environment → python -m hatchling build → build_impl selects builder → BuilderInterface.build validates metadata and initializes hooks → WheelBuilder.build_standard → finalize hooks → artifact yield. — [src/hatch/cli/build/__init__.py#L153-L208](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/build/__init__.py#L153-L208) [backend/src/hatchling/cli/build/__init__.py#L45-L93](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/cli/build/__init__.py#L45-L93) [backend/src/hatchling/builders/plugin/interface.py#L100-L176](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/plugin/interface.py#L100-L176) [backend/src/hatchling/builders/wheel.py#L517-L541](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/wheel.py#L517-L541)
- Alternative-backend build: prepare_build_environment gathers backend get_requires results → _build_project accepts only sdist/wheel → BuildFrontend generates and executes a hook script → output.json identifies the artifact → the frontend moves it to the requested directory. — [src/hatch/project/core.py#L274-L299](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L274-L299) [src/hatch/cli/build/__init__.py#L165-L181](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/build/__init__.py#L165-L181) [src/hatch/project/frontend/core.py#L30-L76](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/frontend/core.py#L30-L76)
- Publish: CLI selects and checks the publisher → IndexPublisher resolves repository and credentials → recurse_artifacts reads metadata → simple API lookup skips existing filenames → upload_artifact sends new files → successful versions print URLs → write_updated_data persists prompted authentication. — [src/hatch/cli/publish/__init__.py#L101-L115](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/publish/__init__.py#L101-L115) [src/hatch/publish/index.py#L63-L147](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/publish/index.py#L63-L147) [src/hatch/index/core.py#L64-L105](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/index/core.py#L64-L105) [src/hatch/publish/auth.py#L104-L116](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/publish/auth.py#L104-L116)

## Testing signals

Tests and CI were inspected, not executed; no passing result or measured coverage is asserted. The inspected suite uses pytest, Click testing helpers, isolated storage, mocks, and capability-dependent integration tests. It exercises environment creation, signals, builds, credentials, and locking, but some tests deliberately replace process or activation boundaries. This inventory is bounded and does not establish exhaustive coverage.
- The default test environment specifies pytest, pytest-mock, pytest-randomly, pytest-rerunfailures, pytest-xdist, and coverage; tests/conftest.py wraps Click CliRunner and defaults catch_exceptions to False. — [src/hatch/env/internal/test.py#L6-L25](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/internal/test.py#L6-L25) [tests/conftest.py#L46-L62](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/conftest.py#L46-L62)
- The session isolation fixture redirects Hatch data/cache directories into temporary storage and controls shell, color, and active-environment state; marker handling skips unavailable network, OS, Git, Docker, and Cargo capabilities. — [tests/conftest.py#L75-L109](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/conftest.py#L75-L109) [tests/conftest.py#L528-L575](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/conftest.py#L528-L575)
- test_automatic_creation asserts environment storage layout and the child's interpreter path; test_interrupt_signal_not_inherited checks the child's default SIGINT handler and restoration of the parent handler. — [tests/cli/run/test_run.py#L48-L98](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/cli/run/test_run.py#L48-L98) [tests/cli/run/test_run.py#L747-L781](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/cli/run/test_run.py#L747-L781)
- Build tests include Flit backend artifact assertions and wheel archive-content/timestamp assertions; the CLI build module applies mock_backend_process, and process-output fixtures explicitly bypass mocking under allow_backend_process. — [tests/cli/build/test_build.py#L10-L51](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/cli/build/test_build.py#L10-L51) [tests/backend/builders/test_wheel.py#L794-L825](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/backend/builders/test_wheel.py#L794-L825) [tests/conftest.py#L438-L479](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/conftest.py#L438-L479)
- Dependency-lock tests compare top-level lock with dep lock and exercise pip apply-lock rejection; the inspected uv sync test uses mock_locker and replaces safe_activation, so it does not validate a real activation layout. — [tests/cli/dep/test_dep_lock.py#L41-L85](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/cli/dep/test_dep_lock.py#L41-L85) [tests/cli/dep/test_dep_lock.py#L109-L167](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/cli/dep/test_dep_lock.py#L109-L167)
- Publishing CLI tests require Docker/internet and a devpi fixture, with keyring calls replaced by an in-memory store; separate auth tests use a fake home to check .pypirc repository-name and URL matching. — [tests/cli/publish/test_publish.py#L11-L30](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/cli/publish/test_publish.py#L11-L30) [tests/utils/test_auth.py#L5-L48](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/utils/test_auth.py#L5-L48)
- Coverage configuration requests branch coverage but omits module entrypoints, backend bridge code, migration, frontend helper scripts, and shell utilities; presence of other tests does not establish coverage of these omitted boundaries. — [pyproject.toml#L113-L125](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/pyproject.toml#L113-L125)
- Inspected CI defines Linux/Windows/macOS testing across Python 3.10–3.14 and 3.14t, randomized parallel tests with retries, combined coverage reports, downstream builds, and a separate Hyperfine CLI benchmark workflow; none was executed or its results verified. — [.github/workflows/test.yml#L20-L53](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/test.yml#L20-L53) [.github/workflows/test.yml#L65-L105](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/test.yml#L65-L105) [.github/workflows/test.yml#L113-L150](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/test.yml#L113-L150) [.github/workflows/cli.yml#L40-L52](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/cli.yml#L40-L52)

## Risk map

The main sensitive boundaries are executable project configuration, plugin loading, credentials, downloads, and filesystem operations beyond the checkout. These findings describe source behavior and review priorities, not confirmed vulnerabilities. Error handling and persistence choices also affect operational reliability. Tests provide useful signals, but mocks and conditional skips limit what their existence proves.
- Configured scripts are formatted into command strings and EnvironmentInterface.run_shell_command defaults shell=True; pre/post-install commands use this executor, making project command configuration an execution trust boundary. — [src/hatch/env/plugin/interface.py#L963-L1010](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/plugin/interface.py#L963-L1010) [src/hatch/project/core.py#L205-L232](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L205-L232) [src/hatch/utils/platform.py#L92-L105](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/utils/platform.py#L92-L105)
- Third-party plugin discovery loads installed hatch entry points, custom plugin loaders execute Python modules, and environment plugin requirements may be installed into Hatch's own interpreter through uv or PyApp management. — [backend/src/hatchling/plugin/manager.py#L104-L111](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/plugin/manager.py#L104-L111) [src/hatch/plugin/utils.py#L9-L21](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/plugin/utils.py#L9-L21) [backend/src/hatchling/plugin/utils.py#L13-L23](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/plugin/utils.py#L13-L23) [src/hatch/cli/application.py#L162-L195](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/application.py#L162-L195)
- Authentication can read user configuration, .pypirc, and keyring; config show --all bypasses scrubbing, HATCH_DEBUG enables traceback locals, and upload errors mask the exact authentication string through replacement. — [src/hatch/publish/auth.py#L39-L100](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/publish/auth.py#L39-L100) [src/hatch/cli/config/__init__.py#L25-L34](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/config/__init__.py#L25-L34) [src/hatch/cli/__init__.py#L241-L252](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L241-L252) [src/hatch/publish/index.py#L124-L128](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/publish/index.py#L124-L128)
- Environment paths may be absolute outside the project and removal deletes both execution/build environments; wheel clean removes every .whl in its selected directory, and force-includes can package external files. — [src/hatch/env/virtual.py#L58-L64](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/virtual.py#L58-L64) [src/hatch/env/virtual.py#L182-L190](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/virtual.py#L182-L190) [backend/src/hatchling/builders/wheel.py#L508-L515](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/wheel.py#L508-L515) [backend/src/hatchling/builders/plugin/interface.py#L218-L245](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/plugin/interface.py#L218-L245)
- EnvironmentMetadata writes JSON directly with write_text and reads with json.loads, whereas ConfigFile.save uses write_atomic. Hypothesis: interrupted or concurrent metadata writes merit targeted recovery testing; no corruption was observed. (inferred) — [src/hatch/project/env.py#L429-L443](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/env.py#L429-L443) [src/hatch/config/user.py#L26-L33](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/config/user.py#L26-L33) [src/hatch/utils/fs.py#L94-L103](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/utils/fs.py#L94-L103)
- IndexPublisher treats any exception during the simple API existence lookup as an empty artifact set, then attempts uploads; this branch is marked no cov and can conceal the original lookup failure. — [src/hatch/publish/index.py#L110-L128](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/publish/index.py#L110-L128)
- PipLocker.apply_lock raises LockerUnsupportedError and install_matches_lock returns False; locked pip environments therefore have a documented synchronization limitation, with a corresponding CLI failure assertion. — [src/hatch/env/lockers/pip.py#L101-L114](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/lockers/pip.py#L101-L114) [src/hatch/env/virtual.py#L249-L266](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/virtual.py#L249-L266) [tests/cli/dep/test_dep_lock.py#L161-L168](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/cli/dep/test_dep_lock.py#L161-L168)
- PythonManager.install follows redirects, unpacks downloaded archives, and replaces the interpreter installation; custom distribution sources are supported, and tar extraction explicitly applies filter='data'. This is a remote-content-to-local-executable boundary. — [src/hatch/python/core.py#L81-L119](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/python/core.py#L81-L119) [src/hatch/python/resolve.py#L77-L111](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/python/resolve.py#L77-L111) [src/hatch/utils/network.py#L45-L50](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/utils/network.py#L45-L50)

## Extension points

The principal extension mechanism is pluggy registration of named classes. Hatch adds environment, collector, publisher, template, and locker registries to Hatchling's build and version registries. Builders expose artifact-version functions and ordered hooks, while environments and lockers expose lifecycle contracts. CLI command lists and dependency-source parser tables provide additional explicit dispatch points.
- Plugins declare registration hooks with hatchling.plugin.hookimpl, return one or more classes carrying PLUGIN_NAME, and advertise their hook module through project.entry-points.hatch. — [docs/plugins/about.md#L9-L32](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/docs/plugins/about.md#L9-L32) [docs/plugins/about.md#L46-L55](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/docs/plugins/about.md#L46-L55) [backend/src/hatchling/plugin/manager.py#L68-L101](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/plugin/manager.py#L68-L101)
- Hatch's PluginManager extends Hatchling's manager and registers environment, environment_collector, publisher, template, and locker hook providers; backend registries cover builders, build hooks, metadata hooks, version sources, and schemes. — [src/hatch/plugin/manager.py#L1-L35](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/plugin/manager.py#L1-L35) [backend/src/hatchling/plugin/manager.py#L36-L59](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/plugin/manager.py#L36-L59)
- New environment types enter through project.config type selection and plugin_manager.environment.get; their contract includes command execution, dependency hashing, filesystem contexts, compatibility checks, and typed override options. — [src/hatch/project/core.py#L141-L180](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L141-L180) [src/hatch/env/plugin/interface.py#L857-L869](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/plugin/interface.py#L857-L869) [src/hatch/env/plugin/interface.py#L937-L972](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/plugin/interface.py#L937-L972) [src/hatch/env/plugin/interface.py#L1054-L1098](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/plugin/interface.py#L1054-L1098)
- LockerInterface defines supports/generate/in_sync/apply_lock plus optional installation conformance checks; resolution prefers environment locker, then project locker, then uv/pip based on the environment, and built-in hooks register both implementations. — [src/hatch/env/lockers/interface.py#L18-L76](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/lockers/interface.py#L18-L76) [src/hatch/env/lock.py#L119-L134](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/lock.py#L119-L134) [src/hatch/env/lockers/hooks.py#L1-L8](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/lockers/hooks.py#L1-L8)
- BuilderInterface.get_version_api maps version names to artifact-producing functions, get_config_class supplies target configuration, and hooks receive shared build_data through initialize/finalize; WheelBuilder maps standard and editable variants. — [backend/src/hatchling/builders/plugin/interface.py#L147-L176](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/plugin/interface.py#L147-L176) [backend/src/hatchling/builders/plugin/interface.py#L405-L445](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/plugin/interface.py#L405-L445) [backend/src/hatchling/builders/wheel.py#L495-L506](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/builders/wheel.py#L495-L506)
- Metadata hooks update core_raw_metadata and contribute known classifiers; dynamically introduced fields must appear in project.dynamic, while custom script loaders select a get_<plugin_id> factory or a unique interface subclass. — [backend/src/hatchling/metadata/core.py#L195-L226](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/metadata/core.py#L195-L226) [backend/src/hatchling/plugin/utils.py#L13-L48](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/plugin/utils.py#L13-L48)
- Publisher selection instantiates a registered class with application, root, cache, project configuration, and user configuration; templates are ordered by PRIORITY and expose initialize_config/get_files/finalize_files stages. — [src/hatch/cli/publish/__init__.py#L101-L115](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/publish/__init__.py#L101-L115) [src/hatch/cli/new/__init__.py#L102-L137](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/new/__init__.py#L102-L137)
- CLI additions attach to explicit Click add_command lists or argparse registration calls; dependency-source parsing uses _SOURCE_PARSERS after enforcing exactly one recognized source-type key. — [src/hatch/cli/__init__.py#L221-L238](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/__init__.py#L221-L238) [backend/src/hatchling/cli/__init__.py#L9-L18](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/cli/__init__.py#L9-L18) [src/hatch/project/sources.py#L160-L194](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/sources.py#L160-L194)

## Contributor handoff

Begin with the two package manifests and hatch.toml, then follow the relevant command through Application and Project before changing a backend or plugin contract. Preserve lazy evaluation, cross-platform filesystem behavior, lifecycle ordering, and backend-specific branches. Tests and CI were inspected, not executed; use their definitions to plan separately authorized validation without treating them as passing evidence. The investigation is bounded, and upstream contribution rules require disclosed AI assistance and informed human review.
- Read pyproject.toml, backend/pyproject.toml, and hatch.toml first: Hatch and Hatchling have separate build bootstraps, and the repository test environment includes backend/ as a workspace member. — [pyproject.toml#L1-L11](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/pyproject.toml#L1-L11) [backend/pyproject.toml#L1-L13](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/pyproject.toml#L1-L13) [hatch.toml#L9-L20](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/hatch.toml#L9-L20)
- For execution changes, read Application.runner_context and Project.prepare_environment together: command handlers populate yielded contexts before preparation, and preparation preserves create/install/lock/sync ordering. — [src/hatch/cli/application.py#L119-L140](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/application.py#L119-L140) [src/hatch/project/core.py#L197-L256](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/core.py#L197-L256)
- Preserve lazy imports and platform abstractions: Ruff explicitly permits lazy imports for CLI responsiveness, while Path IDs casefold on Windows/macOS and Platform formats subprocess calls. — [ruff.toml#L9-L14](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/ruff.toml#L9-L14) [src/hatch/utils/fs.py#L37-L52](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/utils/fs.py#L37-L52) [src/hatch/utils/platform.py#L92-L105](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/utils/platform.py#L92-L105)
- Build edits must account for both Hatchling subprocess invocation and alternative-backend helper scripts; backend metadata-only hooks are conditionally defined when PIP_BUILD_TRACKER is absent because build hooks can change dependency metadata. — [src/hatch/cli/build/__init__.py#L165-L208](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/build/__init__.py#L165-L208) [src/hatch/project/frontend/core.py#L30-L76](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/project/frontend/core.py#L30-L76) [backend/src/hatchling/build.py#L86-L101](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/backend/src/hatchling/build.py#L86-L101)
- Read tests/conftest.py before choosing validation: fixtures isolate storage, some backend calls run through mocks, and capability markers control skips. Tests and CI were inspected only, so no pass status is available from this brief. — [tests/conftest.py#L75-L109](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/conftest.py#L75-L109) [tests/conftest.py#L438-L479](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/conftest.py#L438-L479) [tests/conftest.py#L528-L575](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/tests/conftest.py#L528-L575) [.github/workflows/test.yml#L46-L53](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/test.yml#L46-L53)
- When execution is authorized, repository guidance provides hatch test, hatch test --cover, and hatch check; target test paths can be forwarded through hatch test's variadic arguments before expanding validation. — [docs/community/contributing.md#L29-L60](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/docs/community/contributing.md#L29-L60) [src/hatch/cli/test/__init__.py#L12-L34](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/test/__init__.py#L12-L34) [src/hatch/env/internal/test.py#L18-L23](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/internal/test.py#L18-L23)
- Distinguish the type-checking paths: CI invokes the types environment's Mypy script, whereas hatch check types uses the hatch-check-types environment and defaults to Pyrefly; pip locking likewise differs from uv because pip cannot apply locks. — [.github/workflows/test.yml#L46-L53](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/.github/workflows/test.yml#L46-L53) [hatch.toml#L35-L47](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/hatch.toml#L35-L47) [src/hatch/cli/check/types.py#L23-L30](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/cli/check/types.py#L23-L30) [src/hatch/env/lockers/pip.py#L101-L114](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/src/hatch/env/lockers/pip.py#L101-L114)
- Upstream contribution documentation requires disclosure of all AI usage, human understanding of contributed code, and human review/editing of AI-assisted issue or discussion content; its commit/submission instructions do not authorize actions in this read-only investigation. — [docs/community/contributing.md#L3-L17](https://github.com/pypa/hatch/blob/7c26ebeaf8b83f5f0374a2545bb15e36c87db0d0/docs/community/contributing.md#L3-L17)

Source repository: https://github.com/pypa/hatch
Full evidence corpus: https://github.com/Codevetter/codevetter/tree/main/benchmarks/repo-unpacks/hatch.json

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
