Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,5 @@ jobs:
- name: Install dependencies
run: uv sync --all-groups

- name: Build and install wheel
run: |
uv build
python -m venv pkgtest
source pkgtest/bin/activate
python -m pip install --upgrade pip
python -m pip install dist/*.whl
python -c "import package_name as m; print(getattr(m, '__version__', 'OK'))"
- name: Build, install, and import package
run: uv run --no-sync python scripts/package_smoke_test.py
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# --- Ruff: lint + format (fast) ---
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.15.17
hooks:
- id: ruff
Comment thread
gemmadanks marked this conversation as resolved.
Resolved
args: [--fix] # remove if you want fail-only
Expand Down
158 changes: 158 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# AGENTS.md

This file applies to the entire repository. It is guidance for coding agents
working on this Python project template.

## Repository overview

- The distributable package uses a `src` layout and lives in
`src/package_name/`.
- Unit tests live in `tests/unit/`; shared fixtures belong in
`tests/conftest.py`.
- Documentation is built with MkDocs Material from `docs/`.
- Example notebooks live in `notebooks/`.
- Dependencies and environments are managed with `uv`; common tasks are
exposed through the root `justfile`.
- Python 3.11 and newer are supported. `.python-version` selects Python 3.14
for the default development environment.

This is a reusable template. Keep examples and configuration generic unless a
task explicitly asks to customize the template for a specific project.

## Working principles

- Make the smallest coherent change that satisfies the task.
- Preserve unrelated work in the working tree. Inspect `git diff` before and
after editing, and do not revert changes you did not make.
- Follow the existing structure and naming conventions instead of introducing
a second tool or parallel configuration.
- Add or update tests when behavior changes. Update user-facing documentation
when public APIs, setup steps, or workflows change.
- Use the lightest planning level in `PLAN.md`: routine work needs no plan file,
while durable task plans are copied into `plans/`.
- Use one writing agent by default. Delegate only independent, bounded work;
prefer parallel agents for read-heavy exploration, testing, or review. Give
parallel writers separate worktrees and non-overlapping ownership.
- Review meaningful changes against `CODE_REVIEW.md` before handoff.
- Record architecturally significant decisions with an ADR based on
`docs/architecture/adr/template.md`.

## Setup and commands

Install the complete development environment with:

```bash
uv sync --all-groups
```

Prefer the `just` recipes because they document the intended local workflow:

```bash
just test # quick tests, excluding tests marked slow
just test-vv # verbose quick tests
just coverage # full pytest run with terminal coverage
just test-notebooks # execute notebooks through nbmake
just lint # Ruff checks
just format # Ruff formatting
just format-check # verify formatting without changing files
just type-check # Pyright
just check # fast, non-mutating handoff checks
just docs-build # strict MkDocs build
just build # build wheel and source distribution
just package-smoke-test # install and import the built wheel in isolation
just ci # comprehensive local CI equivalent
just pre-commit # all push-stage hooks
```
Comment thread
gemmadanks marked this conversation as resolved.
Resolved

For a focused test while iterating, run pytest through `uv`, for example:

```bash
uv run pytest -q tests/unit/test_greet.py
uv run pytest -q tests/unit/test_greet.py::test_say_hello
```

Do not invoke tools from an unrelated global Python environment. If `just` is
not installed, run the corresponding `uv run ...` command from the `justfile`.

## Python code conventions

- Put production code under `src/package_name/`, not at the repository root.
- Use absolute imports from `package_name` in tests and consumer examples.
- Use four spaces, UTF-8, LF line endings, and a final newline, as configured in
`.editorconfig`.
- Let Ruff determine formatting. Do not hand-format code against Ruff's output.
- Add type annotations to new or changed functions. Keep code compatible with
every supported Python version (3.11 through 3.14), not only the version in
`.python-version`.
- Follow the existing Google-style docstrings for public modules and functions.
Examples in Python docstrings must be valid doctests because the quick test
recipes collect doctests from `*.py` files.
- Keep the package importable after changes. Export names from
`src/package_name/__init__.py` only when they are intentionally part of the
top-level public API.

## Tests

- Place unit tests in `tests/unit/` and name files `test_*.py`.
- Use pytest idioms, including parametrization for compact input/output cases
and fixtures in `tests/conftest.py` when they are shared.
- Test observable behavior rather than implementation details.
- Cover normal behavior and relevant edge or failure cases introduced by a
change. Keep tests deterministic and independent of execution order.
- Run the narrowest relevant test during development, then run `just test` for
code changes. Use `just coverage` when the change has broader impact.
- CI runs the full test suite on Linux, macOS, and Windows with Python
3.11-3.14. Avoid platform-specific paths, shell assumptions, and timing-based
assertions in Python code and tests.

## Dependencies and lockfiles

- Declare runtime and development dependencies in `pyproject.toml`; do not add
`requirements.txt`, Poetry, or another environment manager.
- Use `uv add <package>` for runtime dependencies, `uv add --dev <package>` for
development dependencies, and `uv add --group docs <package>` for docs-only
dependencies.
- Commit the resulting `pyproject.toml` and `uv.lock` changes together.
- Use `uv lock` after a manual metadata change and `uv lock --upgrade` only when
an upgrade is intended. Do not casually regenerate or broadly upgrade the
lockfile for an unrelated task.

## Documentation and notebooks

- Keep documentation within the existing Diataxis sections: `tutorials/`,
`how-to/`, `reference/`, and `explanation/`.
- Add new pages to `mkdocs.yml` when they should appear in navigation.
- Build docs with `just docs-build`; the build is strict and warnings fail CI.
- Keep API reference paths aligned with importable modules under
`src/package_name/`.
- Notebook outputs are stripped by pre-commit. After changing a notebook, run
`just test-notebooks` and do not commit execution output or local kernel
metadata.
- `site/`, `dist/`, and `build/` are generated artifacts and must not be
committed.

## Releases and commits

- Use Conventional Commit subjects such as `feat:`, `fix:`, `docs:`, `test:`,
`refactor:`, `build:`, and `ci:` when asked to create commits.
- Release Please manages version bumps, release notes, and release metadata.
Do not manually edit `CHANGELOG.md`, `.release-please-manifest.json`, or
release version fields in `pyproject.toml`, `CITATION.cff`, and `uv.lock`
unless the task is specifically about a release.
- Never commit secrets, local virtual environments, caches, coverage output, or
generated documentation.

## Validation before handoff

Choose checks proportional to the change. For a typical Python change, run the
non-mutating handoff suite:

```bash
just check
```

Also run `just docs-build` for documentation or public API changes,
`just test-notebooks` for notebook changes, and `just package-smoke-test` for
packaging changes. Use `just ci` before handing off a broad or high-risk change.
Review the final diff using `CODE_REVIEW.md`, report which checks ran, and
clearly identify any check that could not be run.
59 changes: 59 additions & 0 deletions CODE_REVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Code Review Guide

Use this guide for human or agent review of uncommitted changes, commits, and
pull requests. Establish the intended outcome from the request, issue, or work
plan before judging the implementation.

## Review priorities

Review in this order:

1. Correctness and regressions
2. Security, privacy, and unsafe data handling
3. Public API and supported-version compatibility
4. Missing or misleading tests
5. Packaging, documentation, and operational impact
6. Maintainability that materially affects future changes

Do not spend review attention on formatting that Ruff or another configured
tool handles automatically.

## Review method

1. Read the complete diff and inspect relevant surrounding code, not only the
changed lines.
2. Trace important inputs, outputs, error paths, and platform-dependent paths.
3. Compare behavior with tests, documentation, and public API promises.
4. Run the narrowest command that can confirm or refute a suspected problem.
5. Check that generated files, lockfiles, and release-managed files changed only
when the task requires them.
6. Finish with `just check` when proportional to the change, plus the additional
commands required by `AGENTS.md`.

## Finding quality

Report only actionable findings caused by the change. Each finding should
include:

- **Priority:** `P0` critical, `P1` high, `P2` normal, or `P3` low
- **Location:** the smallest useful file and line range
- **Impact:** the concrete failure or risk and who or what it affects
- **Evidence:** the execution path, reproduction, test, or repository fact that
supports the finding
- **Remediation:** a concise direction when the fix is not obvious

Avoid vague warnings, speculative failures without a reachable path, and style
preferences not enforced by the repository. Group findings that share one root
cause.

## Review output

Present findings first, ordered by priority. Then state:

- assumptions or questions that limit confidence;
- checks run and their results;
- residual risks or coverage gaps.

If there are no findings, say so explicitly and still report checks and
remaining test or review gaps. A clean review means no actionable issue was
found; it does not claim the change is risk-free.
Loading
Loading