Skip to content

Commit 8bf20d0

Browse files
committed
Add AGENTS.md
1 parent de992c3 commit 8bf20d0

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

AGENTS.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Development Commands
6+
7+
### Essential Commands
8+
- **Install dependencies**: `pnpm install`
9+
- **Run tests**: `pnpm test run` (uses Vitest). You can filter with `pnpm test run <file-filters>`. The `run` is important to not trigger watch mode
10+
- **Lint code**: `pnpm lint`. `pnpm lint --fix` will fix some of the linting errors, prefer that over fixing them manually.
11+
- **Type check**: `pnpm typecheck`
12+
13+
#### Extra commands
14+
These commands are usually already called by the user, but you can remind them to run it for you if they forgot to.
15+
- **Build packages**: `pnpm build:packages`
16+
- **Generate code**: `pnpm codegen`
17+
- **Start dependencies**: `pnpm restart-deps` (resets & restarts Docker containers for DB, Inbucket, etc. Usually already called by the user)
18+
- **Run development**: `pnpm dev` (starts all services on different ports. Usually already started by the user in the background)
19+
- **Run minimal dev**: `pnpm dev:basic` (only backend and dashboard for resource-limited systems)
20+
21+
### Testing
22+
You should ALWAYS add new E2E tests when you change the API or SDK interface. Generally, err on the side of creating too many tests; it is super important that our codebase is well-tested, due to the nature of the industry we're building in.
23+
- **Run all tests**: `pnpm test run`
24+
- **Run some tests**: `pnpm test run <file-filters>`
25+
26+
### Database Commands
27+
- **Generate migration**: `pnpm db:migration-gen`
28+
- **Reset database** (rarely used): `pnpm db:reset`
29+
- **Seed database** (rarely used): `pnpm db:seed`
30+
- **Initialize database** (rarely used): `pnpm db:init`
31+
- **Run migrations** (rarely used): `pnpm db:migrate`
32+
33+
## Architecture Overview
34+
35+
Stack Auth is a monorepo using Turbo for build orchestration. The main components are:
36+
37+
### Apps (`/apps`)
38+
- **backend** (`/apps/backend`): Next.js API backend running on port 8102
39+
- Main API routes in `/apps/backend/src/app/api/latest`
40+
- Database models using Prisma
41+
- **dashboard** (`/apps/dashboard`): Admin dashboard on port 8101
42+
- **dev-launchpad**: Development portal on port 8100
43+
- **e2e**: End-to-end tests
44+
45+
### Packages (`/packages`)
46+
- **stack** (`/packages/stack`): Main Next.js SDK
47+
- **stack-shared** (`/packages/stack-shared`): Shared utilities and types
48+
- **stack-ui** (`/packages/stack-ui`): UI components
49+
- **react** (`/packages/react`): React SDK
50+
- **js** (`/packages/js`): JavaScript SDK
51+
52+
### Key Technologies
53+
- **Framework**: Next.js (with App Router)
54+
- **Database**: PostgreSQL with Prisma ORM
55+
- **Testing**: Vitest
56+
- **Package Manager**: pnpm with workspaces
57+
- **Build Tool**: Turbo
58+
- **TypeScript**: Used throughout
59+
- **Styling**: Tailwind CSS
60+
61+
### API Structure
62+
The API follows a RESTful design with routes organized by resource type:
63+
- Auth endpoints: `/api/latest/auth/*`
64+
- User management: `/api/latest/users/*`
65+
- Team management: `/api/latest/teams/*`
66+
- OAuth providers: `/api/latest/oauth-providers/*`
67+
68+
### Development Ports
69+
To see all development ports, refer to the index.html of `apps/dev-launchpad/public/index.html`.
70+
71+
## Important Notes
72+
- Environment variables are pre-configured in `.env.development` files
73+
- Always run typecheck, lint, and test to make sure your changes are working as expected. You can save time by only linting and testing the files you've changed (and/or related E2E tests).
74+
- The project uses a custom route handler system in the backend for consistent API responses
75+
- Sometimes, the typecheck will give errors along the line of "Cannot assign Buffer to Uint8Array" or similar, on changes that are completely unrelated to your own changes. If that happens, stop and tell the user to run `pnpm clean && pnpm i && pnpm run codegen && pnpm build:packages`, and restart the dev server (you cannot run this yourself). After that's done, the typecheck should pass.
76+
- Whenever you learn something new, or at the latest right before you call the `Stop` tool, write whatever you learned into the .claude/CLAUDE-KNOWLEDGE.md file, in the Q&A format in there. You will later be able to look up knowledge from there (based on the question you asked). Note that it's not 100% accurate and you may have to update it later if you find that something is wrong.
77+
78+
### Code-related
79+
- Use ES6 maps instead of records wherever you can.
80+
81+
### Testing-related
82+
- When writing tests, prefer .toMatchInlineSnapshot over other matchers, if possible. You can check (and modify) the snapshot-serializer.ts file to see how the snapshots are formatted and how non-deterministic values are handled.

CLAUDE.md

-3.59 KB
Binary file not shown.

0 commit comments

Comments
 (0)