Skip to content
Back to skills

097 Index 2e7dc709

ASecurity

Metadata hooks provide mechanisms for dynamically injecting and modifying project metadata during the build process. Hatchling includes built-in hooks and supports custom implementations for advanced use cases.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
businesspythongo

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 097-index_2e7dc709 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 097 Index 2e7dc709?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 097 Index 2e7dc709
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-097-index-2e7dc709/badge)](https://www.skillsdirectory.com/skills/tools-only-097-index-2e7dc709)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
category: metadata-management
topics: [metadata-hooks, hook-system, dynamic-injection, build-process]
---

# Metadata Hooks

Metadata hooks provide mechanisms for dynamically injecting and modifying project metadata during the build process. Hatchling includes built-in hooks and supports custom implementations for advanced use cases.

## Navigation

- [Metadata Hooks System](./metadata-hooks.md) - Hook configuration, built-in hooks, execution flow
- [Custom Metadata Hooks](./custom-hooks.md) - Implementing custom hooks with MetadataHookInterface

## When to Use Metadata Hooks

Metadata hooks are appropriate when:

- Dynamic version injection from source files is needed
- Classifiers or other fields require computation at build time
- Metadata should be sourced from external files or configurations
- Custom metadata validation or transformation is required
- Metadata needs to vary based on build environment

## Quick Start

Configure a metadata hook in `pyproject.toml`:

```toml
[tool.hatch.metadata.hooks.custom]
path = "hatch_build.py"
```

Implement the `MetadataHookInterface` in the specified file:

```python
from hatchling.metadata.plugin.interface import MetadataHookInterface

class CustomMetadataHook(MetadataHookInterface):
    def update(self, metadata):
        # Modify metadata in-place
        metadata["version"] = "1.0.0"
```

## Key Concepts

**Hook Configuration**: Hooks are configured in `[tool.hatch.metadata.hooks.*]` sections in `pyproject.toml`.

**Execution Timing**: Hooks execute during:

- Building distributions
- Running `hatch project metadata` command
- Installing the project
- IDE operations requiring metadata

**Metadata Dictionary**: The `update()` method receives a mutable metadata dictionary that reflects the current project metadata state. Modifications are applied in-place.

**Hook Interface**: All metadata hooks implement `MetadataHookInterface`, providing `update(metadata)` as the primary method and `get_known_classifiers()` as an optional method.

## Related Topics

- [Dynamic Metadata Fields](../project-metadata/dynamic-metadata.md) - Declaring fields as dynamic
- [Metadata Options](../project-metadata/metadata-options.md) - Configuration options
- [Custom Build Hooks](../build-hooks/index.md) - Build-time hook system (different from metadata hooks)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.