# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview A statically-linked Zig binary that extracts highlights from Kobo e-reader SQLite databases. The project builds for both x86_64 (development) and ARM (target Kobo device). ## Build Commands ### Local development (x86_64) ```bash zig build ./zig-out/bin/kb_exfiltrator local-dev.sqlite ``` ### Run with arguments ```bash zig build run -- path/to/database.sqlite ``` ### Testing ```bash zig build test ``` ### For Kobo (ARM target) ```bash ./build-kobo.sh # or manually: zig build -Dtarget=arm-linux-musleabihf -Doptimize=ReleaseSmall ``` The ARM build creates `kb_exfiltrator-kobo-arm` in the project root. ## Architecture ### Module Structure The project uses Zig's module system with two distinct modules: - **kb_exfiltrator module** (`src/root.zig`): Library module exposing reusable functionality - **Executable module** (`src/main.zig`): CLI entry point that imports the library module The executable depends on the library module via the imports mechanism in build.zig:87-91. ### SQLite Integration SQLite is vendored as an amalgamation build (vendor/sqlite-amalgamation-3480000/). The build.zig configuration: - Links SQLite as a C source file (build.zig:87-93) - Compiles with `SQLITE_THREADSAFE=0` (no threading, smaller binary) - Compiles with `SQLITE_OMIT_LOAD_EXTENSION` (security) - Uses `@cImport` in main.zig:2-4 to import C headers ### Static Linking The binary is fully statically linked: - Uses musl libc for ARM target (`arm-linux-musleabihf`) - SQLite compiled directly into the binary - No external dependencies required on target device ### Database Schema The program queries the Kobo `Bookmark` table: - `Text`: The highlighted text (non-NULL indicates a highlight) - `Annotation`: User's notes on the highlight (nullable) - `DateCreated`: Timestamp - `ContentID`: Book identifier Query implementation: src/main.zig:33-42 ### Build System Details The build.zig uses Zig's build graph system: - Target and optimization are configurable via CLI (`-Dtarget`, `-Doptimize`) - The executable step (build.zig:60-84) creates the root module and wires dependencies - Tests are split into module tests and executable tests (build.zig:132-154) - Both test suites run in parallel when executing `zig build test` ## Requirements - Zig 0.15.2 or later (specified in build.zig.zon:28)