farfield · docs

Farfield Skills

Four .claude/skills/ live in the repository. They encode the patterns and aesthetics that run through every app.

Content Addressing

Give records and files a content-addressed identity — a CIDv1 sha-256 hash of the content itself, computed in-process. This provides verification, change detection, ETag caching, and deduplication with no IPFS node and no network.

Two identifiers

Every mutable record needs both a key and a CID:

Key (slug, id)CID
What it isA stable nameA hash of the content
Changes on edit?NoYes
Reference byThisNever this
Survives edit?YesNo — that is the point

For immutable bytes (uploaded files, snapshots) the CID is the key. There is no separate slug, and GET /blobs/<cid> is safe to cache forever.

Primitive

A CIDv1 is 0x01 (v1) + 0x55 (raw codec) + 0x12 0x20 (sha2-256, 32 bytes) + the digest, base32-encoded with a b multibase prefix. Implemented in lib/cid with the standard library only.

Self-Migrating SQLite

A single-binary service should not need a migration tool, a migrations directory, or a manual "run migrations" step. The database migrates itself: openDB brings any database — fresh or years old — to the current schema, and every step is safe to run on every startup.

The openDB discipline

  1. CREATE TABLE IF NOT EXISTS — builds fresh DBs, no-ops on existing ones.
  2. Renames — before anything reads the new column name.
  3. Added columns — via ensureColumn for tables that already exist.
  4. Backfills — populate new columns for pre-existing rows.

DSN

file:<path>?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)

WAL gives concurrent readers plus one writer; busy_timeout makes writers wait instead of erroring under contention.

Farfield Stack

Scaffold and build Go CRUD web applications in the farfield workspace using the standard library plus exactly one external dependency.

ConcernTool
HTTP servernet/http (http.ServeMux, method routing)
Routinghttp.ServeMux patterns (GET /items/{id})
Databasedatabase/sql + modernc.org/sqlite
Templateshtml/template
Static assetsembed + http.FileServerFS
JSONencoding/json
Authcrypto/subtle, crypto/rand, cookies
Logginglog/slog
Concurrencygoroutines

Shared libraries under lib/ have zero dependencies:

  • lib/auth — password verify, session token, cookie helpers
  • lib/store — env loader, short-ID, session table helpers
  • lib/theme — shared CSS + editor JS, embedded
  • lib/cid — content-addressed identifiers

Farfield Style

Function and form, with function first. The aesthetic borrows from Dieter Rams (Braun), JPL / NASA technical documentation, and Swiss typography — high-contrast monochrome, generous whitespace, ruled dividers, restrained type. Nothing decorative earns its place unless it carries information.

Palette

TokenValueUsage
--surface#fafaf7Page background — slightly warm, paper-like
--ink#0a0a0aAll text, primary rules
--accent#d93a00NASA red — status, callouts; never body text

No gradients. No shadows. No additional colours.

Hierarchy via opacity

LevelOpacityUsage
Primary1.0Headings, body, links
Secondary0.7Labels, captions, meta
Tertiary0.5Timestamps, table headers, footnotes
Muted0.3Placeholders, disabled, empty states

System fonts only. Mono for numerals, codes, identifiers, telemetry — anywhere alignment matters. Sans for prose.