|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project |
| 6 | + |
| 7 | +`specfact-cli-modules` hosts official nold-ai bundle packages and the module registry used by SpecFact CLI. Bundle packages import from `specfact_cli` (models, runtime, validators). The core CLI lives in a sibling repo (`specfact-cli`). |
| 8 | + |
| 9 | +## Local Setup |
| 10 | + |
| 11 | +```bash |
| 12 | +hatch env create |
| 13 | +hatch run dev-deps # installs specfact-cli from $SPECFACT_CLI_REPO or ../specfact-cli |
| 14 | +``` |
| 15 | + |
| 16 | +In worktrees, `dev-deps` prefers a matching `specfact-cli-worktrees/<branch>` checkout before falling back to the canonical sibling repo. |
| 17 | + |
| 18 | +## Quality Gates |
| 19 | + |
| 20 | +Run in this order: |
| 21 | + |
| 22 | +```bash |
| 23 | +hatch run format |
| 24 | +hatch run type-check |
| 25 | +hatch run lint |
| 26 | +hatch run yaml-lint |
| 27 | +hatch run verify-modules-signature --require-signature --payload-from-filesystem --enforce-version-bump |
| 28 | +hatch run contract-test |
| 29 | +hatch run smart-test |
| 30 | +hatch run test |
| 31 | +``` |
| 32 | + |
| 33 | +Run a single test file: `hatch run test tests/path/to/test_file.py` |
| 34 | +Run a single test: `hatch run test tests/path/to/test_file.py::TestClass::test_name` |
| 35 | + |
| 36 | +Pre-commit hooks mirror CI: `pre-commit install && pre-commit run --all-files` |
| 37 | + |
| 38 | +CI runs in `.github/workflows/pr-orchestrator.yml` — matrix quality gates on Python 3.11/3.12/3.13. |
| 39 | + |
| 40 | +## Architecture |
| 41 | + |
| 42 | +### Bundle packages (`packages/<bundle-name>/`) |
| 43 | + |
| 44 | +Six official bundles: `specfact-backlog`, `specfact-codebase`, `specfact-code-review`, `specfact-govern`, `specfact-project`, `specfact-spec`. Each bundle has: |
| 45 | +- `module-package.yaml` — name, version, commands, core_compatibility, integrity checksums |
| 46 | +- `src/<python_package>/` — bundle source code |
| 47 | + |
| 48 | +### Import policy (`ALLOWED_IMPORTS.md`) |
| 49 | + |
| 50 | +- Only allowed `specfact_cli.*` prefixes may be imported in bundle code (CORE/SHARED APIs only) |
| 51 | +- Cross-bundle lateral imports are forbidden except specific allowed pairs (e.g. `specfact_spec` -> `specfact_project`) |
| 52 | +- Enforced by `hatch run check-bundle-imports` |
| 53 | + |
| 54 | +### Registry (`registry/`) |
| 55 | + |
| 56 | +- `index.json` — published bundle metadata (versions, artifact URLs, checksums) |
| 57 | +- `modules/` and `signatures/` — published artifacts |
| 58 | + |
| 59 | +### Repo tooling |
| 60 | + |
| 61 | +- `tools/` — development infrastructure (type-checker wrapper, smart test coverage, contract-first testing, manifest validation, core dependency bootstrapping) |
| 62 | +- `scripts/` — publishing, signing, import checking, pre-commit hooks |
| 63 | +- `src/specfact_cli_modules/` — shared repo-level Python package |
| 64 | + |
| 65 | +### OpenSpec workflow (`openspec/`) |
| 66 | + |
| 67 | +- `openspec/specs/` — canonical specifications |
| 68 | +- `openspec/changes/` — active change proposals (proposal, design, delta specs, tasks, TDD evidence) |
| 69 | +- `openspec/changes/archive/` — completed changes |
| 70 | +- `openspec/CHANGE_ORDER.md` — tracks change sequencing and dependencies |
| 71 | + |
| 72 | +## Development Workflow |
| 73 | + |
| 74 | +### Branch protection |
| 75 | + |
| 76 | +`dev` and `main` are protected — never work directly on them. Use feature branches: `feature/*`, `bugfix/*`, `hotfix/*`, `chore/*`. PRs go to `dev` unless release workflow requires `main`. |
| 77 | + |
| 78 | +### Git worktrees |
| 79 | + |
| 80 | +Use worktrees for parallel branch work. Keep primary checkout as canonical `dev` workspace. Worktree paths: `../specfact-cli-modules-worktrees/<branch-type>/<branch-slug>`. |
| 81 | + |
| 82 | +### OpenSpec (required before code changes) |
| 83 | + |
| 84 | +Verify an active OpenSpec change covers the requested scope before changing code. If missing: create or extend a change first. |
| 85 | + |
| 86 | +Follow strict TDD order: spec delta -> failing tests -> implementation -> passing tests -> quality gates. Record TDD evidence in `openspec/changes/<change-id>/TDD_EVIDENCE.md`. |
| 87 | + |
| 88 | +### OpenSpec archive rule (hard requirement) |
| 89 | + |
| 90 | +Never manually move folders under `openspec/changes/` into `archive/`. Archiving MUST use `openspec archive <change-id>` (or equivalent workflow command). Update `openspec/CHANGE_ORDER.md` when archive status changes. |
| 91 | + |
| 92 | +## Bundle Versioning |
| 93 | + |
| 94 | +SemVer: patch (bug fix), minor (new command/option/API), major (breaking change/removal). When bumping a version, review and update `core_compatibility` in both `module-package.yaml` and `registry/index.json`. |
| 95 | + |
| 96 | +## Linting Scope |
| 97 | + |
| 98 | +- `ruff` runs on the full repo |
| 99 | +- `basedpyright` and `pylint` are scoped to `src/`, `tests/`, and `tools/` |
| 100 | +- Line length: 120 characters |
| 101 | +- Python target: 3.11+ |
0 commit comments