|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## What is Rhiza? |
| 6 | + |
| 7 | +Rhiza is a **collection of reusable configuration templates** for Python projects — not a runtime library. It has no `src/` directory and no runtime dependencies. Its purpose is to provide and continuously synchronize development infrastructure (Makefiles, CI workflows, linting configs, test setups) into downstream projects via the separate `rhiza-cli` tool. |
| 8 | + |
| 9 | +Downstream projects adopt Rhiza by adding a `.rhiza/template.yml` that lists which bundles to sync from this repository. |
| 10 | + |
| 11 | +## Commands |
| 12 | + |
| 13 | +```bash |
| 14 | +make install # Full setup: installs uv, downloads Python 3.13, creates .venv, installs deps |
| 15 | +make test # Run all tests with coverage (90% minimum required) |
| 16 | +make fmt # Run all pre-commit hooks (ruff format/check, markdownlint, bandit, etc.) |
| 17 | +make deptry # Check for unused/missing dependencies |
| 18 | +make docs-coverage # Check docstring coverage (100% required) |
| 19 | +make typecheck # Static type checking with ty |
| 20 | +make benchmark # Performance benchmarks |
| 21 | +make hypothesis-test # Property-based tests only |
| 22 | +make stress # Load/concurrency tests |
| 23 | +make security # pip-audit + bandit security scans |
| 24 | +make book # Build documentation |
| 25 | +make marimo # Start Marimo notebook server |
| 26 | +make clean # Remove build artifacts and stale branches |
| 27 | +``` |
| 28 | + |
| 29 | +**Running a single test:** |
| 30 | +```bash |
| 31 | +uv run pytest tests/api/test_makefile_targets.py -v |
| 32 | +uv run pytest tests/api/test_makefile_targets.py::TestClass::test_method -v |
| 33 | +uv run pytest -m "not stress" tests/ # Exclude stress tests |
| 34 | +``` |
| 35 | + |
| 36 | +## Command Execution Policy |
| 37 | + |
| 38 | +Follow this order strictly: |
| 39 | + |
| 40 | +1. If a `make` target exists → use `make <target>` |
| 41 | +2. No `make` target → use `uv run <command>` |
| 42 | +3. Never invoke `.venv/bin/python`, `.venv/bin/pytest`, etc. directly |
| 43 | + |
| 44 | +The virtual environment is managed automatically by `make` and `uv run`. No manual activation is needed. |
| 45 | + |
| 46 | +## Architecture |
| 47 | + |
| 48 | +### Template Bundles |
| 49 | + |
| 50 | +The core abstraction is the **bundle** — a named group of configuration files. The 13 bundles are defined in `.rhiza/template-bundles.yml`: |
| 51 | + |
| 52 | +- `core` (required): Makefiles, linting, base infrastructure |
| 53 | +- `tests`: pytest, coverage, type checking |
| 54 | +- `github`: GitHub Actions workflows |
| 55 | +- `gitlab`: GitLab CI |
| 56 | +- `docker`, `devcontainer`: containerisation |
| 57 | +- `marimo`: interactive notebooks |
| 58 | +- `book`: documentation with pdoc + mkdocs |
| 59 | +- `presentation`: Marp slides |
| 60 | +- `lfs`, `legal`, `renovate`, `gh-aw`: miscellaneous tooling |
| 61 | + |
| 62 | +### Modular Makefile System |
| 63 | + |
| 64 | +The root `Makefile` is intentionally thin (~10 lines) and only `include`s `.rhiza/rhiza.mk`. That file auto-loads everything in `.rhiza/make.d/*.mk` alphabetically. |
| 65 | + |
| 66 | +Hook targets use double-colon syntax (`pre-install::`, `post-install::`) and can be defined multiple times to chain behaviour. Add project-specific hooks directly in the root `Makefile` above the include line. Developer-local shortcuts go in `local.mk` (not committed). |
| 67 | + |
| 68 | +### Dependency Management |
| 69 | + |
| 70 | +`uv` manages all Python/dependency concerns: |
| 71 | +- `.python-version` is the single source of truth for the Python version |
| 72 | +- `uv.lock` pins all transitive dependencies — keep it in sync via `uv lock` or `uv sync` |
| 73 | +- `uv run` transparently uses the project venv without manual activation |
| 74 | + |
| 75 | +### Code Quality Requirements |
| 76 | + |
| 77 | +- **Ruff** (`ruff.toml`): line length 120, Google-style docstrings, double quotes, rules D/E/F/I/N/W/UP/B/C4/SIM/PT/RUF/S/TRY/ICN |
| 78 | +- **Docstring coverage**: 100% (interrogate) — all public functions, classes, and modules require docstrings |
| 79 | +- **Test coverage**: 90% minimum |
| 80 | +- **Pre-commit hooks**: `make fmt` runs ruff, markdownlint, bandit, actionlint, interrogate, jsonschema, and uv-lock validation |
| 81 | + |
| 82 | +### GitHub Agentic Workflows (gh-aw) |
| 83 | + |
| 84 | +Agentic workflows live in `.github/workflows/` as `.md` source files compiled to `.lock.yml`. **Never edit `.lock.yml` files directly.** After editing any `.md` workflow: |
| 85 | + |
| 86 | +```bash |
| 87 | +make gh-aw-compile # Recompile .md → .lock.yml |
| 88 | +``` |
| 89 | + |
| 90 | +Always commit both the `.md` and the updated `.lock.yml` together. |
| 91 | + |
| 92 | +### CI/CD |
| 93 | + |
| 94 | +- **GitHub Actions** (primary): `.github/workflows/` — CI, release, docker, CodeQL, weekly, sync |
| 95 | +- **GitLab CI** (parallel): `.gitlab-ci.yml` — mirrors GitHub Actions coverage |
| 96 | +- Agent environment is pre-configured via `.github/workflows/copilot-setup-steps.yml` (runs before agent starts) and `.github/hooks/hooks.json` (quality gates: `make fmt` + `make test` on session end) |
0 commit comments