Skip to content

Commit 06850b2

Browse files
docs: update AGENTS.md with CI/linting guidance and known pitfalls (#1940)
Add practical CI validation commands, pipeline structure, common failure patterns, and known type system limitations learned from real PR workflows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 35ffe03 commit 06850b2

1 file changed

Lines changed: 47 additions & 22 deletions

File tree

AGENTS.md

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,70 @@ Follow these instructions in addition to any higher-level system or tool rules.
99

1010
- **Project**: `commitizen` - a tool to help enforce and automate conventional commits, version bumps, and changelog generation.
1111
- **Primary language**: Python (library + CLI).
12+
- **Cross-platform**: Tests run on Linux, macOS, and Windows. Avoid POSIX-only assumptions in code (paths, subprocesses, line endings).
1213
- **Key entrypoints**:
1314
- `commitizen/cli.py` - main CLI implementation.
1415
- `commitizen/commands/` - subcommands such as `bump`, `commit`, `changelog`, `check`, etc.
1516
- `commitizen/config/` - configuration discovery and loading.
1617
- `commitizen/providers/` - version providers (e.g., `pep621`, `poetry`, `npm`, `uv`).
18+
- **Config sources**: `pyproject.toml` (project config, poe tasks, ruff, mypy), `.pre-commit-config.yaml` (hooks), `.github/workflows/` (CI).
1719

1820
## General Expectations
1921

20-
- **Preserve public behavior and CLI UX.**
21-
- **Avoid breaking changes** (APIs, CLI flags, exit codes) unless explicitly requested.
22-
- **Keep changes small and focused.**
22+
- **Preserve public behavior and CLI UX** — no breaking changes to APIs, CLI flags, or exit codes unless explicitly requested.
2323
- **Update or add tests/docs** when you change user-facing behavior.
24+
- **Commit messages** must follow [Conventional Commits](https://www.conventionalcommits.org/) (enforced by commitizen itself).
2425

25-
## How to Explore and Validate Changes
26+
## Setup and Validation
2627

27-
- **Code entrypoints**:
28-
- CLI behavior: `commitizen/cli.py` and `commitizen/commands/`.
29-
- Config resolution: `commitizen/config/factory.py` and config modules.
30-
- Bump/changelog/versioning: `commitizen/bump.py`, `commitizen/changelog.py`, `commitizen/version_schemes.py`, `commitizen/providers/`.
31-
- **Docs to consult** (before larger changes):
32-
- `docs/README.md`
33-
- `docs/contributing.md`
34-
- `docs/commands/` and `docs/config/`
35-
- **Tests**:
36-
- Prefer targeted runs, e.g. `uv run pytest tests/test_cli.py` or a specific `tests/commands/` file.
28+
### Bootstrap
3729

38-
## Coding Guidelines (for AI tools)
30+
```bash
31+
uv sync --frozen --group base --group test --group linters
32+
```
33+
34+
### Local commands
35+
36+
- **Format**: `uv run poe format` (runs `ruff check --fix` then `ruff format`)
37+
- **Lint**: `uv run poe lint` (runs `ruff check` then `mypy`)
38+
- **Test**: `uv run poe test` (runs `pytest -n auto`)
39+
- **CI-equivalent**: `uv run poe ci` (commit check + pre-commit hooks via `prek` + test with coverage)
40+
- **Full local check**: `uv run poe all` (format + lint + check-commit + coverage)
41+
42+
Always run at least `uv run ruff check --fix . && uv run ruff format .` before pushing. CI will fail if the formatter modifies any files.
43+
44+
### CI pipeline
45+
46+
- CI runs `poe ci` on a matrix of Python 3.10–3.14 × ubuntu/macos/windows.
47+
- Pre-commit hooks are defined in `.pre-commit-config.yaml` and run via `prek`.
48+
- The matrix is **fail-fast**: inspect the earliest failing job that completed; others are cancelled.
49+
50+
### Common CI failure patterns
51+
52+
- **"Format Python code...Failed"**: Run `uv run poe format` and commit the result.
53+
- **mypy `[arg-type]` on TypedDict**: Dynamically-constructed dicts (e.g., from `pytest.mark.parametrize`) passed to TypedDict-typed params need `# type: ignore[arg-type]`.
54+
- **"pathspec 'vX.Y.Z' did not match"**: `.pre-commit-config.yaml` pins a tag of this repo. Rebase onto master to pick up the tag.
55+
- **`VersionProtocol` + `issubclass`**: This Protocol has non-method members (properties), so `issubclass()` raises `TypeError`. Use `hasattr` checks for runtime validation.
56+
57+
## What to Read Before Changing
58+
59+
| Changing... | Read first |
60+
|---|---|
61+
| CLI flags/arguments | `commitizen/cli.py`, `docs/commands/<cmd>.md`, `tests/test_cli/` |
62+
| Bump logic | `commitizen/bump.py`, `commitizen/commands/bump.py`, `docs/commands/bump.md` |
63+
| Changelog generation | `commitizen/changelog.py`, `commitizen/changelog_formats/`, `docs/commands/changelog.md` |
64+
| Version schemes | `commitizen/version_schemes.py`, `tests/test_version_schemes.py` |
65+
| Version providers | `commitizen/providers/`, `tests/test_providers.py`, `docs/config/version_provider.md` |
66+
| Config resolution | `commitizen/config/`, `tests/test_conf.py`, `docs/config/` |
67+
| Tag handling | `commitizen/tags.py`, `tests/test_tags.py` |
68+
| Pre-commit / CI | `.pre-commit-config.yaml`, `.github/workflows/`, `pyproject.toml` (poe tasks) |
69+
70+
## Coding Guidelines
3971

40-
- **Style**: Follow patterns in nearby code; keep functions focused.
4172
- **Types**: Preserve or improve existing type hints.
4273
- **Errors**: Prefer `commitizen/exceptions.py` error types; keep messages clear for CLI users.
4374
- **Output**: Use `commitizen/out.py`; do not add noisy logging.
4475

45-
## Common Task Pointers
46-
47-
- **CLI commands**: edit `commitizen/commands/<name>.py`, wire via `commitizen/cli.py`, and adjust `tests/commands/` + `docs/commands/`.
48-
- **Version bumps / changelog**: use `commitizen/bump.py`, `commitizen/changelog.py`, `commitizen/version_schemes.py`, and `commitizen/providers/` (+ matching tests).
49-
- **Config resolution**: use `commitizen/config/factory.py` and config modules; update `tests/test_conf.py` and related tests.
50-
5176
## When Unsure
5277

5378
- Prefer **reading tests and documentation first** to understand the expected behavior.

0 commit comments

Comments
 (0)