Skip to content

Commit c54c316

Browse files
lucbrinkmanclaude
andcommitted
Add GitHub Actions CI workflow and update Git workflow documentation
Setup automated CI pipeline that runs on all pushes and PRs: - Type checking with TypeScript - Linting with ESLint - Build verification with Next.js Updated CLAUDE.md to reflect new PR-based workflow: - All changes go through GitHub Pull Requests - Never merge to main locally - Never push main branch directly - CI validates all changes before merge This ensures code quality and establishes a proper CI/CD foundation for the project, even as a solo developer. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 31a1c86 commit c54c316

File tree

2 files changed

+82
-26
lines changed

2 files changed

+82
-26
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: ['**']
8+
9+
jobs:
10+
quality-checks:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Type check
27+
run: npm run type-check
28+
29+
- name: Lint
30+
run: npm run lint
31+
32+
- name: Build
33+
run: npm run build

CLAUDE.md

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
77
Next.js application called "Map of AI Futures" - an interactive probability flowchart visualizing potential AI future scenarios. Users adjust probability sliders to explore how different decisions affect outcome likelihoods.
88

99
**Key Features:**
10+
1011
- Interactive probability sliders with real-time DAG-based calculations
1112
- Zoom and pan canvas navigation
1213
- Supabase authentication (passwordless magic link)
@@ -16,17 +17,20 @@ Next.js application called "Map of AI Futures" - an interactive probability flow
1617
## Development
1718

