Skip to content
Toolkit

AGENTS.md — Canonical AI Agent Instructions

This file is the single source of truth for all AI agent guidance in this repository. CLAUDE.md, GEMINI.md, and any other agent-specific files must only reference this file — never duplicate it.

Per-service detail lives in apps/api/AGENTS.md (backend) and apps/web/AGENTS.md (frontend).


1. Project context

  • Project: Cardsite, the presence platform, carried to launch in one repository: API, web, Apple apps, marketing site, design system, product toolkit, GCP staging.
  • Type / stage: Application · Production (single tracker: ROADMAP.md; see ADR-0004).
  • Stack: Go 1.25 (Chi, pgx/v5) + React 19 (Vite, TypeScript, Studio 2.4 — OKLCH tokens generated from design/studio/DESIGN.md, TanStack Query v5) + PostgreSQL 16 + optional Redis 7.
  • Architecture: docs/ARCHITECTURE.md
  • Key commands: docs/DEVELOPMENT.md or make help.

2. Working conventions

  • Read before writing. Consult ROADMAP.md, README.md, and the relevant /docs and per-service AGENTS.md before making changes.
  • Update ROADMAP.md at the end of every working session: what was completed, what is in progress, what is blocked, next steps.
  • Session logs stay short. A SESSION.md Completed entry is ≤ 8 lines and links the ADR/PR/archive-register row that carries the narrative. Long-form findings belong in ADRs and the archive register, never in the log.
  • Conventional Commits for all commit messages (see CONTRIBUTING.md).
  • Record significant decisions as ADRs in docs/decisions/ using the template.
  • Single source of truth. Never duplicate documentation; link to it. The map of what is canonical where is in docs/guides/documentation.md, which also fixes document headers, the five-word status vocabulary, and what a ticked checkbox asserts.
  • Run substantial work as a job (workstream) under .station/jobs/NNN-slug/, per docs/guides/workstream.md; SESSION.md keeps the eight WORK headings and a Status: line, and station check holds it. ROADMAP.md answers "what is the state of the product"; a workstream's SESSION.md answers "what is the state of this work". Never copy between them.
  • Recurring (routine) runs are @work, the agent module at .station/modules/work-agent/ .station/modules/work-agent/README.md; its routine is .station/modules/work-agent/routines/job.md — the loop is inspect → implement → validate → document → update roadmap → archive, one item per PR. The active workstream's ROUTINE.md fixes the claim protocol (an atomic claim/* ref before any code), the read budget, the verify budget (npm run verify once, at the end) and the output budget. A run never answers an owner decision (ROADMAP → DEFERRED) and never invents scope: an empty NEXT list is reported, not filled.
  • A debt marker names a record that outlives it. TODO(003):, FIXME(ADR-0066):, HACK(#480): — the attribution is an ADR in docs/decisions/, a track directory under .station/jobs/, or a pull request number, so a reader gets from the code to the reasoning. The bare form and XXX/WIP are refused by npm run check:debt; the reasoning stays in the record, never in the comment (ADR-0140).
  • Product vocabulary is decided once in docs/GLOSSARY.md and used identically in code, UI, API and docs. No surface coins a user-facing term on its own.
  • Delete what is superseded (ADR-0178). The change that replaces something deletes it and names the replacement in the commit message; git history is the archive. Nothing goes into .archives/removal-safe/.
  • Keep the root minimal. The root is the Station shape plus what the ecosystem expects there; every deliberate difference is listed in docs/guides/station.md.

3. Project rules & non-negotiables

  • All changes go through PRs against main. Branch as feat/*, fix/*, or chore/*.
  • Migrations are never auto-run by the binary. Add new migrations at the next free number (stated once, at the top of ROADMAP.md; check apps/api/migrations/ before trusting it) with a matching .down.sql and apply them manually with psql. Never renumber or edit the SQL of an applied migration. CI's migration-lint job enforces sequential numbering and up/down pairing.
  • Backend layering is strict: handler → repository → database. No business logic in handlers; handlers declare narrow consumer-side store interfaces so tests stay DB-free.
  • Frontend never hardcodes colors/spacing. Every value is a Studio 2.4 token (generated from design/studio/DESIGN.md; studio/ 1.2 names now resolve to 2.x values, ADR-0179, ADR-0181). New and converted UI uses @aidenlive/studio-react 2.4; pages not yet converted still use @csxbase/studio-react 1.2 and move one whole page at a time (migration table). Domain components Studio does not own live in apps/web/src/components/; no raw HTML inputs/buttons with ad-hoc styles.
  • No secrets in the repository. Configuration comes from .env (.env.example documents the baseline; docs/DEPLOYMENT.md has the full table).
  • API responses always use the models.APIResponse envelope ({data, meta, error}); breaking API changes ship under a new prefix (/api/v2/), never in place.
  • Server state on the frontend is a ratchet (ADR-0005): new pages and new fetches use TanStack Query hooks in apps/web/src/hooks/queries/ with keys from apps/web/src/lib/queryKeys.ts; all mutations (including in legacy pages) invalidate the relevant resource keys; legacy useEffect+services reads migrate when a change touches a page's data flow.

4. Design principles

  • Prefer boring, well-understood technology; the stack is intentionally portable (no framework lock-in).
  • Optimize for readability and long-term maintainability over cleverness.
  • One canonical place per concept — in code, docs, and configuration.
  • Cross-runtime vocabularies follow ADR-0030: identity vocabularies are packages generated from one data file; runtime data is served by an endpoint; Go modules are compiled and composed, never dynamically loaded.
  • Degrade gracefully: optional dependencies (Redis, S3, AI keys, gateways) must never be required for the core to run.

5. Validation before committing

npm run verify                                     # the merge gate: studio build/lint,
                                                   # 29 parity gates, web unit tests, web build
npm run check:station                              # station check, Level 2 (layout, jobs, content, tokens)
cd apps/api && go vet ./... && go test ./...       # additionally, when apps/api changed

Merge policy: local npm run verify green and every CI check green on the pull request. Actions runs on hosted runners; a red check is root-caused, never re-run to see, never skipped or quarantined. The policy is stated once, in ROADMAP.md → Standing policy.

CI (.github/workflows/ci.yml) runs seven jobs; the seventh, station, runs station check and the public/ drift check. The six the product owns: Go (vet, test with -race against migrated Postgres 16, staticcheck), Frontend (tsc, unit tests, build), E2E (Playwright, the stub suite and the live suite against a real API), migration lint, OpenAPI coverage, and Studio (build, lint, dist staleness, then the whole of npm run verify). What each parity gate holds is described beside it in the workflow and in the ADR the gate cites. Run the live suite locally with npm run test:e2e:live in apps/web (docs/DEVELOPMENT.md).

Monorepo layout

apps/api (Go) · apps/web (React, Studio 1.2 runtime) · apps/apple (SwiftUI, XcodeGen) · apps/marketing (Astro) · apps/toolkit (the product toolkit, static) · design/studio (Studio 2.4, the canonical specification) · design/icons · design/brand-kit · studio/ (Studio 1.2 runtime for the web, and the Apple app's StudioKit) · packages/ (shared) · shared/ (contracts/openapi.yaml) · infra/ (GCP staging) · deploy/ (self-hosted production) · docs/ (brand/, gtm/, guides/, decisions/) · public/ · .archives/ · .station/ (see .station/README.md, ADR-0004, ADR-0161, ADR-0176).

Launch rules (job 013)

  1. Facts come from docs/brand/. A plan, price, limit, domain or claim on any surface — web, Apple, marketing, toolkit — is the Overview's; copy follows the Marketing guide's guardrails.
  2. Studio 2.4 decides how things look (ADR-0175; 2.4 carries the walkthrough's kinds, tokens and words, ADR-0181). Rule 2 above still binds apps/web to studio/; a new surface is built on design/studio. npm run check:studio-convergence fails on new drift.
  3. The nested packages keep their lockfiles. Install design/studio, design/icons and apps/marketing with npm ci --prefix <dir>; never add them to the root workspaces (ADR-0176).
  4. Staging is deployed by CI, not by hand (ADR-0177). Migrations run as the cardsite-migrate job; nobody runs psql against the staging database. No secret, seeded password or service-account key enters the repository or a workflow log.
  5. Apple code is not compiled here. Never claim a Swift build or test passed unless the macOS CI run says so (docs/guides/apple.md).
  6. make validate is the whole gate; npm run verify stays the web and registry half of it.
  7. Clean UI, progressive disclosure (owner, 2026-11-22). A screen shows the one thing it is for; everything else waits behind one control (a menu, a filter button with a count, a disclosure, a sheet). Never a wall of chips or buttons that wraps onto a second line; never a control row that wraps at 390 px. If options do not fit one line, they belong in a menu. Applies to web, Apple, marketing and the toolkit.
  8. Apple work follows apps/apple/docs/APPLE-GUIDELINES.md (owner, 2026-11-22).

Non-negotiables

  1. ROADMAP.md is the single source of truth for progress. Update it at the end of every session. Do not add a second tracker — this repository previously had two and they disagreed with each other and with the code. Its DEFERRED section is the owner's; a session lists a decision there with options and a recommendation and never answers it.
  2. Studio 2.4 is canonical for UI (ADR-0175, ADR-0179, ADR-0181). Tokens come from design/studio/DESIGN.md and nowhere else; web, Apple (StudioKit 2.4), marketing, Icons and the toolkit all read them. If Cardsite needs a component Studio lacks, build it in design/studio with its spec entry, then consume it. Never fork or copy the design system.
  3. Read studio/docs/for-developers/interaction-patterns.md before building any create or edit surface. Drawer vs editor page vs modal is a product-level decision and it is already made: every resource kind is created and edited in the one editor workspace (/resources/edit/:kind/:id, ADR-0181, job 014); a drawer is only for records that are not resource kinds (domains, projects, pixels, signatures, uploads, PWAs, payment processors, admin records).
  4. Everything is a link. Add link types to @csxbase/link-model, never to a hardcoded list in a page. CI enforces parity with the Go registry.
  5. Preview payload == save payload. Build both from one object.
  6. One copy of everything. Superseded code, docs and assets are deleted in the change that replaces them (ADR-0178); no second copy, no "old" folder, no alternative kept "just in case".
  7. If a control ships, it works. Nothing user-visible may be merged wired to nothing.

Run npm run verify before committing; merge on local green and green CI.

Source: AGENTS.md

Library