Skip to content

Commit 1803449

Browse files
committed
Claude.md initial draft
1 parent 7f056da commit 1803449

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

CLAUDE.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Coder Development Guidelines
2+
3+
## Build/Test/Lint Commands
4+
5+
### Main Commands
6+
7+
- `make build` or `make build-fat` - Build all "fat" binaries (includes "server" functionality)
8+
- `make build-slim` - Build "slim" binaries
9+
- `make test` - Run Go tests
10+
- `make test RUN=TestFunctionName` or `go test -v ./path/to/package -run TestFunctionName` - Test single
11+
- `make test-postgres` - Run tests with Postgres database
12+
- `make test-race` - Run tests with Go race detector
13+
- `make test-e2e` - Run end-to-end tests
14+
- `make lint` - Run all linters
15+
- `make fmt` - Format all code
16+
- `make gen` - Generates mocks, database queries and other auto-generated files
17+
18+
### Frontend Commands (site directory)
19+
20+
- `pnpm build` - Build frontend
21+
- `pnpm dev` - Run development server
22+
- `pnpm check` - Run code checks
23+
- `pnpm format` - Format frontend code
24+
- `pnpm lint` - Lint frontend code
25+
- `pnpm test` - Run frontend tests
26+
27+
## Code Style Guidelines
28+
29+
### Go
30+
31+
- Follow [Effective Go](https://go.dev/doc/effective_go) and [Go's Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)
32+
- Use `gofumpt` for formatting
33+
- Create packages when used during implementation
34+
- Validate abstractions against implementations
35+
36+
### TypeScript/React
37+
38+
- Use TypeScript for all frontend code
39+
- Follow ESLint and Prettier configurations
40+
- Components should be atomic, reusable, and free of business logic
41+
- Modules can contain Coder-specific business logic
42+
43+
### Error Handling
44+
45+
- Use descriptive error messages
46+
- Wrap errors with context
47+
- Propagate errors appropriately
48+
- Use proper error types
49+
- (`xerrors.Errorf("failed to X: %w", err)`)
50+
51+
### Naming
52+
53+
- Use clear, descriptive names
54+
- Abbreviate only when obvious
55+
- Follow Go and TypeScript naming conventions
56+
57+
### Comments
58+
59+
- Document exported functions, types, and non-obvious logic
60+
- Follow JSDoc format for TypeScript
61+
- Use godoc format for Go code
62+
63+
## Commit Style
64+
65+
- Follow [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/)
66+
- Format: `type(scope): message`
67+
- Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
68+
- Keep message titles concise (~70 characters)
69+
- Use imperative, present tense in commit titles
70+
71+
## Database queries
72+
73+
- MUST DO! Any changes to database - adding queries, modifying queries should be done in the `coderd\database\queries\*.sql` files.
74+
- MUST DO! Queries are grouped in files relating to context - e.g. `prebuilds.sql`, `users.sql`, `provisionerjobs.sql`.
75+
- After making changes to any `coderd\database\queries\*.sql` files you must run `make gen` to generate respective ORM changes.
76+
77+
## Architecture
78+
79+
### Core Components
80+
81+
- **coderd**: Main API service connecting workspaces, provisioners, and users
82+
- **provisionerd**: Execution context for infrastructure-modifying providers
83+
- **Agents**: Services in remote workspaces providing features like SSH and port forwarding
84+
- **Workspaces**: Cloud resources defined by Terraform
85+
86+
## Sub-modules
87+
88+
### Template System
89+
90+
- Templates define infrastructure for workspaces using Terraform
91+
- Environment variables pass context between Coder and templates
92+
- Official modules extend development environments
93+
94+
### RBAC System
95+
96+
- Permissions defined at site, organization, and user levels
97+
- Object-Action model protects resources
98+
- Built-in roles: owner, member, auditor, templateAdmin
99+
- Permission format: `<sign>?<level>.<object>.<id>.<action>`
100+
101+
### Database
102+
103+
- PostgreSQL 13+ recommended for production
104+
- Migrations managed with `migrate`
105+
- Database authorization through `dbauthz` package
106+
107+
## Frontend
108+
109+
### Tech Stack
110+
111+
- React with TypeScript
112+
- Material UI v5 for components
113+
- TanStack Query v4 for data fetching
114+
- Emotion for styling
115+
- Formik with Yup for forms and validation
116+
117+
### Structure
118+
119+
- `/site/` directory contains all UI code
120+
- Components in `/site/src/components`
121+
- Feature modules in `/site/src/modules`
122+
- Pages in `/site/src/pages`
123+
124+
### State Management
125+
126+
- React Query for API data fetching and caching
127+
- Context-based state with providers
128+
- React Router for navigation
129+
130+
### Accessibility
131+
132+
- Color contrast meets WCAG AA compliance (4.5:1 ratio)
133+
- Proper labeling for input elements
134+
- Include descriptive text for images
135+
136+
### Testing
137+
138+
- End-to-end testing with Playwright
139+
- Integration testing with Jest and react-testing-library
140+
- Visual testing with Storybook and Chromatic

0 commit comments

Comments
 (0)