# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Commands **Run `composer test` after every code change before considering a task complete.** ## Architecture ### Code organisation **Code is organised package-by-domain.** Each domain package under `src//` contains everything related to that domain: value objects, repositories, controllers, REST endpoints, and shortcode pages. Cross-cutting wiring classes (Plugin, AdminMenu, RestRegistrar, ShortcodeRegistrar, Schema) live directly under `src/`. ### Data Storage Custom database tables are created via `dbDelta` on activation; `Schema.php` holds the SQL. All database access goes through repository classes within their domain package. No direct `$wpdb` calls outside repositories. ### REST API Namespace All endpoints live under `/wp-json/us-scheduler/v1/`. Permissions are enforced via `permission_callback` using capability checks (`manage_availability`, `book_lesson`), never role name checks. ### Testing Approach Tests stub WordPress with Brain\Monkey rather than booting a real WP install. The setup and the Brain\Monkey/Mockery API gotchas are in `tests/CLAUDE.md`. ### Adding a Feature 0. **If the feature touches `Schema.php`, bump both the `Version:` header and `USC_VERSION` in `unsupervised-schedular.php`.** `Plugin::boot()` only re-runs `Installer`/`dbDelta` when the stored `us_schedular_version` differs, so a schema change without a version bump never reaches existing sites and inserts into new columns fail silently. 1. Write the feature doc in `docs/features/.md` (data model, API, classes, test paths). 2. Create a domain package under `src//` containing all classes for that feature. 3. Add template(s) under `templates/` if needed. 4. Write unit tests under `tests/Unit//` mirroring the `src//` structure. 5. Run `composer test` — all tests must pass before the feature is complete.