Skip to content

Commit 629d1f3

Browse files
Alex Fernandezclaude
andcommitted
Add agentic development infrastructure (001-agentic-tooling)
- Agent rule files (.agents/rules/) for AI onboarding, feedback loop, and coding standards - GitHub Actions workflows for automated Claude code review and rule governance gate - Shared Claude tool permissions (.claude/settings.json) and SpecKit skill commands - PR template, CODEOWNERS, and SpecKit scripts/templates (.specify/) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4c63a66 commit 629d1f3

42 files changed

Lines changed: 5754 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# AI Feedback Learning Loop
2+
3+
> Documents the process for AI agents to propose rule changes and await human approval. Prevents silent rule drift between sessions.
4+
5+
## When to Propose a Change
6+
7+
Propose a rule change when any of the following happen:
8+
9+
- A human corrects your approach during development and the correction is worth preserving project-wide
10+
- You discover a pattern, constraint, or convention that recurs across multiple tasks and is not yet captured in `.agents/rules/`
11+
- A tool, command, or workflow behaves differently than what the rules describe
12+
- An accepted convention turns out to be incorrect or outdated
13+
14+
Do not propose a change for one-off situations specific to a single task.
15+
16+
## Proposal Format
17+
18+
When you identify a change worth proposing, output the following block in your response:
19+
20+
```
21+
## Rule Change Proposal
22+
23+
**Triggered by**: [What correction or learning surfaced this]
24+
**Proposed rule**: [Exact text to add/change/remove in base.md]
25+
**Section**: [Which section of base.md this belongs in]
26+
**Rationale**: [Why this is worth preserving project-wide]
27+
28+
Awaiting human approval before applying.
29+
```
30+
31+
Include this block in-line in your response — do not create a file or modify any `.agents/rules/` file until the human explicitly approves.
32+
33+
## One-at-a-Time Constraint
34+
35+
Only propose one rule change per session. If multiple corrections surface, log them in `specs/<feature>/lessons-learned.md` and propose them one at a time in future sessions after the current proposal is resolved.
36+
37+
## Human Approval Required
38+
39+
AI agents MUST NOT self-apply rule changes. The rule files in `.agents/rules/` are governance documents — changes require human review and explicit approval. This prevents agents from silently shifting project conventions based on in-session learning that may be wrong or context-specific.
40+
41+
Approval means the human explicitly says something like "approved", "apply it", or "go ahead and update base.md". Implicit agreement or lack of objection is not approval.
42+
43+
## How to Apply After Approval
44+
45+
Once a human explicitly approves a rule change:
46+
47+
1. Open `.agents/rules/base.md` (or the relevant rule file)
48+
2. Apply the exact change described in the proposal — no scope creep
49+
3. Open a PR with the change; include `Rule-Change-Approval: <ref>` in the PR description (reference the conversation, issue, or comment where approval was given)
50+
4. CI will verify the approval reference is present before allowing the merge

.agents/rules/base.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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.

.agents/rules/coding-standards.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Coding Standards
2+
3+
> Agreed-upon code quality standards for AI agents to apply consistently across this project.
4+
5+
## Python Standards
6+
7+
**Runtime**: Python 3.10+, managed with `uv`
8+
9+
**Linting and formatting**: `ruff` — run `uv run ruff check .` and `uv run ruff format .`
10+
**Type checking**: `ty` — run `uv run ty check`
11+
12+
**Naming**:
13+
- Modules, functions, variables: `snake_case`
14+
- Classes: `PascalCase`
15+
- Constants: `UPPER_SNAKE_CASE`
16+
17+
**Type annotations**: Required on all non-trivial public functions and methods. Use `from __future__ import annotations` for forward references.
18+
19+
**Import order** (enforced by ruff):
20+
1. Standard library
21+
2. Third-party packages
22+
3. Local application imports
23+
24+
No relative imports (`..`) — use absolute imports only.
25+
26+
**Function size**: Max 100 lines, cyclomatic complexity ≤ 8, max 5 positional parameters.
27+
28+
**Docstrings**: Google-style on non-trivial public APIs. Code should be self-documenting — only add docstrings where the purpose isn't obvious from names and types.
29+
30+
## TypeScript Standards
31+
32+
**Runtime**: Node 22, ESM-only (`"type": "module"` in package.json)
33+
**Package manager**: `bun`
34+
35+
**Linting and formatting**: `oxlint` and `oxfmt`
36+
37+
**tsconfig.json** — enable all strictness flags:
38+
- `strict: true`
39+
- `noUncheckedIndexedAccess: true`
40+
- `exactOptionalPropertyTypes: true`
41+
- `noImplicitOverride: true`
42+
- `noPropertyAccessFromIndexSignature: true`
43+
- `verbatimModuleSyntax: true`
44+
- `isolatedModules: true`
45+
46+
**Naming**:
47+
- Variables, functions: `camelCase`
48+
- Classes, types, interfaces: `PascalCase`
49+
- Constants: `UPPER_SNAKE_CASE`
50+
- Files: `kebab-case.ts`
51+
52+
No relative imports (`../`) across package boundaries — use absolute imports configured via `tsconfig.json` paths.
53+
54+
**Test files**: Colocated as `*.test.ts` alongside source files.
55+
56+
## Testing Principles
57+
58+
**Test behavior, not implementation.** Tests verify what the code does, not how. A refactor that doesn't change behavior must not break tests.
59+
60+
**Test edges and errors, not just the happy path.** Empty inputs, boundary values, malformed data, missing files — bugs live in edges. Every error path the code handles should have a test that triggers it.
61+
62+
**Mock only boundaries.** Mock things that are slow (network, filesystem), non-deterministic (time, randomness), or external services you don't control. Never mock internal application logic.
63+
64+
**Verify tests catch failures.** Break the code, confirm the test fails, then fix. Tests that always pass regardless of implementation are useless.
65+
66+
## Error Handling
67+
68+
**Fail fast with clear, actionable messages.** When something goes wrong, raise immediately with context: what operation failed, what input caused it, and what the caller should do.
69+
70+
**Never swallow exceptions silently.** No bare `except: pass` or `.catch(() => {})`. If an error is genuinely ignorable, add a comment explaining why.
71+
72+
**Include context in error messages**: what operation was attempted, what the unexpected value was, and a suggested fix where possible.
73+
74+
## Comments
75+
76+
**Code should be self-documenting.** Choose names that make the purpose obvious. If a comment explains what the code does, the code probably needs refactoring.
77+
78+
**No commented-out code.** Delete it. Version control exists to recover deleted code.
79+
80+
**Comments explain why, not what.** The only valid use for a comment is to explain a non-obvious decision, a known limitation, or a gotcha that the code cannot express.
81+
82+
**No `<!-- TODO -->` comments in rule files.** Open items go to `tasks.md`.

0 commit comments

Comments
 (0)