Skip to content

Commit 7611f83

Browse files
harleyMinhchau0108
andauthored
Add AGENTS guidelines (#99)
## Summary - add root `AGENTS.md` with coding and testing instructions ## Testing - `pnpm lint` - `pnpm test:run` - `pnpm test:e2e` *(fails: browsers not installed)* ------ https://chatgpt.com/codex/tasks/task_b_6841494b8bf8832b9aa5e4dbc1601d5d ## Summary by Sourcery Add a new AGENTS.md file to define repository-wide development standards and procedures Documentation: - Introduce AGENTS.md with coding conventions, React component guidelines, and commit message formats - Include instructions for linting with pnpm lint and testing with Vitest and Playwright - Document additional setup notes for E2E tests via MCP server and Supabase hybrid approach <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Added a comprehensive AGENTS.md file with development guidelines, testing instructions, commit conventions, and documentation standards for the Pulse web application. - Updated CLAUDE.md to CLAUDE Development Notes with streamlined guidance, simplified commands, and high-level architectural and testing overviews. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Minhchau0108 <minhchau3315@gmail.com>
1 parent dde10eb commit 7611f83

File tree

2 files changed

+69
-63
lines changed

2 files changed

+69
-63
lines changed

AGENTS.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# AGENTS Instructions
2+
3+
This repository contains a Next.js 15 web application called **Pulse**. It uses Supabase for authentication and database storage, Tailwind CSS for styling, and shadcn/ui components.
4+
5+
Codex should also read `CLAUDE.md` in the repository root for extended architecture and workflow details.
6+
7+
## Scope
8+
These instructions apply to the entire repository.
9+
10+
## Development Guidelines
11+
- Use TypeScript for all source code.
12+
- Prefer functional React components and hooks.
13+
- Use the utility `cn` from `src/lib/utils.ts` to compose CSS class names.
14+
- UI components should follow the shadcn/ui style (see `components.json`).
15+
- Keep new code and tests within the `src/` directory structure.
16+
- Start the development server with `pnpm dev` and build with `pnpm build`.
17+
- Manage Supabase locally with:
18+
- `supabase start` – start local instance
19+
- `supabase stop` – stop local instance
20+
- `supabase status` – check status
21+
- `supabase db reset` – reset database **(destroys local data, confirm before running)**
22+
23+
## Linting and Formatting
24+
- Run `pnpm lint` before committing to ensure ESLint rules pass.
25+
26+
## Testing
27+
- Unit tests use **Vitest**. Run them with `pnpm test:run`.
28+
- End-to-end tests use **Playwright** and require a local Supabase instance and the MCP server. Run them with `pnpm test:e2e`.
29+
- Additional helpers: `pnpm test:e2e:debug` and `pnpm test:coverage`.
30+
- If tests fail due to environment limitations (e.g. missing dependencies), note this in the PR.
31+
32+
## Commit Messages
33+
Use short descriptive commit messages, for example:
34+
```
35+
feat: add weekly submission API
36+
docs: update README with setup steps
37+
```
38+
39+
## Additional Notes
40+
- E2E tests must drive the browser via the MCP server as described in `docs/prompt-work-with-playwright-mcp.md`.
41+
- For Supabase-related tests, see `docs/supabase-in-test.md` for the hybrid approach using mocks and a local instance.
42+
- Consult `docs/test-plan.md` and `docs/implementation.md` for deeper explanations.
43+
- `CLAUDE.md` contains extended documentation for human contributors.
44+
- Keep documentation updates in the `docs/` directory when adding new features.

CLAUDE.md

Lines changed: 25 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,42 @@
1-
# CLAUDE.md
1+
# CLAUDE Development Notes
22

3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3+
This document contains extended guidance for working on Pulse. Codex will also use these instructions for additional context.
44

5-
## Development Commands
5+
## Local Development Workflow
66

7-
**Development workflow:**
8-
```bash
9-
pnpm dev # Start dev server with Turbopack
10-
pnpm build # Build for production
11-
pnpm lint # Run ESLint
12-
```
7+
- Install dependencies with `pnpm install`.
8+
- Start the application locally with `pnpm dev`.
9+
- Build for production with `pnpm build`.
1310

14-
**Database management:**
15-
```bash
16-
supabase start # Start local Supabase
17-
supabase stop # Stop local Supabase
18-
supabase db reset # Reset local database (CONFIRM BEFORE RUNNING)
19-
supabase status # Check Supabase status
20-
```
21-
22-
**Testing commands:**
23-
```bash
24-
pnpm test # Run unit tests in watch mode
25-
pnpm test:run # Run unit tests once
26-
pnpm test:coverage # Run unit tests with coverage
27-
pnpm test:e2e # Run Playwright E2E tests
28-
pnpm test:e2e:ui # Run E2E tests with UI mode
29-
pnpm test:e2e:debug # Run E2E tests in debug mode
30-
```
11+
### Supabase Local
12+
- `supabase start` &mdash; start the local Supabase instance.
13+
- `supabase stop` &mdash; stop the instance when not needed.
14+
- `supabase status` &mdash; check whether Supabase is running.
15+
- `supabase db reset` &mdash; **destroys local data. Confirm before running.**
3116

3217
## Architecture Overview
3318

34-
### Application Structure
35-
- **Next.js 15 App Router** with route groups: `(authenticated)` for protected routes, `admin` for admin-only areas
36-
- **Supabase local development** - always confirm before running `supabase db reset` as it resets the database
37-
- **Multi-step form flow** orchestrated by `WeeklyPulseForm` with screen-based progression
38-
- **Dynamic questions system** with versioned questions supporting multiple types (text, textarea, number, multiple_choice, checkbox)
19+
Pulse uses Next.js 15 with the App Router. Key route groups are `(authenticated)` for user views and `admin` for administrative pages. Supabase authentication works on both the server and API routes through helper clients in `src/lib/supabase` (`server.ts`, `api.ts`, `middleware.ts`).
20+
21+
Submissions are collected via the multi-step `WeeklyPulseForm`. Questions are versioned so that historical submissions retain their original questions. Track the time from `startTime` to form completion for analytics purposes.
22+
23+
## Testing Tools
3924

40-
### Authentication & Authorization
41-
- **Supabase SSR authentication** with three client types:
42-
- Server: `/utils/supabase/server.ts` for server components
43-
- API: `/utils/supabase/api.ts` for API routes
44-
- Middleware: `/utils/supabase/middleware.ts` for route protection
45-
- **Two-tier access control**: authenticated users vs admin users (`is_admin` flag)
46-
- **Middleware-based route protection** in `/src/middleware.ts`
25+
- Unit tests: `pnpm test:run`
26+
- Coverage: `pnpm test:coverage`
27+
- End-to-end tests: `pnpm test:e2e` (requires MCP and local Supabase)
28+
- Debugging E2E tests: `pnpm test:e2e:debug`
4729

48-
### Database Schema
49-
- **Versioned questions**: Questions use `parent_id` self-reference with version incrementing
50-
- **Submission windows**: Friday 5PM opens → Monday 2PM due → Tuesday 5PM late cutoff
51-
- **JSONB storage**: `additional_projects` in submissions, `answers` in submission_answers
52-
- **Hierarchical data**: Comments with `parent_id`, questions with versioning
30+
## Important Notes
5331

54-
### Form Architecture
55-
- **Screen components** in `/src/components/screens/` with consistent interfaces
56-
- **Question-to-screen mapping**: Categories map to specialized screens (e.g., `primaryProject``ProjectSelectionScreen`)
57-
- **Dynamic question rendering** falls back by question type
58-
- **Form data structure**: Core submission data + `answers` object keyed by question ID
32+
- Follow modern Next.js 15 patterns (server actions, file-based routing).
33+
- Form validation occurs at the UI, API layer, and database constraints.
34+
- Refer to `docs/test-plan.md` for the full testing strategy and `docs/implementation.md` for architecture details.
5935

60-
### Testing Strategy
61-
- **Unit tests**: Vitest with React Testing Library and jsdom
62-
- **E2E tests**: Playwright with automatic dev server setup
63-
- **Test utilities**: Supabase mocks in `/src/test-utils/`
6436

6537
### Key Business Logic
66-
- **Week calculations**: ISO week numbers with `date-fns` for consistency
38+
6739
- **Auto-sharing**: Submissions auto-shared with managers for NEXT_PUBLIC_COMPANY_EMAIL_DOMAIN emails
6840
- **Streak calculation**: Configurable start week with exclusions for holidays
6941
- **Late submission detection**: Based on submission window timing
7042

71-
### Component Patterns
72-
- **Screen components**: Follow props pattern `{onNext, onBack, formData, setFormData, error}`
73-
- **Admin components**: Modular structure in `/src/components/admin/`
74-
- **UI components**: Radix UI-based components in `/src/components/ui/`
75-
76-
### Important Notes
77-
- Always use Next.js 15 latest practices, not older patterns
78-
- Supabase local development - confirm before database resets
79-
- Form validation happens at multiple levels: form, API, and database
80-
- Time tracking from `startTime` to completion for analytics

0 commit comments

Comments
 (0)