# Project Guidelines ## Protecting This File **IMPORTANT**: This file (CLAUDE.md) can be lost during branch operations! Git doesn't protect untracked/ignored files during `git checkout` or branch switches. Before major git operations: ```bash cp CLAUDE.md CLAUDE.md.backup ``` ## Project Structure This project follows a standardized structure for Tauri desktop apps. ``` ProjectRoot/ ├── CLAUDE.md # AI assistant guidelines ├── README.md # Project documentation ├── build_spec.md # Full project specification ├── build_plan.md # Phased task checklist ├── .gitignore ├── docs/ # Technical documentation │ ├── README.md # Docs index with table of contents │ ├── getting-started.md │ ├── architecture.md │ ├── development.md │ ├── deployment.md │ └── feature-*.md # Feature docs (added per phase) └── app/ # ALL project code lives here ├── build.sh # Build script ├── package.json ├── vite.config.ts ├── tsconfig.json ├── index.html ├── src/ │ ├── main.ts │ ├── App.vue │ ├── boot/ │ │ └── console-logger.ts │ ├── components/ │ ├── composables/ │ ├── css/ │ ├── layouts/ │ ├── pages/ │ ├── router/ │ ├── stores/ │ ├── services/ │ └── types/ └── src-tauri/ ├── Cargo.toml ├── tauri.conf.json ├── icons/ └── src/ └── main.rs ``` ## TeamIDE Project Management If this project was scaffolded from Ideation, `.teamide/` PM files (plans, tasks, project.yml) should already exist — generated from `build_plan.md` during scaffolding. See the Ideation workspace's `claude.md` for the PM generation workflow and format details. ## Terminology - **"build spec"** or **"spec"** refers to `build_spec.md` - the full project description - **"build plan"** or **"plan"** refers to `build_plan.md` - the phased task checklist ## Onboarding Questions (Ask at Project Start) At the start of every new project conversation, gather these details before writing any code: 1. **Brand colors & fonts** - Primary, secondary, accent colors. Typography preferences. Any existing brand guidelines or color palette? 2. **App personality & tone** - Formal or casual? Dark or light default theme? Dense or spacious layout? Any design inspiration or reference apps? 3. **Target platform** - Desktop-first, mobile-first, or responsive? Specific OS targets (macOS, Windows, Linux)? Minimum screen sizes? 4. **Auth requirements** - Login method (email/password, OAuth, magic link)? User roles and permissions? Public or private app? Don't assume defaults for any of these. Ask, get answers, then document them in the Project-Specific Configuration section at the bottom of this file. ## Tech Stack - **Frontend**: Quasar Framework (Vue 3) + Vite - **Desktop**: Tauri (Rust) - Cross-platform builds (macOS, Windows, Linux) - **State**: Pinia - **Routing**: Vue Router - **Backend** (optional): Nhost (self-hosted or cloud) - PostgreSQL - Database - Hasura - GraphQL API - Auth - Authentication service - Storage - File storage - Functions - Serverless functions (Node.js) ## Testing Changes (CRITICAL) **After every code editing session, you MUST rebuild the app so the user can test your changes.** ```bash cd app ./build.sh -dev -open ``` ### Why This Matters - This uses a **build-and-run** approach, not hot reload - Your code changes are NOT visible until you rebuild - Always rebuild before asking the user to test - If the user reports issues, check the logs first: `./build.sh logs` ## Build Script **Always use `build.sh` for building the app.** This ensures consistent builds and logging for collaborative debugging. ```bash cd app ./build.sh -dev -open # Build dev and open app ./build.sh -prod # Build prod to build/prod/ ./build.sh -install # Build prod and open Finder for drag-to-Applications ./build.sh logs # View latest console output (last 100 lines) ./build.sh clean # Clean build artifacts (preserves logs) ./build.sh clean-logs # Remove all logs ``` ### Commands | Command | Description | |---------|-------------| | `-dev` | Development build. Bundle ID: `com.[app].dev` | | `-prod` | Production build. Builds to `build/prod/`. | | `-install` | Build prod and open Finder for drag-to-Applications. | | `-open` | Open the app after building (use with `-dev` or `-prod`) | | `-secure` | Build without automation (no HTTP server on port 9876) | | `logs` | Show last 100 lines of console output | | `clean` | Remove build artifacts (preserves logs) | | `clean-logs` | Remove all log files | ### Why Build-and-Run (No Hot Reload) This project uses a **build-and-run** approach instead of hot reload: | Aspect | Hot Reload | Build-and-Run | |--------|------------|---------------| | Speed | Instant updates | Full rebuild required | | Dev/Prod parity | Different environments | Identical to production | | Debugging | Dev-only issues possible | What you test = what ships | | Logging | Console only | Full logs to files | The tradeoff is slower iteration, but you always test exactly what will ship. ### What the Build Does 1. **Build with Tauri** - `npx tauri build` does all of the following: - Build frontend (`npm run build` → `dist/`) - Build Rust binary with embedded frontend - Create .app bundle in `src-tauri/target/release/bundle/macos/` 2. **Copy to build folder** - Copies bundle to `build/dev/` or `build/prod/` 3. **Update Info.plist** - Sets correct bundle ID for dev/prod 4. **Install (prod only)** - Copies to `~/Applications` **Important**: Using `npx tauri build` ensures the frontend is properly embedded in the binary. Manual `cargo build --release` does NOT embed the frontend. ### Build Output Builds are organized in separate folders: ``` app/build/ ├── dev/ │ └── AppName.app # Dev build (bundle ID: .dev) ├── prod/ │ └── AppName.app # Prod build ├── logs/ │ ├── build_dev_*.log # Build output logs │ └── build_latest.log # Symlink to latest └── console/ ├── console_*.log # App runtime console output └── console_latest.log # Symlink to latest ``` Dev and prod have different bundle IDs, so both can run simultaneously. ### Logging All build output and app console output is logged: - **Build logs**: `build/logs/build_latest.log` - compilation output, errors - **Console logs**: `build/console/console_latest.log` - runtime `console.log()`, errors When debugging, run `./build.sh logs` to see the latest console output. ### Console Logging (Already Configured) This template includes console logging out of the box. Frontend `console.log()` calls are forwarded to Rust and captured in log files. **How it works:** ``` console.log() → console-logger.ts → invoke('log_to_stdout') → Rust println!() → stdout → build.sh logs ``` ## Automation Plugin (Already Configured) This template includes an automation HTTP server for external testing and AI-assisted development. **How it works:** ``` External Tool (curl) → HTTP Server (port 9876) → Rust → JavaScript → DOM ``` ### Automation API When the app is running, these endpoints are available: ```bash # Health check curl http://localhost:9876/automation/health # Execute a command curl -X POST http://localhost:9876/automation/execute \ -H "Content-Type: application/json" \ -d '{"command": "click", "args": {"selector": "#my-button"}}' # Take a screenshot curl http://localhost:9876/automation/screenshot --output screenshot.png ``` ### Available Commands | Command | Args | Description | |---------|------|-------------| | `navigate` | `{path}` | Navigate to route | | `click` | `{selector}` | Click element | | `type` | `{selector, text}` | Type into input | | `getText` | `{selector}` | Get element text | | `getValue` | `{selector}` | Get input value | | `exists` | `{selector}` | Check if element exists | | `waitFor` | `{selector, timeout?}` | Wait for element | | `getUrl` | `{}` | Get current URL | | `screenshot` | - | Capture page (via endpoint) | Full command list in `src/automation/README.md`. ### Disabling Automation **Option 1: Build flag (recommended)** Use the `-secure` flag to build without automation: ```bash ./build.sh -prod -secure # Production build without automation ``` **Option 2: Permanently disable** Remove `automation` from the default features in `Cargo.toml`: ```toml [features] default = ["custom-protocol"] # Remove "automation" ``` ### When to Clean Run `./build.sh clean` when: - Switching between major dependency versions - Build errors reference stale/cached files - Rust compilation issues after Tauri config changes - Before creating a fresh production build ## Node.js Environment **Node.js version**: Always match Debian stable (currently Node.js 18.x for Debian 12 Bookworm) Check current Debian stable Node version: https://packages.debian.org/stable/nodejs **Package manager**: Use npm. Commit lock files for reproducible builds. Rules: - Always commit `package-lock.json` - required for deterministic installs - Never ignore lock files (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`) - Use `npm install` to install dependencies - Use `npm run