AGENTS.md -- Shelfie

This file is for coding agents working on the Shelfie repo. Humans should read README.md, PLAN.md, RUNBOOK.md, and DEPLOY.md instead.

Identity

Stack

Two modes

SHELFIE_DB_MODE env var:

Every persistence hook (lib/reading.ts, lib/overrides.ts, lib/deletions.ts, lib/book-meta.ts) writes to localStorage and fires a best-effort patchBook(id, ...) to /api/books/[id]. localStorage is the offline cache; the DB is the source of truth in cloud mode.

Key files

Path Purpose
app/library/page.tsx Four-view home (Grid/Spines/Stacks/Table).
app/library/[id]/page.tsx Book detail, server component.
app/scan/page.tsx Live camera capture flow.
app/scan/review/[id]/page.tsx Confidence-banded review (green/yellow/red).
lib/dedupe.ts bookKey(title, author) -- the canonical normalization.
lib/library.ts loadLibrary(libraryId?) -- routes to fixtures or loadLibraryFromDb.
lib/db.ts Supabase clients + loadLibraryFromDb.
lib/sync.ts patchBook / deleteBook client helper that no-ops in local mode.
lib/claude.ts readSpines, readCover, recommendForCluster. Cached system prompts.
supabase/migrations/*.sql Run with npm run migrate.
scripts/seed-cloud.ts One-shot fixture importer for a real Supabase user.

Doing tasks

  1. Read PLAN.md and pick the lowest-numbered open milestone.
  2. If a task is fuzzy, write or update its bullets in PLAN.md first.
  3. Implement.
  4. Add or update tests where they exist (currently sparse).
  5. Run the voice-check on any new prose surfaced to humans.
  6. Update README.md's Status section.
  7. Use eroske@interrel.com as the git author for commits intended to deploy via Vercel CLI -- the team gates by author email.

Don't

Shelfie API for non-human users (in progress)

If you are an agent reading this and you have an API key, the canonical entry points are:

GET  https://shelfiebook.com/api/v1/books             # paginated list
GET  https://shelfiebook.com/api/v1/books/:id
POST https://shelfiebook.com/api/v1/books             # add a book
PATCH https://shelfiebook.com/api/v1/books/:id        # status/rating/notes/etc.
POST https://shelfiebook.com/api/v1/scan              # multipart photo upload
GET  https://shelfiebook.com/api/v1/export?format=csv # also xlsx, bibtex, goodreads

Authenticate with Authorization: Bearer <api_key>. The user owning the key sees only their own libraries.