mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
4dcf0c3e7e
# Organize Development Documentation into Separate Files This PR reorganizes the development documentation by splitting the monolithic CLAUDE.md file into multiple focused documents. The main file now provides a concise overview with essential commands and critical patterns, while importing detailed content from specialized guides. Key improvements: - Created separate documentation files for specific domains: - Database development patterns - OAuth2 implementation guidelines - Testing best practices - Troubleshooting common issues - Development workflows and guidelines - Restructured the main CLAUDE.md to be more scannable with improved formatting - Added quick-reference tables for common commands - Maintained all existing content while making it more accessible - Highlighted critical patterns that must be followed This organization makes the documentation more maintainable and easier to navigate, allowing developers to quickly find relevant information for their specific tasks.
4.2 KiB
4.2 KiB
Coder Development Guidelines
@.claude/docs/WORKFLOWS.md @.cursorrules @README.md @package.json
🚀 Essential Commands
| Task | Command | Notes |
|---|---|---|
| Development | ./scripts/develop.sh |
⚠️ Don't use manual build |
| Build | make build |
Fat binaries (includes server) |
| Build Slim | make build-slim |
Slim binaries |
| Test | make test |
Full test suite |
| Test Single | make test RUN=TestName |
Faster than full suite |
| Test Postgres | make test-postgres |
Run tests with Postgres database |
| Test Race | make test-race |
Run tests with Go race detector |
| Lint | make lint |
Always run after changes |
| Generate | make gen |
After database changes |
| Format | make fmt |
Auto-format code |
| Clean | make clean |
Clean build artifacts |
Frontend Commands (site directory)
pnpm build- Build frontendpnpm dev- Run development serverpnpm check- Run code checkspnpm format- Format frontend codepnpm lint- Lint frontend codepnpm test- Run frontend tests
Documentation Commands
pnpm run format-docs- Format markdown tables in docspnpm run lint-docs- Lint and fix markdown filespnpm run storybook- Run Storybook (from site directory)
🔧 Critical Patterns
Database Changes (ALWAYS FOLLOW)
- Modify
coderd/database/queries/*.sqlfiles - Run
make gen - If audit errors: update
enterprise/audit/table.go - Run
make genagain - Update
coderd/database/dbmem/dbmem.goin-memory implementations
LSP Navigation (USE FIRST)
- Find definitions:
mcp__go-language-server__definition symbolName - Find references:
mcp__go-language-server__references symbolName - Get type info:
mcp__go-language-server__hover filePath line column
OAuth2 Error Handling
// OAuth2-compliant error responses
writeOAuth2Error(ctx, rw, http.StatusBadRequest, "invalid_grant", "description")
Authorization Context
// Public endpoints needing system access
app, err := api.Database.GetOAuth2ProviderAppByClientID(dbauthz.AsSystemRestricted(ctx), clientID)
// Authenticated endpoints with user context
app, err := api.Database.GetOAuth2ProviderAppByClientID(ctx, clientID)
📋 Quick Reference
Full workflows available in imported WORKFLOWS.md
New Feature Checklist
- Run
git pullto ensure latest code - Check if feature touches database - you'll need migrations
- Check if feature touches audit logs - update
enterprise/audit/table.go
🏗️ Architecture
- coderd: Main API service
- provisionerd: Infrastructure provisioning
- Agents: Workspace services (SSH, port forwarding)
- Database: PostgreSQL with
dbauthzauthorization
🧪 Testing
Race Condition Prevention
- Use unique identifiers:
fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano()) - Never use hardcoded names in concurrent tests
OAuth2 Testing
- Full suite:
./scripts/oauth2/test-mcp-oauth2.sh - Manual testing:
./scripts/oauth2/test-manual-flow.sh
🎯 Code Style
Detailed guidelines in imported WORKFLOWS.md
- Follow Uber Go Style Guide
- Commit format:
type(scope): message
📚 Detailed Development Guides
@.claude/docs/OAUTH2.md @.claude/docs/TESTING.md @.claude/docs/TROUBLESHOOTING.md @.claude/docs/DATABASE.md
🚨 Common Pitfalls
- Audit table errors → Update
enterprise/audit/table.go - OAuth2 errors → Return RFC-compliant format
- dbmem failures → Update in-memory implementations
- Race conditions → Use unique test identifiers
- Missing newlines → Ensure files end with newline
This file stays lean and actionable. Detailed workflows and explanations are imported automatically.