@@ -4,7 +4,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44
55## Project Overview
66
7- GSD Task Manager is a privacy-first Eisenhower matrix task manager built with Next.js 15 App Router. All data is stored locally in IndexedDB via Dexie, with JSON export/import for backups. The app is a PWA that works completely offline.
7+ GSD Task Manager is a privacy-first Eisenhower matrix task manager built with Next.js 16 App Router. All data is stored locally in IndexedDB via Dexie, with JSON export/import for backups. The app is a PWA that works completely offline.
8+
9+ ** v5.0.0 Features:**
10+ - ** Optional Cloud Sync** — End-to-end encrypted multi-device sync via Cloudflare Workers (OAuth with Google/Apple)
11+ - ** MCP Server Integration** — AI-powered task management through Claude Desktop with natural language queries
12+ - ** Zero-Knowledge Architecture** — Worker stores only encrypted blobs; decryption happens locally
813
914## Core Commands
1015
@@ -123,6 +128,59 @@ Quadrant logic lives in `lib/quadrants.ts` with `resolveQuadrantId()` and `quadr
123128- ` public/sw.js ` - Service worker for offline caching
124129- ` components/pwa-register.tsx ` - Client component that registers SW on mount
125130
131+ ### Cloud Sync Architecture (Optional, v5.0.0)
132+ - ** Backend** : Cloudflare Workers + D1 (SQLite) + KV + R2
133+ - ** Authentication** : OAuth 2.0 with Google and Apple (OIDC-compliant)
134+ - ** Encryption** : AES-256-GCM with PBKDF2 key derivation (600k iterations)
135+ - ** Multi-Environment** : Dev, staging, prod with isolated databases and secrets
136+ - ** Sync Protocol** : Vector clock-based conflict resolution with cascade sync
137+ - ** Zero-Knowledge** : Worker stores only encrypted blobs + metadata, cannot decrypt task content
138+
139+ ** Key Files** :
140+ - ` worker/src/index.ts ` - Main Worker entry point with API routes
141+ - ` worker/src/routes/ ` - API endpoints for auth, sync, devices
142+ - ` worker/src/db/ ` - D1 database queries and migrations
143+ - ` lib/sync/ ` - Client-side sync logic with encryption (frontend)
144+
145+ ** API Endpoints** :
146+ - ` /api/auth/login/:provider ` - OAuth initiation
147+ - ` /api/auth/callback/:provider ` - OAuth callback
148+ - ` /api/sync/push ` - Upload encrypted task changes
149+ - ` /api/sync/pull ` - Fetch encrypted task updates
150+ - ` /api/sync/status ` - Sync health check
151+ - ` /api/devices ` - Device management
152+
153+ ### MCP Server Architecture (v5.0.0)
154+ - ** Purpose** : Enable Claude Desktop to access and analyze tasks via natural language
155+ - ** Location** : ` packages/mcp-server/ ` - Standalone npm package
156+ - ** Runtime** : Node.js 18+ with TypeScript
157+ - ** Communication** : stdio transport (JSON-RPC 2.0) with Claude Desktop
158+ - ** Security** : Read-only access, decryption happens locally on user's machine
159+
160+ ** Key Modules** :
161+ - ` packages/mcp-server/src/index.ts ` - MCP server entry point, tool registration
162+ - ` packages/mcp-server/src/crypto.ts ` - Encryption/decryption using Node.js Web Crypto API
163+ - ` packages/mcp-server/src/tools.ts ` - API client and 6 MCP tool implementations
164+
165+ ** Available MCP Tools** :
166+ 1 . ` list_tasks ` - List decrypted tasks with optional filtering (quadrant, status, tags)
167+ 2 . ` get_task ` - Get detailed task information by ID
168+ 3 . ` search_tasks ` - Search across titles, descriptions, tags, subtasks
169+ 4 . ` get_sync_status ` - Check sync health and storage usage
170+ 5 . ` list_devices ` - View all registered devices
171+ 6 . ` get_task_stats ` - Get task statistics and metadata
172+
173+ ** Configuration** : Claude Desktop config at ` ~/Library/Application Support/Claude/claude_desktop_config.json ` with:
174+ - ` GSD_API_BASE_URL ` - Worker API URL (https://gsd.vinny.dev )
175+ - ` GSD_AUTH_TOKEN ` - JWT token from OAuth flow (7-day expiration)
176+ - ` GSD_ENCRYPTION_PASSPHRASE ` - User's passphrase for local decryption
177+
178+ ** Security Model** :
179+ - Encryption passphrase stored only in Claude Desktop config (never in cloud)
180+ - End-to-end encryption maintained (Worker cannot decrypt tasks)
181+ - Read-only access (Claude cannot modify, create, or delete tasks)
182+ - Opt-in feature (requires explicit passphrase configuration)
183+
126184## Testing Guidelines
127185- Place UI tests in ` tests/ui/ ` , data logic in ` tests/data/ `
128186- Use ` @testing-library/react ` and ` @testing-library/jest-dom ` for component tests
@@ -274,6 +332,71 @@ Quadrant logic lives in `lib/quadrants.ts` with `resolveQuadrantId()` and `quadr
274332 - Search filters to relevant tasks only
275333 - Clear visual feedback for selected dependencies
276334
335+ ## Feature Highlights (v5.0.0)
336+
337+ ### OAuth Cloud Sync
338+ - ** End-to-End Encryption** : AES-256-GCM with PBKDF2 key derivation (600k iterations, OWASP 2023)
339+ - ** Zero-Knowledge Architecture** : Worker stores only encrypted task blobs; cannot decrypt task content
340+ - ** OAuth Authentication** : Secure login with Google or Apple (OIDC-compliant)
341+ - ** Multi-Device Sync** : Vector clock-based synchronization across unlimited devices
342+ - ** Conflict Resolution** : Automatic cascade sync for concurrent edits with manual resolution UI
343+ - ** Device Management** : View, manage, and revoke access for specific devices
344+ - ** Session Management** : JWT tokens with 7-day expiration and refresh flow
345+
346+ ** Implementation Details** :
347+ - ` worker/src/index.ts ` - Cloudflare Worker with Hono router
348+ - ` worker/src/routes/auth.ts ` - OAuth login, callback, registration, salt endpoints
349+ - ` worker/src/routes/sync.ts ` - Push, pull, status endpoints with vector clock logic
350+ - ` worker/src/routes/devices.ts ` - Device listing and management
351+ - ` worker/src/db/ ` - D1 database queries with prepared statements
352+ - ` lib/sync/ ` - Frontend sync client with encryption (AES-GCM wrapper)
353+ - Multi-environment deployment: dev (` localhost:3000 ` ), staging (` gsd-dev.vinny.dev ` ), prod (` gsd.vinny.dev ` )
354+
355+ ** Security Features** :
356+ - Encryption salt stored encrypted in D1 (useless without user's passphrase)
357+ - PBKDF2 with 600,000 iterations (OWASP 2023 recommendation)
358+ - Nonce per encryption operation (96-bit random)
359+ - JWT tokens signed with HS256 (256-bit secret per environment)
360+ - Rate limiting via KV (100 requests/minute per IP)
361+ - CORS restrictions (only allow origin: https://gsd.vinny.dev in prod)
362+
363+ ### MCP Server for Claude Desktop
364+ - ** Natural Language Task Access** : Query tasks with plain English ("What are my urgent tasks this week?")
365+ - ** 6 MCP Tools** : list_tasks, get_task, search_tasks, get_sync_status, list_devices, get_task_stats
366+ - ** Local Decryption** : Encryption passphrase stored only in Claude Desktop config (never in cloud)
367+ - ** Read-Only Access** : Claude cannot modify, create, or delete tasks (safe exploration)
368+ - ** Privacy-Preserved** : End-to-end encryption maintained throughout (Worker → MCP → Claude)
369+
370+ ** Implementation Details** :
371+ - ` packages/mcp-server/src/index.ts ` - MCP server using ` @modelcontextprotocol/sdk `
372+ - ` packages/mcp-server/src/crypto.ts ` - Node.js Web Crypto API port of client-side crypto
373+ - ` packages/mcp-server/src/tools.ts ` - API client with fetch + JWT auth, tool handlers
374+ - stdio transport (JSON-RPC 2.0) spawned by Claude Desktop
375+ - Stateless tool calls (no persistent state, ephemeral decryption)
376+
377+ ** Usage Examples** :
378+ - "What are my urgent tasks?" → Uses ` list_tasks ` with filter
379+ - "Find tasks about the quarterly report" → Uses ` search_tasks `
380+ - "How many tasks do I have in Q2?" → Uses ` list_tasks ` + analysis
381+ - "Check my sync status" → Uses ` get_sync_status `
382+
383+ ** Configuration** : Claude Desktop config JSON with environment variables:
384+ ``` json
385+ {
386+ "mcpServers" : {
387+ "gsd-taskmanager" : {
388+ "command" : " npx" ,
389+ "args" : [" -y" , " @gsd/mcp-server" ],
390+ "env" : {
391+ "GSD_API_BASE_URL" : " https://gsd.vinny.dev" ,
392+ "GSD_AUTH_TOKEN" : " eyJ..." ,
393+ "GSD_ENCRYPTION_PASSPHRASE" : " user's passphrase"
394+ }
395+ }
396+ }
397+ }
398+ ```
399+
277400## Development Notes
278401- Changes to task schema require updating fixtures in ` lib/schema.ts ` , export/import logic, and test fixtures in ` tests/ `
279402- Database migrations handled in ` lib/db.ts ` - current version is 6 (v1→v6: tags/subtasks→filters→notifications→dependencies)
@@ -298,4 +421,21 @@ Quadrant logic lives in `lib/quadrants.ts` with `resolveQuadrantId()` and `quadr
298421 - Use ` useViewTransition() ` hook for client-side navigation with smooth View Transitions API
299422 - The hook automatically adds trailing slashes to routes (required for static export with trailingSlash: true)
300423 - View transitions only work in Chrome/Edge 111+, Safari 18+ (gracefully degrades in Firefox)
424+ - Cloud Sync (v5.0.0):
425+ - ** Worker Deployment** : Use ` npm run deploy:all ` in ` worker/ ` to deploy to dev, staging, prod
426+ - ** Environment Setup** : Run ` ./worker/scripts/setup-{env}.sh ` to create D1, KV, R2 resources
427+ - ** Migrations** : Use ` npm run migrations:{env} ` to apply D1 schema changes
428+ - ** Secrets** : Set OAuth client IDs, secrets, JWT secret per environment via ` wrangler secret put `
429+ - ** Testing** : Use ` ./worker/test-*.sh ` scripts for manual API testing with curl
430+ - ** JWT Tokens** : Expire after 7 days; frontend should handle refresh flow (401 → re-auth)
431+ - ** Encryption** : Never log or expose encryption salts or passphrases in Worker code
432+ - MCP Server (v5.0.0):
433+ - ** Location** : All MCP code in ` packages/mcp-server/ ` (standalone package)
434+ - ** Building** : Run ` npm run build ` in ` packages/mcp-server/ ` before testing
435+ - ** Testing** : Configure Claude Desktop with local ` node dist/index.js ` for development
436+ - ** Tools** : Add new MCP tools in ` tools.ts ` following existing pattern (schema + handler)
437+ - ** Security** : MCP tools must be read-only; never implement write operations without user consent
438+ - ** Decryption** : Use ` CryptoManager ` singleton from ` crypto.ts ` for all decryption
439+ - ** Error Handling** : Provide clear error messages (e.g., "Token expired" vs generic "Auth failed")
440+ - ** Documentation** : Update ` packages/mcp-server/README.md ` when adding new tools
301441- Always leverage @coding-standards .md for coding standards and guidelines
0 commit comments