|
1 | | -# Repository Guidelines |
| 1 | +# AGENTS.md - Coding Agent Guidelines |
2 | 2 |
|
3 | | -## Project Structure & Module Organization |
4 | | -- Monorepo managed by Turbo. Key paths: |
5 | | - - `apps/web`: React + TypeScript + Vite (assets in `public/`, source in `src/`). |
6 | | - - `apps/api`: ASP.NET Core Web API (`TrendWeight/`), tests in `apps/api/TrendWeight.Tests/`. |
7 | | - - `scripts/`: Docker helpers. `.github/`: CI workflows. `.env.example` for config. |
| 3 | +## Essential Commands (run from root only) |
| 4 | +```bash |
| 5 | +# Development |
| 6 | +npm run dev # Start both frontend/backend via tmuxinator |
| 7 | +npm run -w apps/web dev # Frontend only (port 5173) |
| 8 | +npm run -w apps/api dev # Backend only (port 5199) |
8 | 9 |
|
9 | | -## Steering Docs (Authoritative) |
10 | | -- Always review and reference `docs/steering/{conventions,tech,product,structure}.md` before proposing changes. |
| 10 | +# Testing |
| 11 | +npm test # All tests |
| 12 | +npm run -w apps/web test # Frontend tests only |
| 13 | +npm run -w apps/api test # Backend tests only |
| 14 | +vitest run path/to/file.test.ts # Single frontend test |
| 15 | +dotnet test --filter "TestName" # Single backend test |
11 | 16 |
|
12 | | -## Build, Test, and Development Commands |
13 | | -- Root (runs across workspaces): |
14 | | - - `npm install`: Install all dependencies. |
15 | | - - `npm run dev`: Start frontend and backend via tmuxinator. |
16 | | - - `npm run build`: Build web and API. |
17 | | - - `npm run check`: Typecheck + lint. `npm test`: Run all tests. |
18 | | - - Preferred validation (run from repo root): `npm run check && npm run test`. |
19 | | - - `npm run docker:build` / `npm run docker:run`: Local Docker image + run. |
20 | | -- Per workspace examples: Web `npm run -w apps/web dev`, `npm run -w apps/web test:coverage`; API `npm run -w apps/api dev`, `npm run -w apps/api test`. |
| 17 | +# Quality checks (MANDATORY before commits) |
| 18 | +npm run check && npm run test # TypeScript + lint + all tests |
| 19 | +npm run check # TypeScript + lint only |
| 20 | +npm run format # Format all code |
| 21 | +``` |
21 | 22 |
|
22 | | -## Coding Style & Naming Conventions |
23 | | -- EditorConfig: 2‑space indent TS/JS, 4‑space C#. |
24 | | -- Web: Prettier + ESLint (see `apps/web/eslint.config.js`), Tailwind 4 with semantic tokens only; always use `@/` alias; components in `PascalCase`; tests `*.test.ts(x)` colocated. |
25 | | -- API: `dotnet format` via lint‑staged; `PascalCase` for types/methods, `camelCase` for locals/params; feature‑oriented folders. |
26 | | - |
27 | | -## Testing Guidelines |
28 | | -- Web: Vitest + Testing Library (`src/test/setup.ts`). Run `npm test` (root) or `npm run -w apps/web test`. |
29 | | -- API: xUnit + FluentAssertions + Moq; integration via `WebApplicationFactory<Program>`. Run `npm test` or `dotnet test`. |
30 | | -- Add tests for new endpoints, hooks, and components; keep fast and deterministic. |
31 | | - |
32 | | -## Commit & Review Guidelines |
33 | | -- Do not open PRs. PRs are created and merged manually by the maintainer. |
34 | | -- Use Conventional Commits: `feat:`, `fix:`, `perf:`, `refactor:`, `deps:`, `chore:` (scopes allowed). Examples: `feat(api): add /api/health`, `refactor(web): replace relative imports with @/`. |
35 | | -- Propose changes via issues referencing relevant sections in `docs/steering/*`; include screenshots for UI changes. |
36 | | -- Before pushing, validate from repo root: `npm run check && npm run test`. |
37 | | -- Never commit secrets. Add new env keys to `.env.example` and document usage. |
38 | | - |
39 | | -## Security & Config Tips |
40 | | -- Configure Clerk and Supabase via `.env` (see README). Keep `AllowedHosts` strict in production. Rate limiting is enabled per user on API. |
| 23 | +## Code Style & Conventions |
| 24 | +- **Frontend**: 2-space indent, kebab-case files, PascalCase components, `@/` imports (never `../`) |
| 25 | +- **Backend**: 4-space indent, PascalCase public members, camelCase locals/params |
| 26 | +- **Routes**: Minimal (<30 lines), NO logic/hooks, delegate to components |
| 27 | +- **Tailwind**: Use semantic variables (`bg-background`) never explicit colors (`bg-gray-500`) |
| 28 | +- **Types**: Strict TypeScript, avoid `any`, functional components with hooks |
| 29 | +- **Tests**: Vitest (frontend) + xUnit (backend), MSW for HTTP mocking, colocated `*.test.ts(x)` |
| 30 | +- **Commits**: Conventional format (`feat:`, `fix:`, `refactor:`), never "BREAKING CHANGE" |
| 31 | +- **Naming**: TrendWeight (capital T+W), snake_case database, kebab-case routes, PascalCase components |
0 commit comments