Skip to content

Commit 6936f5c

Browse files
Development environment setup (#1474)
* docs(config): add cursor cloud specific instructions to AGENTS.md * docs(AGENTS): update development instructions in AGENTS.md for clarity and best practices * docs(AGENTS): expand development instructions in AGENTS.md with detailed quick start guide, module aliases, and troubleshooting tips --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 711790d commit 6936f5c

2 files changed

Lines changed: 100 additions & 34 deletions

File tree

.cursorrules/development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ yarn install --frozen-lockfile --network-timeout 300000
2222
### Environment Configuration
2323

2424
```bash
25-
cp packages/backend/.env.example packages/backend/.env
25+
cp packages/backend/.env.local.example packages/backend/.env
2626
```
2727

2828
Edit `packages/backend/.env` with your credentials.

AGENTS.md

Lines changed: 99 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,120 @@
11
# Compass Calendar Development Instructions
22

3-
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
3+
Primary instructions for AI agents and developers in the Compass monorepo.
4+
5+
## Quick Start
6+
7+
1. `yarn install --frozen-lockfile --network-timeout 300000` (takes ~3.5 min, do not cancel)
8+
2. `cp packages/backend/.env.local.example packages/backend/.env`
9+
3. `yarn dev:web` (frontend on http://localhost:9080/)
10+
11+
## Table of Contents
12+
13+
- [Compass Calendar Development Instructions](#compass-calendar-development-instructions)
14+
- [Quick Start](#quick-start)
15+
- [Table of Contents](#table-of-contents)
16+
- [Key Guidelines](#key-guidelines)
17+
- [Module Aliases](#module-aliases)
18+
- [Working Effectively](#working-effectively)
19+
- [Initial Setup](#initial-setup)
20+
- [Development Servers](#development-servers)
21+
- [Testing](#testing)
22+
- [Writing Tests in `@compass/web`](#writing-tests-in-compassweb)
23+
- [Running Tests](#running-tests)
24+
- [Building](#building)
25+
- [Linting](#linting)
26+
- [Validation](#validation)
27+
- [Project Structure](#project-structure)
28+
- [Packages Overview](#packages-overview)
29+
- [Key Files \& Directories](#key-files--directories)
30+
- [Environment Requirements](#environment-requirements)
31+
- [Required for Full Development](#required-for-full-development)
32+
- [Optional Services](#optional-services)
33+
- [Critical Environment Variables (backend/.env)](#critical-environment-variables-backendenv)
34+
- [Common Tasks \& Timing](#common-tasks--timing)
35+
- [Repository Operations](#repository-operations)
36+
- [Development Workflow](#development-workflow)
37+
- [Styling](#styling)
38+
- [CI/CD Integration](#cicd-integration)
39+
- [Troubleshooting](#troubleshooting)
40+
- [Common Issues](#common-issues)
41+
- [Network Limitations](#network-limitations)
42+
- [Workarounds](#workarounds)
43+
- [Package Scripts Reference](#package-scripts-reference)
44+
- [Root Level Commands](#root-level-commands)
45+
- [Naming Conventions](#naming-conventions)
46+
- [Branch Naming \& Commit Message Conventions](#branch-naming--commit-message-conventions)
47+
- [Semantic Branch Naming](#semantic-branch-naming)
48+
- [Semantic Commit Messages](#semantic-commit-messages)
49+
- [Pre-commit Validation](#pre-commit-validation)
50+
- [Gotchas](#gotchas)
451

552
## Key Guidelines
653

754
1. When working in `packages/web`, follow React best practices and idiomatic patterns
855
2. When working in `packages/backend` or `packages/core`, follow Node.js best practices and idiomatic patterns
956
3. Always use module aliased paths for imports when importing Compass modules.
57+
4. Prefer the simplest solution to a problem over the more complex solutions.
58+
59+
## Module Aliases
60+
61+
Use these aliases instead of relative paths:
62+
63+
- **Backend, scripts, core** (see root `package.json` `_moduleAliases`):
64+
- `@compass/backend``packages/backend/src`
65+
- `@compass/core``packages/core/src`
66+
- `@compass/scripts``packages/scripts/src`
67+
- **Web** (see `packages/web/tsconfig.json` paths):
68+
- `@web/*``packages/web/src/*`
69+
- `@core/*``packages/core/src/*`
70+
71+
Example: `import { foo } from '@compass/core'` not `import { foo } from '../../../core'`
1072

1173
## Working Effectively
1274

1375
### Initial Setup
1476

1577
- Install dependencies: `yarn install --frozen-lockfile --network-timeout 300000`
16-
- Takes ~3.5 minutes. NEVER CANCEL. Set timeout to 10+ minutes.
17-
- Copy environment template: `cp packages/backend/.env.example packages/backend/.env`
78+
- Takes ~3.5 minutes. Set timeout to 10+ minutes.
79+
- Copy environment template: `cp packages/backend/.env.local.example packages/backend/.env`
1880

1981
### Development Servers
2082

21-
- **CRITICAL**: The backend requires external service credentials (Google OAuth, Supertokens, MongoDB) to run properly
22-
- **Web Development** (RECOMMENDED for coding):
23-
- `yarn dev:web` - Takes ~10 seconds to build. Serves on <http://localhost:9080/>
83+
- **Web Development**:
84+
- yarn dev:web - Takes ~10 seconds to build. Serves on http://localhost:9080/
2485
- Frontend works standalone without backend services
25-
- **Backend Development** (requires full setup):
86+
- **Backend Development**:
2687
- `yarn dev:backend` - Fails without proper .env configuration
27-
- Needs: Google Cloud OAuth credentials, Supertokens account, MongoDB connection
2888

2989
### Testing
3090

31-
### Writing Tests in `@compass/web`
91+
Run `yarn test:core`, `yarn test:web`, and `yarn test:backend` after making changes. Use `yarn test:scripts` for scripts package tests. Avoid `yarn test` (full suite) in restricted network environments—MongoDB binary download may fail.
92+
93+
#### Writing Tests in `@compass/web`
3294

3395
- Write tests the way a user would use the application by using the DOM and user interactions with `@testing-library/user-event` rather than internal implementation details of React components.
3496
- Do NOT use `data-` attributes or CSS selectors to locate elements. Use semantic locators and roles instead.
3597
- When writing tests, avoid mocking as much as possible.
3698
- Where mocking is inevitable, use spies to sub out specific module functions before attempting to mock the whole module.
99+
- **DO NOT** attempt to test login functionality without proper backend setup.
37100

38101
#### Running Tests
39102

40-
- **Core tests**: `yarn test:core` - Takes ~2 seconds. NEVER CANCEL. Always tests pass.
41-
- **Web tests**: `yarn test:web` - Takes ~15 seconds. NEVER CANCEL. All tests pass
42-
- **Full test suite**: `yarn test` - Takes ~18 seconds but FAILS in restricted environments due to MongoDB binary download from fastdl.mongodb.org
43-
- Use individual package tests instead: `yarn test:core` and `yarn test:web`
44-
- **DO NOT** attempt to test login functionality without proper backend setup
45-
- **ALWAYS** run `yarn test:core` and `yarn test:web` and `yarn test:backend` after making changes
103+
- **Core tests**: `yarn test:core`
104+
- **Web tests**: `yarn test:web`
105+
- **Backend tests**: `yarn test:backend`
106+
- **Scripts tests**: `yarn test:scripts`
107+
- **Full test suite**: `yarn test` (may fail if MongoDB binary download is blocked)
46108

47109
### Building
48110

49-
- **CLI Tool**: `yarn cli --help` - Takes ~3 seconds. Lists all available commands.
50111
- **Web Build**: `yarn cli build web --environment staging --clientId "test-client-id"`
51112
- **Node Build**: `yarn cli build nodePckgs --environment staging`
52113
- Both builds require valid environment configuration
53114

54115
### Linting
55116

56-
- `yarn prettier . --write` - Takes ~15 seconds. NEVER CANCEL.
117+
- `yarn prettier . --write` - Takes ~15 seconds.
57118

58119
## Validation
59120

@@ -74,7 +135,7 @@ This is a Typescript project with a monorepo structure.
74135

75136
### Key Files & Directories
76137

77-
```
138+
```text
78139
packages/backend/src/
79140
├── auth/ # Google OAuth integration
80141
├── calendar/ # Google Calendar API
@@ -132,17 +193,18 @@ TZ=Etc/UTC
132193

133194
### Repository Operations
134195

135-
- `yarn install` - 3.5 minutes (NEVER CANCEL, set 10+ minute timeout)
136-
- `yarn test:core` - 2 seconds (all pass)
137-
- `yarn test:web` - 15 seconds (all pass)
138-
- `yarn test:backend` - 15 seconds (all pass)
139-
- `yarn dev:web` - 10 seconds to start (always works)
140-
- `yarn cli --help` - 3 seconds (shows available commands)
196+
- `yarn install` - 3.5 minutes
197+
- `yarn test:core` - ~2 seconds (all pass)
198+
- `yarn test:web` - ~15 seconds (all pass)
199+
- `yarn test:backend` - ~15 seconds (all pass)
200+
- `yarn test:scripts` - scripts package tests
201+
- `yarn dev:web` - ~10 seconds to start
202+
- `yarn cli --help` - ~3 seconds (shows available commands)
141203

142204
### Development Workflow
143205

144206
1. **Start Development**: `yarn dev:web` (frontend only, always works)
145-
2. **Run Tests**: `yarn test:core && yarn test:web` (skips problematic backend tests)
207+
2. **Run Tests**: `yarn test:core && yarn test:web` (add `&& yarn test:backend` when credentials available)
146208
3. **Check Code Style**: `yarn prettier . --write`
147209
4. **Manual Validation**: Open <http://localhost:9080/> and verify login page loads
148210

@@ -155,17 +217,13 @@ TZ=Etc/UTC
155217
### CI/CD Integration
156218

157219
- GitHub Actions runs `yarn install` and `yarn test`
158-
- Tests fail in CI due to MongoDB network restrictions (known limitation)
159-
- Linting and build validation happens in CI pipeline
160220

161221
## Troubleshooting
162222

163223
### Common Issues
164224

165-
- **MongoDB download failures**: Use `yarn test:core` and `yarn test:web` instead of `yarn test`
166-
- **Backend won't start**: Missing environment variables, use web-only development
167-
- **Build timeouts**: All build operations need 10+ minute timeouts
168-
- **Test failures**: Expected in restricted network environments
225+
- **Test failures**: Run `yarn test:core`, `yarn test:web`, and `yarn test:backend` individually to narrow the scope of the failure
226+
- **Backend won't start**: Missing environment variables in `packages/backend/.env`, use web-only development (`yarn dev:web`)
169227

170228
### Network Limitations
171229

@@ -188,6 +246,8 @@ TZ=Etc/UTC
188246
- `yarn test` - Run all tests (fails in restricted environments)
189247
- `yarn test:core` - Run core package tests only
190248
- `yarn test:web` - Run web package tests only
249+
- `yarn test:backend` - Run backend package tests only
250+
- `yarn test:scripts` - Run scripts package tests only
191251

192252
Always prioritize frontend development with `yarn dev:web` when backend services are unavailable.
193253

@@ -200,9 +260,9 @@ Always prioritize frontend development with `yarn dev:web` when backend services
200260

201261
### Semantic Branch Naming
202262

203-
**ALWAYS** create branches following this pattern based on the GitHub issue:
263+
**ALWAYS** create branches following this pattern:
204264

205-
- `type/action-issue-number` (e.g., `copilot/fix-spinner`, `feature/add-form`, `bug/fix-auth`)
265+
- `type/action[-issue-number]` (e.g., `feature/add-form`, `bug/fix-auth`, `bug/fix-auth-123`)
206266

207267
**Branch Type Prefixes:**
208268

@@ -273,3 +333,9 @@ The repository includes Husky hooks that will:
273333
- Run `yarn prettier . --write` on pre-push (ensures consistent formatting)
274334

275335
**ALWAYS** ensure your commits pass these checks before pushing.
336+
337+
## Gotchas
338+
339+
- Environment: Copy from `packages/backend/.env.local.example` to `packages/backend/.env` (there is no `.env.example`).
340+
- Webpack dev server warns about a missing `.env.local` file; this is harmless—it falls back to `process.env`.
341+
- Husky pre-push hook runs `yarn prettier . --write`, which can modify files. Ensure working tree is clean or committed before pushing.

0 commit comments

Comments
 (0)