Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 4.57 KB

AGENTS.md

File metadata and controls

44 lines (31 loc) · 4.57 KB

Repository agent instructions

IMPORTANT: Never override a past decision without approval

A past decision is any choice already made in this repository: behaviour, defaults, UI, architecture, schema, API contracts, dependencies, tooling or conventions. It can be recorded in code, comments, tests, docs, these instruction files, commit messages or merged PRs.

  1. Before changing something that already exists, check why it is that way (comments, docs, tests, git log / git blame, related PRs).

  2. If the change would alter, reverse or remove a past decision, stop before editing and tell the user: what was decided, where it is recorded, what would change and why. If you find the PR or commit that made the decision, reference it (PR number or link, commit hash).

  3. Make the change only after the user explicitly approves it. Silence, or approval of the task in general, is not approval. Each override needs its own approval. Without it, keep the decision and do only the work that does not depend on changing it.

  4. This also applies to bug fixes, refactors and cleanups. If you are unsure whether something was decided on purpose, treat it as decided and ask.

  5. If the developer decides to submit an approved override as a PR, the first line of the PR description must be:

    **Override past decision**: <what was decided before> (<PR or commit, if found>) → <what it is now, and why>

    Never guess a reference: if no PR or commit is found, leave it out and say none was found.

Database schema changes: update every dialect

Mailflare runs on SQLite/D1, PostgreSQL and MySQL from one schema file. Any change to src/db/schema/index.ts (table, column, index, default) must ship a migration for all three dialects in the same change:

  1. npm run db:generate → drizzle/migrations/ (SQLite/D1)
  2. npm run db:generate:pg → drizzle/migrations-pg/ (PostgreSQL)
  3. npm run db:generate:mysql → drizzle/migrations-mysql/ (MySQL/MariaDB)
  4. npm run db:bundle to refresh src/lib/migrations/bundle*.json (commit them).
  5. Touching messages, folders, mailboxes or mailbox_aliases behaviour that SQLite does with triggers (JMAP change log, trashed_at, search index): add the equivalent trigger SQL to a new hand-written PostgreSQL and MySQL migration too.
  6. Run node --test tests/*.test.mjs (tests/database-dialects.test.mjs fails if the dialects diverge or a bundle is stale) and, if a database is available, npm run db:smoke -- <DATABASE_URL>.

Raw SQL must also work on all three dialects; see "The database is D1 unless DATABASE_URL says otherwise" in CLAUDE.md and docs/databases.md. Never edit an already-applied migration; add a new one.

Database backup and restore

  • Whenever a migration creates, renames, or removes a persisted table, update the backup and restore table lists in the same change, even if the feature is unrelated to backups. Review BACKUP_TABLES and INTERNAL_TABLES in src/lib/backups/export.ts, BACKUP_TABLE_GROUPS in src/lib/backups/table-groups.ts, and DatabaseBackupTable in src/lib/backups/types.d.ts.
  • Put every backed-up table in exactly one group. Keep BACKUP_TABLES in foreign-key dependency order so restore inserts parents before children and deletes them in reverse order. Exclude a table only when its contents are derived or internally managed, and document why.
  • When adding a table, check backup and restore behavior both before and after its migration is applied. Keep older full backup documents restorable.

Design system

  • All UI must use components from @/design-system. Icons come from @/components/icons.
  • Any new or edited component must use the @/design-system component wherever one is available. When editing existing UI, replace the raw elements or one-off UI you touch with the matching design system component, even if the surrounding file has not been migrated.
  • Do not write raw <button>, <input>, <textarea> or <select>, and do not import @radix-ui/* outside src/design-system.
  • Do not use raw hex/rgb colours, Tailwind palette colours or arbitrary values for colour, spacing, radius, shadow, type size or z-index. Use the tokens (text-fg-muted, bg-surface, zLayer). No inline styles for token values.
  • Before creating any component, check src/design-system/DESIGN_SYSTEM.md. If nothing fits, extend the design system and that file instead of building one-off UI.
  • src/components/ui/* are compatibility re-exports; add nothing there.
  • vp lint reports violations (design-system/*). Older files warn; migrated files listed in lint.config.ts error. Add a file to that list once you migrate it.