Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Rewritting skills following Addy Osmani conventions

Jerome50994177ee09
diff --git a/.claude/skills/e2e-conventions/SKILL.md b/.claude/skills/e2e-conventions/SKILL.md
index ae3bd433..f996e0d3 100644
--- a/.claude/skills/e2e-conventions/SKILL.md
+++ b/.claude/skills/e2e-conventions/SKILL.md
@@ -3,6 +3,11 @@ name: e2e-conventions
description: When to write e2e tests, where to put them, and how to verify them. Apply to any task touching UI, filters, forms, or interactions.
---
+# E2E Conventions
+
+Reference for *whether* an e2e test is required, *where* it goes, and *what* it must assert. For the assertion/locator patterns inside the spec, see
+`Skill({skill: "playwright-testing"})`.
+
## When e2e tests are required
A change **requires** an e2e test if it touches any of:
@@ -28,4 +33,16 @@ If the work is tracked under a ticket id, you may prefix the file with it (e.g.
Write the spec alongside the implementation. The reviewer checks that the spec exists and asserts the right thing. CI runs it — don't run it locally yourself.
-See [playwright-testing](../playwright-testing/SKILL.md) for the assertion / locator patterns to use inside the spec.
+## Red Flags
+
+- A UI/filter/form/interaction change with no `e2e/*.spec.ts` added.
+- Claiming the CSS/migration-only exception without saying so in the task notes.
+- A spec placed outside `e2e/`, or that asserts nothing user-visible.
+- Running the e2e suite locally instead of letting CI do it.
+
+## Verification
+
+- [ ] If the change touches UI/filters/forms/interactions, a spec exists under `e2e/`.
+- [ ] The spec is named after the feature (ticket-id prefix optional).
+- [ ] The spec asserts the right user-visible behavior, using `playwright-testing` patterns.
+- [ ] Any CSS/migration-only exemption is stated explicitly in the task notes.
diff --git a/.claude/skills/frontend-dev/SKILL.md b/.claude/skills/frontend-dev/SKILL.md
index 60ca001f..556d7cbe 100644
--- a/.claude/skills/frontend-dev/SKILL.md
+++ b/.claude/skills/frontend-dev/SKILL.md
@@ -3,8 +3,21 @@ name: frontend-dev
description: Coding practices for frontend development in Atomic CRM. Use when creating or modifying React components, forms, list pages, detail views, filters, data fetching, or responsive layouts.
---
+# Frontend Development
+
+Reference for the conventions a frontend change must follow.
+This is a reference skill, not a step sequence — read the relevant section before writing code, then verify against the checklist at the end.
The frontend uses ra-core (react-admin headless) for data fetching, routing, and CRUD logic, with shadcn-admin-kit and shadcn/ui for the UI layer.
+## When to Use
+
+- Creating or modifying React components, forms, list pages, or detail views.
+- Adding or changing filters, data fetching, or responsive (mobile/desktop) layouts.
+- Registering a new resource or reorganizing an existing resource folder.
+
+Not for backend/schema work — see `Skill({skill: "backend-dev"})`.
+Not for theming/colors — see `Skill({skill: "shadcn-customization"})`.
+
## Component architecture
- Import form inputs (`TextInput`, `SelectInput`, `ReferenceInput`, etc.) from `@/components/admin/`, not from shadcn/ui directly. The admin layer wraps shadcn with ra-core integration (labels, validation, data binding).
@@ -46,3 +59,21 @@ Resources are registered in `root/CRM.tsx` via `<Resource name="contacts" {...co
- Major pages have desktop and mobile variants. Use `useIsMobile()` to branch.
- Desktop: 2-column grid layouts. Mobile: single column with `MobileHeader`/`MobileContent`.
- Mobile lists use `InfiniteListBase` for scroll pagination.
+
+## Red Flags
+
+- Importing `TextInput`/`SelectInput`/etc. directly from `@/components/ui/` instead of `@/components/admin/`.
+- Hardcoding deal stages, note statuses, task types, or sectors instead of reading `useConfigurationContext()`.
+- A new resource folder missing one of the standard files, or not registered in `root/CRM.tsx`.
+- A bespoke fetch/axios call where a ra-core hook or a dataProvider method belongs.
+- A new top-level page with only a desktop layout and no `useIsMobile()` branch.
+- A form field component growing past the typical size instead of being split into semantic sub-components.
+
+## Verification
+
+- [ ] Inputs imported from `@/components/admin/`, pure UI from `@/components/ui/`.
+- [ ] Domain options come from `useConfigurationContext()` — nothing hardcoded.
+- [ ] New resources follow the file structure and are registered in `root/CRM.tsx`.
+- [ ] Data access uses ra-core hooks, or a dataProvider method via react-query.
+- [ ] Pages touching major UI have both desktop and mobile variants.
+- [ ] If the change touches UI/forms/filters/interactions, an e2e test exists (see `Skill({skill: "e2e-conventions"})`).
diff --git a/.claude/skills/writing-migrations/SKILL.md b/.claude/skills/writing-migrations/SKILL.md
index 74729ab8..028575da 100644
--- a/.claude/skills/writing-migrations/SKILL.md
+++ b/.claude/skills/writing-migrations/SKILL.md
@@ -5,13 +5,30 @@ description: Generate Supabase SQL migrations at deploy time from the session br
# Writing Migrations (deploy-time round)
-You are `simple-developer` in migration mode. Your worktree is
-`<WORKTREE_BASE>/simple` on `<SESSION_SHORT_ID>/simple`,
-forked from `session/<SESSION_SHORT_ID>` (`<WORKTREE_BASE>` =
-`/tmp/<$CLAUDE_PROJECT_DIR with every "/" replaced by "_">/<SESSION_ID>`). Produce SQL migrations that make the
-real Supabase schema match what this session's app expects — nothing more.
+## Overview
-## 1. Compute the session's net change
+A workflow that turns a session's *code* changes into the *minimal* SQL that
+makes the real Supabase schema match what the session's app now expects
+nothing more.
+You run as `simple-developer` in migration mode.
+Exit criterion: either a committed, idempotent migration whose delta is provably the net schema change, or an explicit `NO_MIGRATION_NEEDED` when there is no schema impact.
+
+Your worktree is `<WORKTREE_BASE>/simple` on `<SESSION_SHORT_ID>/simple`, forked from `session/<SESSION_SHORT_ID>` (`<WORKTREE_BASE>` =
+`/tmp/<$CLAUDE_PROJECT_DIR with every "/" replaced by "_">/<SESSION_ID>`).
+
+## When to Use
+
+- The deploy-time migration round, after a session's app changes have merged to `session/<SESSION_SHORT_ID>` and need their schema counterpart.
+- Triggered only by the orchestrator dispatching `simple-developer` in MIGRATION MODE never invoked ad hoc by a feature developer (developers never write SQL).
+
+Skip (write nothing, report `NO_MIGRATION_NEEDED`) when the net diff has no
+schema impact: CSS, layout, copy, or test-only changes.
+
+## Process
+
+Each step ends in a checkpoint, do not advance until its evidence holds.
+
+### 1. Compute the session's net change
```bash
cd <WORKTREE_PATH>
@@ -22,7 +39,9 @@ This is the branch's full diff since creation. Do NOT use `git merge-base`
(it collapses after the first promotion). Do NOT diff against main (other
sessions pollute it).
-## 2. Identify schema-relevant changes
+**Checkpoint:** you have the full session diff, produced from the two-dot range above (not merge-base, not main).
+
+### 2. Identify schema-relevant changes
From that diff, keep only changes that imply a database schema change:
- Entity TypeScript types (e.g. `src/**/types.ts`, resource type defs).
@@ -30,7 +49,10 @@ From that diff, keep only changes that imply a database schema change:
- dataProvider resource registrations (new resource = new table).
Ignore CSS, component layout, copy, tests.
-## 3. Compute the delta against what is already deployed
+**Checkpoint:** you have an explicit list of schema-relevant changes (possibly
+empty). If empty, jump to step 3's no-op path.
+
+### 3. Compute the delta against what is already deployed
For each changed entity, compare the desired schema (from the TS types) with the
schema already in `supabase/migrations/` and `supabase/schemas/`. Emit ONLY the
@@ -38,14 +60,20 @@ incremental delta. Anything already represented in `supabase/migrations/` is
already deployed — do not re-emit it. If the net diff has no schema impact,
write **nothing** (a no-op deploy is valid) and report `NO_MIGRATION_NEEDED`.
-## 4. Write idempotent SQL
+**Checkpoint:** every line of SQL you are about to write corresponds to a delta
+NOT already present in `supabase/migrations/`.
+
+### 4. Write idempotent SQL
Write to `supabase/migrations/<YYYYMMDDHHMMSS>_<SESSION_SHORT_ID>_migration_<slug>.sql`
(timestamp via `date -u +%Y%m%d%H%M%S`). Use `IF NOT EXISTS` / `IF EXISTS`,
correct column types matching the TS types, FKs, and RLS for new tables (RLS
enabled + policies, never `USING (true)`).
-## 5. View-recreation rule (BLOCKING correctness)
+**Checkpoint:** re-running the migration on an already-migrated database is a
+no-op (every statement is guarded), and every new table has RLS enabled with at least one non-`USING (true)` policy.
+
+### 5. View-recreation rule (BLOCKING correctness)
When a migration adds a column on a table referenced by a view in
`supabase/schemas/03_views.sql`, recreate the view with **`CREATE OR REPLACE
@@ -92,10 +120,44 @@ declarative schema must mirror the deployed view, including the chronological
"append at end" placement of newer columns. Don't reorder the schema file to
look prettier — schema drift breaks future `supabase db diff` generations.
-## 6. Commit and hand off
+**Checkpoint:** for every table that gained a column AND feeds a view,
+positions 1..N of the recreated view match the old view exactly, the new column is position N+1, and `03_views.sql` mirrors that order.
+
+### 6. Commit and hand off
Commit the SQL on `<SESSION_SHORT_ID>/simple`. Stop. SubagentStop hooks
(typecheck/prettier/unit/e2e) run automatically. The orchestrator then sends you
to quality-reviewer (migration mode) and the merger.
For Postgres correctness you may load `Skill({skill: "supabase-postgres-best-practices"})`.
+
+**Checkpoint:** the migration is committed on `<SESSION_SHORT_ID>/simple` and the SubagentStop validation chain is green.
+
+## Rationalizations
+
+| Rationalization | Reality |
+|---|---|
+| "I'll diff against main, it's close enough." | Other sessions pollute main. Only the two-dot `session-base..session` range is the true net change. |
+| "This column is probably already deployed, I'll re-emit it to be safe." | Re-emitting a deployed change is drift, not safety. Guard with `IF NOT EXISTS` and emit only the delta. |
+| "The view still selects all the right columns, order doesn't matter." | Postgres rejects any ordinal shift (42P16). Order is a hard correctness constraint, not cosmetics. |
+| "DROP VIEW CASCADE then CREATE is simpler." | It silently drops dependents and loses REVOKEs. Use `CREATE OR REPLACE` unless you are removing/renaming a column. |
+| "No schema change, but I'll write an empty migration anyway." | A no-op deploy is valid. Write nothing and report `NO_MIGRATION_NEEDED`. |
+
+## Red Flags
+
+- Diff computed via `git merge-base` or against `main`.
+- A migration statement without an `IF [NOT] EXISTS` guard.
+- A new table with no RLS, or an RLS policy using `USING (true)`.
+- A view recreated by `DROP … CASCADE` for a mere column *addition*.
+- A new column inserted anywhere but the last position of an existing view.
+- `03_views.sql` and the migration's view definition disagreeing on column order.
+- Re-emitting SQL already present in `supabase/migrations/`.
+
+## Verification
+
+- [ ] Diff taken from `session-base/<SESSION_SHORT_ID>..session/<SESSION_SHORT_ID>`.
+- [ ] Every emitted statement is an incremental delta not already in `supabase/migrations/`.
+- [ ] All statements are idempotent (`IF [NOT] EXISTS`).
+- [ ] New tables have RLS enabled with real policies (never `USING (true)`).
+- [ ] Affected views recreated via `CREATE OR REPLACE`, new column last, matching `03_views.sql`.
+- [ ] SQL committed on `<SESSION_SHORT_ID>/simple`; SubagentStop validation green — OR `NO_MIGRATION_NEEDED` reported with no file written.