This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
CrossPaste is a Kotlin Multiplatform application using Gradle. Key commands:
- Run the application:
./gradlew app:run - Build:
./gradlew build - Run tests:
./gradlew test - Code formatting:
./gradlew ktlintFormat - Code style check:
./gradlew ktlintCheck - Run single test:
./gradlew test --tests "ClassName.testMethodName"
First startup downloads JBR (JetBrains Runtime) and gradle dependencies automatically.
- Desktop multiplatform app: Built with Compose Multiplatform and Kotlin
- Database: SQLite with SQLDelight for type-safe queries
- Networking: Ktor for client/server communication with custom encryption
- UI: Compose Multiplatform with Material 3 design
- DI: Koin for dependency injection across modules
CrossPaste is a cross-platform product covering Desktop (this repo) and Mobile (Android/iOS, separate private repos). The commonMain code is designed to be shared across both Desktop and Mobile platforms — it gets copied to the mobile projects. When modifying commonMain code, always consider mobile compatibility: avoid desktop-only APIs, keep interfaces platform-agnostic, and ensure changes won't break mobile consumers.
app/src/commonMain/kotlin/: Shared business logic across Desktop and Mobile platformsapp/src/desktopMain/kotlin/: Desktop-specific implementationsapp/src/desktopTest/kotlin/: Desktop platform testsapp/src/commonMain/sqldelight/: Database schema definitions
The application follows a modular architecture defined in CrossPasteModule.kt:
- appModule(): Core application services and managers
- sqlDelightModule(): Database layer and DAOs
- networkModule(): Client/server networking with encryption
- securityModule(): Cryptographic services and secure storage
- pasteTypePluginModule(): Handlers for different clipboard data types
- pasteComponentModule(): Clipboard monitoring and processing
- uiModule(): UI components and screen providers
- viewModelModule(): ViewModels for UI state management
- Dependency Injection: Koin modules organize services by domain
- Repository Pattern: DAOs abstract database operations
- Plugin Architecture: Extensible paste type handlers (text, images, files, etc.)
- Platform Abstraction: Common interfaces with platform-specific implementations
- Secure Communication: End-to-end encryption for cross-device sync
SQLDelight manages database schema in .sq files:
PasteDatabase.sq: Main paste item storagePasteTaskDatabase.sq: Background task managementSecureDatabase.sq: Encrypted data storageSyncRuntimeInfoDatabase.sq: Device synchronization state
- macOS: Swift integration via
MacosApi.swiftcompiled to dylib - Windows/Linux: JNA for native API access
- Global shortcuts: Platform-specific keyboard listeners
- System tray: Cross-platform tray implementation
- macOS: Xcode tools required for Swift compilation
- All platforms: JBR is automatically downloaded to
jbr/directory - Proxy configuration: Available in
gradle.propertiesfor restricted networks
- Tests use MockK for mocking
- Platform-specific test utilities in
desktopTest/ - System property
appEnv=TESTis set automatically during test runs
- Commit messages: Use emoji prefixes (see
doc/en/CommitMessage.md) - Code formatting: Enforced via ktlint with exclusions for generated code
- Package structure: Organized by feature domain under
com.crosspaste - Platform files: Use
.desktop.ktsuffix for platform-specific implementations - Utility usage: Always check
com.crosspaste.utilsand prefer existing utility classes (e.g., FileUtils, DateUtils, StringUtils) instead of implementing new ones.
- Encryption: Asymmetric encryption for secure device-to-device communication
- Discovery: mDNS/Bonjour for local network device discovery
- Storage: Local-only architecture with no cloud dependencies
- Performance: Coroutines for async operations, caching for clipboard history
Before attempting to compile or build the project, always run ./gradlew ktlintFormat first. If the command fails with errors, investigate and fix the issues. If it succeeds and modifies files, understand that the changes are purely stylistic and semantically equivalent to the original code — do not treat reformatted code as something that needs review or further modification.
Format: <emoji code> <description>
Types:
- ✨ new feature
- 🐛 Bug fix
- 🔨 Refactoring
- 📝 docs
- 🎨 code style
- ⚡ performance
- ✅ test
- 👷 build/ci
- ➕ add dependency
- ➖ remove dependency
- ⬆️ dependency upgrade
- ⬇️ dependency downgrade
Examples from this project:
- ✨ add OCR support for images
- 🐛 resolve navigation crash on back press
- 🔨 extract SwipeableDeviceRow component
- 👷 bump kotlin to 2.0.0
Language: English for commit messages