1819
**Commands:**
20+
1921
- `npm run dev` - Start dev server (http://localhost:3000)
2022
- `npm run build` - Build for production
2123
- `npm run lint` - Run ESLint
2224

2325
**Process Management:**
26+
2427
- **To stop a dev server cleanly:** `fuser -k <port>/tcp` (e.g., `fuser -k 3000/tcp`)
2528
- This kills all processes using that port, including orphaned child processes
2629
- More reliable than KillShell which can leave next-server processes running
2730
- Prevents accumulation of zombie processes that consume CPU/memory
2831

2932
**Environment Variables:**
33+
3034
- `NEXT_PUBLIC_SUPABASE_URL`
3135
- `NEXT_PUBLIC_SUPABASE_ANON_KEY`
3236
- `SUPABASE_SERVICE_ROLE_KEY` (server-side only)
@@ -38,63 +42,78 @@ Next.js application called "Map of AI Futures" - an interactive probability flow
3842
**Important:** This repository uses **multiple worktrees** - the user may be working in different directories on different branches simultaneously.
3943

4044
**Worktree Safety Rule:**
45+
4146
- **NEVER** make edits to files in any worktree other than the one Claude Code was started in
4247
- Only read from, write to, and execute commands within the current working directory
4348
- If the user needs changes in a different worktree, they will navigate there and start a new session
4449

4550
**Development Model:**
46-
- Solo developer project - no GitHub PRs or code review process
47-
- Merge feature branches to main locally, then push to GitHub
48-
- Direct push workflow: test locally → merge to main → push
4951

50-
**Branch Merging Protocol:**
51-
**IMPORTANT:** Only merge to main when the user explicitly says it's time to merge. Do not automatically merge or test for merging during development - features may need multiple iterations before being ready.
52+
- Solo developer project using GitHub Pull Request workflow
53+
- All changes go through PRs with automated CI checks
54+
- Work on feature branches → push to GitHub → create PR → merge via GitHub UI
55+
- **NEVER merge to main locally**
56+
- **NEVER push main branch directly**
5257

53-
When the user says to merge a feature branch to main, ALWAYS follow this sequence:
58+
**Pull Request Workflow:**
59+
60+
1. **Create and push feature branch:**
5461

55-
1. **First, update the feature branch with main:**
5662
```bash
57-
git checkout feature-branch
58-
git merge main
59-
# Resolve any conflicts HERE on the feature branch, never on main
63+
git checkout -b feature-branch
64+
# Make your changes and commit
65+
git push origin feature-branch
6066
```
6167

62-
2. **Test after merging:**
63-
- Clear the Next.js cache: `rm -rf .next`
64-
- Start dev server: `npm run dev`
65-
- Verify it runs without errors before proceeding
68+
2. **Create Pull Request:**
69+
- Use GitHub UI or `gh pr create` command
70+
- CI automatically runs type-check, lint, and build
71+
- PR cannot be merged until all CI checks pass
6672

67-
3. **Only then, merge to main using fast-forward only:**
68-
```bash
69-
git checkout main
70-
git merge --ff-only feature-branch
71-
# If this fails, return to step 1 - there are unresolved issues
72-
git push origin main
73-
```
73+
3. **Merge via GitHub:**
74+
- Once CI passes and changes are ready, merge via GitHub PR interface
75+
- Delete feature branch after merging (can be done automatically)
76+
- Pull latest main locally: `git checkout main && git pull origin main`
77+
78+
**CI/CD Pipeline:**
79+
80+
- GitHub Actions workflow runs on all pushes and PRs (`.github/workflows/ci.yml`)
81+
- Checks: TypeScript type-check, ESLint, Next.js build
82+
- PRs blocked from merging if CI fails
83+
- Local pre-commit hooks run same checks (via Husky) to catch issues early
84+
85+
**Branch Protection (configure in GitHub settings):**
86+
87+
- Require PR reviews before merging (optional for solo dev)
88+
- Require status checks to pass (CI workflow)
89+
- Require branches to be up to date before merging
7490

7591
**Key Rules:**
76-
- NEVER merge to main unless the user explicitly says to merge
77-
- NEVER resolve merge conflicts while on `main` branch
78-
- ALWAYS use `--ff-only` when merging into main (ensures clean, conflict-free merge)
79-
- ALWAYS test the dev server after merging but before pushing
80-
- If user says "merge to main", first update feature branch with main, then merge to main
92+
93+
- NEVER merge to main locally - always use GitHub PRs
94+
- NEVER push main branch directly - only push feature branches
95+
- Let CI validate all changes before merging
96+
- If CI fails, fix issues and push updates to the PR branch
8197

8298
## Architecture
8399

84100
### Core System
85101

86102
**Probability Engine:**
103+
87104
- **DAG Structure** (`lib/graphData.ts`, `graphData.json`): Nodes (question/start/outcome types) and edges with conditional probabilities
88105
- **Calculation** (`lib/probability.ts`): Recursive probability propagation with memoization. Question nodes (21 total) use slider values to control YES/NO branch probabilities
89106
- **URL State** (`lib/urlState.ts`): Slider values encoded as `?p=50i70i25i...` (integers separated by 'i')
90107

91108
**Unified Document Storage:**
109+
92110
- Single `documents` table replaces old `saved_scenarios` and `user_graphs` tables
93111
- Each document contains: graph nodes, slider values, metadata (all in one JSONB field)
94112
- Auto-save with 2-second debounce for authenticated users
95113
- localStorage fallback for anonymous users with auto-migration on signup
96114

97115
**Authentication:**
116+
98117
- Supabase passwordless magic link (`lib/supabase/`)
99118
- Server actions in `lib/actions/documents.ts`
100119
- Custom `useAuth` hook (`hooks/useAuth.ts`) with localStorage migration logic
@@ -113,23 +132,27 @@ When the user says to merge a feature branch to main, ALWAYS follow this sequenc
113132
### Important Implementation Details
114133

115134
**Node Interaction:**
135+
116136
- Clicking a node sets it as probability root (recalculates all probabilities from that point)
117137
- Clicking same node again resets to start node
118138
- Slider hover highlights corresponding flowchart node
119139

120140
**Edge Rendering:**
141+
121142
- Uses refs to track actual DOM node bounds for accurate arrow positioning
122143
- Adjusts for zoom scale when calculating edge paths
123144
- Adaptive opacity/width based on probability values
124145

125146
**State Management:**
147+
126148
- Auto-save hook (`lib/autoSave.ts`) with 2-second debounce for cloud saves
127149
- localStorage (`lib/documentState.ts`) for anonymous user drafts
128150
- Document state unified: graph structure, slider values, node positions all in one
129151
- `useMemo` for probability calculations to prevent unnecessary recomputation
130152
- Undo stack tracks slider history
131153

132154
**Storage Flow:**
155+
133156
- **Anonymous users**: Changes save instantly to localStorage
134157
- **Authenticated users**: Changes auto-save to cloud (debounced)
135158
- **On signup**: localStorage draft automatically migrates to cloud as "My First Map"

0 commit comments

Comments
 (0)