You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolved conflicts:
- Applied Prettier formatting from main
- Preserved type renaming changes (descriptive names vs single letters)
- Integrated ESLint config, CI workflow, and pre-commit hooks from main
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: CLAUDE.md
+56-26Lines changed: 56 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
7
7
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.
8
8
9
9
**Key Features:**
10
+
10
11
- Interactive probability sliders with real-time DAG-based calculations
@@ -16,11 +17,20 @@ Next.js application called "Map of AI Futures" - an interactive probability flow
16
17
## Development
17
18
18
19
**Commands:**
20
+
19
21
-`npm run dev` - Start dev server (http://localhost:3000)
20
22
-`npm run build` - Build for production
21
23
-`npm run lint` - Run ESLint
22
24
25
+
**Process Management:**
26
+
27
+
-**To stop a dev server cleanly:**`fuser -k <port>/tcp` (e.g., `fuser -k 3000/tcp`)
28
+
- This kills all processes using that port, including orphaned child processes
29
+
- More reliable than KillShell which can leave next-server processes running
30
+
- Prevents accumulation of zombie processes that consume CPU/memory
31
+
23
32
**Environment Variables:**
33
+
24
34
-`NEXT_PUBLIC_SUPABASE_URL`
25
35
-`NEXT_PUBLIC_SUPABASE_ANON_KEY`
26
36
-`SUPABASE_SERVICE_ROLE_KEY` (server-side only)
@@ -32,63 +42,79 @@ Next.js application called "Map of AI Futures" - an interactive probability flow
32
42
**Important:** This repository uses **multiple worktrees** - the user may be working in different directories on different branches simultaneously.
33
43
34
44
**Worktree Safety Rule:**
45
+
35
46
-**NEVER** make edits to files in any worktree other than the one Claude Code was started in
36
47
- Only read from, write to, and execute commands within the current working directory
37
48
- If the user needs changes in a different worktree, they will navigate there and start a new session
38
49
39
50
**Development Model:**
40
-
- Solo developer project - no GitHub PRs or code review process
41
-
- Merge feature branches to main locally, then push to GitHub
42
-
- Direct push workflow: test locally → merge to main → push
43
51
44
-
**Branch Merging Protocol:**
45
-
**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**
46
57
47
-
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:**
48
61
49
-
1.**First, update the feature branch with main:**
50
62
```bash
51
-
git checkout feature-branch
52
-
git merge main
53
-
# Resolve any conflicts HERE on the featurebranch, never on main
63
+
git checkout -b feature-branch
64
+
# Make your changes and commit
65
+
git push origin feature-branch
54
66
```
55
67
56
-
2.**Test after merging:**
57
-
- Clear the Next.js cache: `rm -rf .next`
58
-
- Start dev server: `npm run dev`
59
-
- Verify it runs without errors before proceeding
68
+
2.**Create Pull Request:**
69
+
- Use GitHub UI or `gh pr create --repo lucbrinkman/ai-world-model` command
70
+
-**IMPORTANT:** Always create PRs to `lucbrinkman/ai-world-model` (NOT the upstream fork `swantescholz/aifutures`)
71
+
- CI automatically runs type-check, lint, and build
72
+
- PR cannot be merged until all CI checks pass
60
73
61
-
3.**Only then, merge to main using fast-forward only:**
62
-
```bash
63
-
git checkout main
64
-
git merge --ff-only feature-branch
65
-
# If this fails, return to step 1 - there are unresolved issues
66
-
git push origin main
67
-
```
74
+
3.**Merge via GitHub:**
75
+
- Once CI passes and changes are ready, merge via GitHub PR interface
76
+
- Delete feature branch after merging (can be done automatically)
77
+
- Pull latest main locally: `git checkout main && git pull origin main`
78
+
79
+
**CI/CD Pipeline:**
80
+
81
+
- GitHub Actions workflow runs on all pushes and PRs (`.github/workflows/ci.yml`)
- Local pre-commit hooks run same checks (via Husky) to catch issues early
85
+
86
+
**Branch Protection (configure in GitHub settings):**
87
+
88
+
- Require PR reviews before merging (optional for solo dev)
89
+
- Require status checks to pass (CI workflow)
90
+
- Require branches to be up to date before merging
68
91
69
92
**Key Rules:**
70
-
- NEVER merge to main unless the user explicitly says to merge
71
-
- NEVER resolve merge conflicts while on `main` branch
72
-
-ALWAYS use `--ff-only` when merging into main (ensures clean, conflict-free merge)
73
-
-ALWAYS test the dev server after merging but before pushing
74
-
- If user says "merge to main", first update feature branch with main, then merge to main
93
+
94
+
- NEVER merge to main locally - always use GitHub PRs
95
+
-NEVER push main branch directly - only push feature branches
96
+
-Let CI validate all changes before merging
97
+
- If CI fails, fix issues and push updates to the PR branch
75
98
76
99
## Architecture
77
100
78
101
### Core System
79
102
80
103
**Probability Engine:**
104
+
81
105
-**DAG Structure** (`lib/graphData.ts`, `graphData.json`): Nodes (question/start/outcome types) and edges with conditional probabilities
82
106
-**Calculation** (`lib/probability.ts`): Recursive probability propagation with memoization. Question nodes (21 total) use slider values to control YES/NO branch probabilities
83
107
-**URL State** (`lib/urlState.ts`): Slider values encoded as `?p=50i70i25i...` (integers separated by 'i')
84
108
85
109
**Unified Document Storage:**
110
+
86
111
- Single `documents` table replaces old `saved_scenarios` and `user_graphs` tables
87
112
- Each document contains: graph nodes, slider values, metadata (all in one JSONB field)
88
113
- Auto-save with 2-second debounce for authenticated users
89
114
- localStorage fallback for anonymous users with auto-migration on signup
90
115
91
116
**Authentication:**
117
+
92
118
- Supabase passwordless magic link (`lib/supabase/`)
93
119
- Server actions in `lib/actions/documents.ts`
94
120
- Custom `useAuth` hook (`hooks/useAuth.ts`) with localStorage migration logic
@@ -107,23 +133,27 @@ When the user says to merge a feature branch to main, ALWAYS follow this sequenc
107
133
### Important Implementation Details
108
134
109
135
**Node Interaction:**
136
+
110
137
- Clicking a node sets it as probability root (recalculates all probabilities from that point)
0 commit comments