3.3 KiB
3.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Development Commands
Frontend Development
pnpm dev- Start development mode with hot reloadpnpm build- Build the application for productionpnpm typecheck- Run TypeScript type checkingpnpm format- Format code with Prettierpnpm format:check- Check code formatting without making changes
Backend Development (Rust)
cd src-tauri && cargo fmt- Format Rust codecd src-tauri && cargo clippy- Run Rust linter/analyzercd src-tauri && cargo test- Run Rust tests
Build Commands
pnpm tauri build- Build production application bundlepnpm tauri build --debug- Build debug version
Architecture Overview
This is a Tauri 2.0 desktop application that manages Claude Code and Codex provider configurations. The application uses a hybrid architecture:
Frontend (React + TypeScript)
- Location:
src/directory - Framework: React 18 with TypeScript, Vite build system, TailwindCSS 4.x
- Key Components:
App.tsx- Main application component with routing logiccomponents/- UI components including modals, forms, and provider managementlib/tauri-api.ts- Centralized API layer for all Tauri command callstypes.ts- TypeScript type definitions for Provider, Settings, etc.
Backend (Rust)
- Location:
src-tauri/src/directory - Key Modules:
lib.rs- Main entry point, tray menu system, and application setupcommands.rs- Tauri command handlers (API endpoints)config.rs- Configuration file management (reads/writes JSON configs)provider.rs- Provider management logic and switching operationsstore.rs- Application state management with Mutex protectionmigration.rs- Handles migration from legacy configurationsvscode.rs- VS Code integration for automatic config sync
Data Flow Architecture
The application follows a Single Source of Truth (SSOT) pattern:
- Centralized Config: All provider data stored in
~/.cc-switch/config.json - Live Config Files:
- Claude Code:
~/.claude/settings.json - Codex:
~/.codex/auth.json+~/.codex/config.toml
- Claude Code:
- Switching Process: Copy from centralized config → live config files
- Atomic Operations: Uses atomic writes with rollback for configuration safety
System Integration
- System Tray: Dynamic menus that reflect current provider states
- VS Code Integration: Automatic sync with VS Code Codex plugin settings
- Cross-Platform: Windows (MSI installer), macOS (app bundle), Linux (deb/AppImage)
- Updates: Built-in updater system for automatic application updates
State Management
- Frontend: React hooks and context for UI state
- Backend:
AppStatestruct with Mutex-protected shared state - IPC: Tauri commands for frontend-backend communication
- Events: Event system for real-time updates (provider switching, etc.)
Project Structure Notes
- Configuration presets are defined in
src/config/providerPresets.tsandsrc/config/codexProviderPresets.ts - The application supports both portable and installed modes
- Icons and assets are stored in
src-tauri/icons/with platform-specific variants - The build system uses Vite with React plugin and TailwindCSS integration