|
| 1 | +# Base Agent Rules |
| 2 | + |
| 3 | +> Single source of truth for AI agent conventions in this project. Read this file at the start of every session before doing anything else. |
| 4 | +
|
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a full-stack web application with a Python backend and TypeScript/Node 22 frontend. |
| 8 | + |
| 9 | +**Backend**: Python 3.10+, FastAPI, SQLModel, PostgreSQL, managed with `uv` |
| 10 | +**Frontend**: TypeScript, Node 22, ESM-only, managed with `bun` |
| 11 | +**CI/CD**: GitHub Actions — automated tests, linting, Docker compose validation, Claude AI review |
| 12 | +**Infrastructure**: Docker Compose for local development and CI |
| 13 | + |
| 14 | +Architecture: HTTP API (backend) consumed by a single-page frontend. Services run in Docker containers locally and in staging/production via GitHub Actions deployments. |
| 15 | + |
| 16 | +``` |
| 17 | +full-stack-agentic/ |
| 18 | + backend/ Python FastAPI application |
| 19 | + frontend/ TypeScript/Node 22 frontend |
| 20 | + .github/ CI workflows, PR templates, CODEOWNERS |
| 21 | + .agents/rules/ AI agent conventions (this directory) |
| 22 | + .claude/ Claude Code settings and commands |
| 23 | + specs/ Feature specifications (SpecKit artifacts) |
| 24 | +``` |
| 25 | + |
| 26 | +## Project Structure |
| 27 | + |
| 28 | +``` |
| 29 | +. |
| 30 | +├── backend/ |
| 31 | +│ ├── app/ Application source (routers, models, services) |
| 32 | +│ ├── tests/ pytest test suite |
| 33 | +│ └── pyproject.toml |
| 34 | +├── frontend/ |
| 35 | +│ ├── src/ TypeScript source |
| 36 | +│ └── package.json |
| 37 | +├── .github/ |
| 38 | +│ ├── workflows/ CI workflow files |
| 39 | +│ ├── CODEOWNERS Auto-review assignments |
| 40 | +│ └── pull_request_template.md |
| 41 | +├── .agents/ |
| 42 | +│ └── rules/ Agent rule files (base.md, coding-standards.md, ai-feedback-learning-loop.md) |
| 43 | +├── .claude/ |
| 44 | +│ ├── commands/ SpecKit skill files |
| 45 | +│ └── settings.json Shared Claude tool permissions |
| 46 | +└── specs/ Per-feature SpecKit artifacts |
| 47 | +``` |
| 48 | + |
| 49 | +## Available Commands |
| 50 | + |
| 51 | +### Backend Tests |
| 52 | + |
| 53 | +```bash |
| 54 | +uv run pytest |
| 55 | +``` |
| 56 | + |
| 57 | +```bash |
| 58 | +uv run python -m pytest |
| 59 | +``` |
| 60 | + |
| 61 | +### Backend Lint |
| 62 | + |
| 63 | +```bash |
| 64 | +uv run ruff check . |
| 65 | +``` |
| 66 | + |
| 67 | +```bash |
| 68 | +uv run ruff format . |
| 69 | +``` |
| 70 | + |
| 71 | +### Backend Type Check |
| 72 | + |
| 73 | +```bash |
| 74 | +uv run ty check |
| 75 | +``` |
| 76 | + |
| 77 | +### Frontend Tests |
| 78 | + |
| 79 | +```bash |
| 80 | +bun run test |
| 81 | +``` |
| 82 | + |
| 83 | +### Frontend Lint |
| 84 | + |
| 85 | +```bash |
| 86 | +bun run lint |
| 87 | +``` |
| 88 | + |
| 89 | +### Docker (local dev) |
| 90 | + |
| 91 | +```bash |
| 92 | +docker compose up |
| 93 | +``` |
| 94 | + |
| 95 | +```bash |
| 96 | +docker compose down |
| 97 | +``` |
| 98 | + |
| 99 | +### SpecKit Scripts |
| 100 | + |
| 101 | +```bash |
| 102 | +.specify/scripts/bash/<script-name> |
| 103 | +``` |
| 104 | + |
| 105 | +## Testing Conventions |
| 106 | + |
| 107 | +- Backend tests live in `backend/tests/`, mirroring the `app/` package structure |
| 108 | +- Run with `uv run pytest` from the repo root or `backend/` directory |
| 109 | +- Frontend tests are colocated (`*.test.ts`) alongside source files |
| 110 | +- Run with `bun run test` from `frontend/` |
| 111 | +- Test behavior, not implementation — tests verify what code does, not how |
| 112 | +- Mock only boundaries: network, filesystem, external services |
| 113 | +- Every error path the code handles should have a test |
| 114 | + |
| 115 | +## SpecKit Workflow |
| 116 | + |
| 117 | +This project uses SpecKit for structured feature development. The phases are: |
| 118 | +`/speckit.specify` → `/speckit.clarify` → `/speckit.plan` → `/speckit.tasks` → `/speckit.implement` |
| 119 | + |
| 120 | +Artifacts live in `specs/<feature-id>-<feature-name>/`. |
| 121 | + |
| 122 | +### Retro Gate (mandatory) |
| 123 | + |
| 124 | +After every SpecKit phase command completes (`/speckit.specify`, `/speckit.plan`, |
| 125 | +`/speckit.tasks`, `/speckit.implement`), run `/speckit.retro` before starting |
| 126 | +the next phase. Do not proceed until the retro produces a "Ready" status. |
| 127 | + |
| 128 | +**Micro-retro** (after each task in `/speckit.implement`): |
| 129 | +1. Simplify the code just written |
| 130 | +2. Log anything unexpected to `specs/<feature>/lessons-learned.md` |
| 131 | +3. Check whether `tasks.md`, `plan.md`, or `spec.md` needs updating |
| 132 | +4. Suggest `/clear` before the next task |
| 133 | + |
| 134 | +**Phase retro** (after each phase command): |
| 135 | +1. Summarize what was produced |
| 136 | +2. Review `lessons-learned.md` |
| 137 | +3. Check all earlier artifacts for drift |
| 138 | +4. Propose constitution/rules updates (never self-apply — await human approval) |
| 139 | +5. Confirm readiness gate (5 items) |
| 140 | +6. Suggest `/clear` with specific files to re-read |
| 141 | + |
| 142 | +## Rule Proposal Process |
| 143 | + |
| 144 | +When you receive a correction or discover a pattern worth preserving project-wide, propose a rule change following the process in `.agents/rules/ai-feedback-learning-loop.md`. |
| 145 | + |
| 146 | +Key constraint: **never self-apply rule changes**. Always propose and wait for explicit human approval before modifying any file in `.agents/rules/`. |
| 147 | + |
| 148 | +## SDD Development Workflow |
| 149 | + |
| 150 | +1. **Branch**: Create a feature branch from `master` — `git checkout -b <id>-<short-name>` |
| 151 | +2. **Develop**: Implement the feature; run tests and linter locally before committing |
| 152 | +3. **PR**: Open a pull request against `master` using the PR template in `.github/pull_request_template.md` |
| 153 | +4. **CI**: GitHub Actions runs tests, lint, and automated Claude code review |
| 154 | +5. **Review**: CODEOWNERS auto-requests designated reviewers for affected paths |
| 155 | +6. **Merge**: Merge after CI passes and reviewers approve — no direct pushes to `master` |
| 156 | + |
| 157 | +Changes to `.agents/rules/base.md` require a `Rule-Change-Approval: <ref>` line in the PR description. CI will block the PR if absent. |
0 commit comments