Skip to content

Commit beade8e

Browse files
authored
Add AGENTS.md for dev/ and scripts/ci/prek/ (#64434)
* Add AGENTS.md guidelines for dev/ scripts New scripts in dev/ should be standalone Python (not bash) with inline script metadata so they can be run via `uv run`. * Add AGENTS.md guidelines for dev/ and scripts/ci/prek/ Add coding guidelines for AI agents working in these directories: - dev/AGENTS.md: new scripts must be standalone Python with inline script metadata (after the license header), run via `uv run`. - scripts/ci/prek/AGENTS.md: use common_prek_utils.py helpers, breeze-dependent hooks go at the end of .pre-commit-config.yaml.
1 parent 04b90f5 commit beade8e

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

dev/AGENTS.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!-- SPDX-License-Identifier: Apache-2.0
2+
https://www.apache.org/licenses/LICENSE-2.0 -->
3+
4+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
5+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
6+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
7+
8+
- [dev/ directory guidelines](#dev-directory-guidelines)
9+
- [Scripts](#scripts)
10+
11+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
12+
13+
# dev/ directory guidelines
14+
15+
## Scripts
16+
17+
New scripts in `dev/` must be standalone Python scripts (not bash). Each script must include
18+
[inline script metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/)
19+
placed **after** the Apache License header, so that `uv run` can execute it without any prior
20+
installation:
21+
22+
```python
23+
#!/usr/bin/env python3
24+
# Licensed to the Apache Software Foundation (ASF) ...
25+
# http://www.apache.org/licenses/LICENSE-2.0
26+
# ...
27+
# /// script
28+
# requires-python = ">=3.9"
29+
# dependencies = [
30+
# "some-package",
31+
# ]
32+
# ///
33+
```
34+
35+
If the script only uses the standard library, omit the `dependencies` key but keep the
36+
`requires-python` line.
37+
38+
Run scripts with:
39+
40+
```shell
41+
uv run dev/my_script.py [args...]
42+
```
43+
44+
Document `uv run` (not `python`) as the invocation method in READMEs and instructions.

scripts/ci/prek/AGENTS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- SPDX-License-Identifier: Apache-2.0
2+
https://www.apache.org/licenses/LICENSE-2.0 -->
3+
4+
# scripts/ci/prek/ guidelines
5+
6+
## Overview
7+
8+
This directory contains prek (pre-commit) hook scripts. Shared utilities live in
9+
`common_prek_utils.py` — always check there before duplicating logic.
10+
11+
## Breeze CI image scripts
12+
13+
Some prek scripts require the Breeze CI Docker image to run (e.g. mypy checks, OpenAPI spec
14+
generation, provider validation). These scripts use the `run_command_via_breeze_shell` helper
15+
from `common_prek_utils.py` to execute commands inside the container.
16+
17+
When adding a new breeze-dependent hook:
18+
19+
1. Import and use `run_command_via_breeze_shell` from `common_prek_utils` — do not shell out
20+
to `breeze` directly.
21+
2. Register the hook at the **end** of the relevant `.pre-commit-config.yaml` file (breeze
22+
hooks are slow and should run after fast, local checks).
23+
24+
## Adding new hooks
25+
26+
- Scripts must be Python (not bash).
27+
- Use helpers from `common_prek_utils.py` for path constants, console output, and breeze
28+
execution.
29+
- Register the script in the appropriate `.pre-commit-config.yaml` (`/.pre-commit-config.yaml`
30+
for repo-wide hooks, `/airflow-core/.pre-commit-config.yaml` for core-specific hooks, or a
31+
provider-level config).

0 commit comments

Comments
 (0)