This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Format Swift code:
./format.sh(uses swift-format with project configuration) - Configuration file:
.swift-format(4-space indentation, 140 character line length) - Never let the views or view closures get too large. Extract large subviews into their own struct (which also may increase performance since SwiftUI can reuse those view objects)
- Keep views as small as possible
- The max amount of props should not exceed 4 except for special cases
- Create new files for views
- Use
.map(\.name)instead of.map { $0.name }, i.e., if you want to map over a member use the key path function overload
- Build/run the macOS app: Open
SQL Browser.xcodeprojin Xcode - Target: SQL Browser (macOS application)
- Never build yourself. Ask the user to build the project themselves a provide error messages.
- macOS SQLite Browser: Document-based app for viewing and managing SQLite database files
- SwiftUI: Primary UI framework using WindowGroup and Commands
- SQLite3: Direct SQLite C API integration for database operations
- Document Architecture: Uses FileDocument protocol for SQLite file handling
- SQLBrowserApp: Main app entry point with WindowGroup and FileCommands
- ContentView: Primary UI showing database status and file management
- SQLiteDocument: FileDocument implementation for SQLite file read/write
- FileCommands: Menu commands for creating/opening SQLite databases
- Custom UTTypes: Extensions for .sqlite and .db file type handling
- Database Creation: Creates new SQLite databases using temporary files
- Database Opening: File picker with SQLite validation using sqlite3_open_v2
- File Management: Tracks recent database files and current database
- Document Integration: Full macOS document handling with export/import
- 4-space indentation (configured in
.swift-format) - 140 character line length
- File-scoped access level privacy enabled
- Multiline collection trailing commas
- Ordered imports enforced
- Menu Commands: FileCommands trigger NotificationCenter events
- Event Handling: ContentView responds to createNewSQLiteFile/openSQLiteFile notifications
- File Operations: SQLiteDocument handles FileDocument protocol requirements
- SQLite Validation: Direct C API calls to verify database integrity
- State Management: SwiftUI @State for UI updates and file tracking
- Thread Safety: All database operations must be executed on the main thread
- Transaction Handling: Avoid nested transactions - let DatabaseManager handle transaction management
- SQL Quoting: Use double quotes (") for table and column identifiers, not backticks (`)
- Schema Changes: For complex schema changes (column removal, etc.), use table recreation pattern:
- Backup existing data with SELECT
- DROP TABLE old table
- CREATE TABLE new table with updated schema
- INSERT compatible data back into new table
SQLBrowserApp.swift: Main app entry pointContentView.swift: Primary UI and database interaction logicSQLiteDocument.swift: FileDocument implementation for SQLite filesFileCommands.swift: Menu command definitionsUTType+Extensions.swift: Custom file type definitionsNotification+Extensions.swift: Custom notification namesUpdateTableView.swift: Table schema modification interface