This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Test: deno task test
Sync: deno task sync
Dry Run: deno task dry-run
Check Environment: deno task check
Validate APIs: deno task validate
Setup Guide: deno task setup
Format: deno fmt (configured for 2-space indents, 80-char lines, semicolons)
Lint: deno lint
Available deno tasks:
deno task test - Run unit testsdeno task sync - Run real sync with production datadeno task dry-run - Run sync with real data in dry-run mode (no changes made)deno task check - Check environment configurationdeno task validate - Validate API structure and mock compatibilitydeno task setup - Show Val Town configuration guideThis is a bidirectional sync system between Linear issues and Google Calendar events using the Declarative Reconciliation Loop (DRL) pattern. The system follows a strict Observe → Project → Diff → Actuate cycle.
src/worker.ts): Main orchestrator that coordinates the sync processsrc/projector.ts): Converts external data into canonical itemssrc/diff.ts): Computes operations needed to reach desired statesrc/actuator.ts): Executes operations against external APIssrc/api-clients.ts): Handle Linear and Google Calendar API communicationThe sync operates in 4 phases:
The system recognizes 5 phases with specific transition rules:
| Phase | Description | Triggers |
|---|---|---|
eventOnly | GCal event without Linear match | New calendar event created |
linearOnly | Linear issue without GCal match | Issue marked as "Scheduled" |
active | Linked and syncing | Both systems have records |
completed | Linear marked done/canceled/failed | State change in Linear |
overdue | Past deadline but still active | >24h after event end |
extendedProperties (GCal) and description metadata (Linear)The system expects environment variables:
LINEAR_API_KEY: Linear API tokenLINEAR_TEAM_ID: Linear team identifierGOOGLE_SERVICE_ACCOUNT_JSON: Base64-encoded Google service account JSONGCAL_CALENDAR_ID: Primary calendar IDGCAL_HISTORY_CALENDAR_ID: (Optional) Calendar for overdue itemsTIMEZONE: Timezone for operations (default: America/New_York)All core logic (worker, projector, diff, actuator) has comprehensive unit tests with 31 test cases total. Tests use Deno's built-in test framework with mocked API responses to ensure deterministic behavior.
src/
├── types.ts # Core data models and interfaces
├── projector.ts # Observe → Project (create canonical truth)
├── diff.ts # Project → Diff (compute operations)
├── actuator.ts # Diff → Actuate (execute operations)
├── worker.ts # Main sync orchestrator
├── api-clients.ts # Linear and Google Calendar API clients
├── main.ts # Entry point for sync execution
├── dry-run.ts # Dry run mode for testing
└── *.test.ts # Comprehensive test suite
scripts/
├── check.ts # Environment configuration checker
├── validate.ts # API structure validator
├── setup.ts # Val Town setup guide
├── show-*.ts # Debug scripts for data inspection
├── api-validator.ts # API structure validation
├── val-town-config.ts # Val Town deployment helpers
└── README.md # Script documentation
deno task commands for environment checks, API validation, and testingscripts/ directory for data inspection:
show-gcal.ts - View Google Calendar eventsshow-linear.ts - View Linear issuesshow-canonical.ts - View canonical projectionshow-all.ts - Complete data flow analysisscripts/val-town-config.ts for deployment helpers