aboutsummaryrefslogtreecommitdiffstats
path: root/CLAUDE.md
diff options
context:
space:
mode:
Diffstat (limited to 'CLAUDE.md')
-rw-r--r--CLAUDE.md53
1 files changed, 53 insertions, 0 deletions
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 0000000..e54032e
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1,53 @@
1# Claude Flow — Codebase Overview
2
3## What This Is
4
5An Electron desktop app that enforces a **Research → Plan → Implement** workflow for AI-assisted coding, using `@anthropic-ai/claude-agent-sdk`.
6
7## Tech Stack
8
9- **Electron 38** + **Vite** + **React 19** + **TypeScript**
10- **better-sqlite3** — local persistence (projects, sessions, messages)
11- **@anthropic-ai/claude-agent-sdk** — Claude integration
12- **CodeMirror 6** — markdown editor in DocumentPane
13- **react-markdown + remark-gfm** — markdown renderer
14
15## Project Structure
16
17```
18src/main/ # Electron main process
19 claude/ # SDK integration + phase configs
20 db/ # SQLite layer (schema, projects, sessions)
21 ipc/ # IPC channel registrations
22 index.ts # App entry, BrowserWindow
23 preload.ts # contextBridge API surface
24renderer/src/ # React UI
25 App.tsx # Root — all state management
26 components/ # Header, DocumentPane, ChatPane, ActionBar
27 types.ts # Shared TypeScript types
28 styles/ # CSS variables (dark/light themes)
29```
30
31## Key Patterns
32
33### Phase System
34Phases: `research | plan | implement`. Each defined in `src/main/claude/phases.ts` with its own `systemPrompt`, `tools[]`, `permissionMode`, and `initialMessage`. Phase progression is one-way; triggered by user clicking "Submit".
35
36### Artifact Storage
37Session artifacts (`research.md`, `plan.md`) stored inside the target project at `.claude-flow/sessions/{sessionId}/`. This keeps them within the SDK's allowed write boundary (project `cwd`). Add `.claude-flow/` to `.gitignore` to exclude from version control.
38
39### Session Continuity
40Claude SDK session IDs are captured from the `system:init` message and stored in SQLite. Subsequent turns resume the same SDK session (`options: { resume: claude_session_id }`).
41
42### IPC Pattern
43All renderer→main communication goes through named IPC channels registered in `src/main/ipc/handlers.ts`. Streaming events flow back via `mainWindow.webContents.send("claude:message", sessionId, msg)` and are received via `ipcRenderer.on()`.
44
45### Database
46SQLite at `app.getPath("userData")/claude-flow.db`. Tables: `projects`, `sessions`, `messages`. Foreign keys ON, WAL mode enabled.
47
48## Important Notes
49
50- `ANTHROPIC_API_KEY` env var must be set before launching
51- Artifacts are stored in `.claude-flow/sessions/` inside the target project
52- `bypassPermissions` mode is a user-controlled toggle in implement phase only
53- Token usage (from `SDKResultMessage.usage`) is displayed in the ActionBar