Commit Graph
3 Commits
Author SHA1 Message Date
Alaister YoungandAlaister Young d845768fcf chore(claude): add react-hook-form skill (#48431)
Adds a Claude skill encoding correct React Hook Form usage, so
AI-written form code follows best practices instead of copying the
anti-patterns common in older Studio code (prop-form
`form.watch()`/`formState` subscriptions, subscription-only watches,
unguarded `valueAsNumber`, `?? undefined` controlled values, defaults
computed from unloaded queries).

**Added:**
- `.claude/skills/react-hook-form/SKILL.md` — subscription model
(`useWatch`/`useFormState` with `control`), canonical zod + `FormField`
composition (layout deferred to `studio-ui-patterns`), `values:` option
for async data, null normalization for controlled inputs, number-input
handling, dirty-state and gating rules, plus a fix-what-you-touch policy
aligned with the `no-use-watch` lint ratchet

**Changed:**
- `.claude/CLAUDE.md` and `apps/studio/CLAUDE.md` — register the skill
in the skill lists/table
- `.coderabbit.yaml` — add the skill to the existing Studio
code-guidelines entry so CodeRabbit applies it when reviewing Studio
code

Benchmarked on three real form tasks (adding a live-updating field to
`ThroughputField`, a new sheet form with async + nullable data, a
review-changes step in `EditBucketModal`), each run with and without the
skill: 13/13 assertions with the skill vs 8/13 baseline. The baseline
shipped a genuine bug in one task — a `null` server default flowed into
a `''` its own schema rejected, making Save unreachable — which the
skill run avoided.

## To test

- Ask Claude Code to add a field to any Studio form and check it loads
the skill (it's in the studio CLAUDE.md skill table) and uses
`useWatch({ control, name })` rather than `form.watch`
- Skim `SKILL.md` for anything that contradicts current form conventions
— `apps/design-system` demos remain the layout source of truth

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Added a new monorepo “react-hook-form” skill guide with recommended
patterns for safe form subscriptions, wiring, default values,
reset/submission flows, and common anti-patterns.
* Updated Studio skills/load guidance to expand and reorder the skills
matrix, including form logic and copywriting guidance.
* Updated required skill coverage so `react-hook-form` is included for
any form-related work.
* **Chores**
* Expanded automated review enforcement so Studio form code is checked
against the new “react-hook-form” skill guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-07-29 16:52:03 +08:00
Alaister YoungandAlaister Young 32798c3162 [FE-3423] chore(studio): flag pages/** edits to mirror into TanStack routes (#47650)
Adds a PR-time reminder to mirror any edit to `apps/studio/pages/**`
into the corresponding `apps/studio/routes/**` file, since the Next.js
pages router and the TanStack Start route tree ship side-by-side during
the migration and can silently drift.

**Added:**
- A CodeRabbit `path_instructions` rule (`.coderabbit.yaml`) scoped to
`apps/studio/pages/**` that prompts authors to check whether a page
change needs mirroring into `routes/**`. It encodes the migration's
nuance so it isn't noise — pure body edits on re-export (Path A) pages
propagate automatically, but layout/`getLayout`, `staticData` props,
`withAuth`, redirect-path, or new-page changes must be mirrored by hand.
Framed as verify-not-block, and explicitly tells authors *not* to delete
the `pages/**` file.

**Changed:**
- `apps/studio/TANSTACK_MIGRATION.md` — documents the guardrail under
the Runtime model section, and adds a cleanup-checklist line to remove
it once `pages/**` is deleted (FE-3106).

This is temporary scaffolding — it comes out with the final `pages/**`
cleanup pass.

## To test

- This needs to land on `master` first, then open a throwaway PR that
touches a file under `apps/studio/pages/**` and confirm CodeRabbit
leaves the reminder comment.
- `path_instructions` can be flaky — if CodeRabbit doesn't fire
reliably, the fallback is a GitHub Action + sticky PR comment scoped to
`paths: ['apps/studio/pages/**']`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Added migration guidance for Studio page changes to help keep mirrored
routes in sync during the transition period.
* Clarified when page updates need to be reflected in the matching route
files, including new pages and changes to layout, access control,
titles, static data, or paths.
* Added a cleanup reminder for removing the temporary review guidance
once the migration is complete.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-07-06 15:26:43 +00:00
Alaister YoungandAlaister Young 7b5e976c9f chore: manage CodeRabbit config in .coderabbit.yaml (#47328)
Sets up `.coderabbit.yaml` so our CodeRabbit configuration lives in the
repo — version-controlled, visible to contributors, and reviewable —
instead of split between the dashboard and nowhere. Three parts:

1. **Skills as code guidelines** — wires our `.claude/skills/` into
reviews.
2. **Path instructions** — migrates the telemetry rules out of the
CodeRabbit dashboard UI.
3. **Path filters** — skips machine-generated files so reviews focus on
hand-written code.

Supersedes #47327 (closed).

## 1. Skills as review guidelines

CodeRabbit's code-guidelines feature reads guideline files and, by
default, **directory-scopes** them — a file applies only to its own
folder and below. Our skills live in `.claude/skills/` (no code), so
they'd never reach `apps/studio`. The `applyTo` field on `filePatterns`
decouples *where the guideline lives* from *which code it governs*, so
we point CodeRabbit straight at the skills:

| Skills | Apply to |
| --- | --- |
| `studio-best-practices`, `studio-ui-patterns`,
`vercel-composition-patterns`, `studio-queries`, `studio-error-handling`
| `apps/studio/**/*.{ts,tsx}` |
| `studio-testing`, `studio-mock-api-tests` |
`apps/studio/**/*.test.{ts,tsx}` |
| `studio-e2e-tests` | `e2e/studio/**/*.spec.ts` |

Skills stay the **single source of truth** — consumed directly, no
duplicated/generated copy.

## 2. Path instructions (migrated from the dashboard)

Moved the two existing telemetry path instructions into the file so
they're version-controlled:
- `packages/common/telemetry-constants.ts` — event-naming enforcement
(`[object]_[verb]` snake_case, approved verb list, camelCase props,
`useSendEventMutation` flag, JSDoc + union-type checks).
- `apps/studio/components/**/*.tsx` — only suggest PostHog tracking for
growth-relevant interactions, not passive/UI-only ones.

## 3. Path filters (skip generated files)

Excludes machine-generated / vendored paths from review (mirrors
`.prettierignore`): API types, generated DB types, route trees,
design-system / icons / ui-library registries, generated icon
components, and the lockfile. Keeps reviews focused on hand-written code
and preserves OSS rate-limit budget on large codegen diffs.

## Notes
- Cost is \$0 — CodeRabbit Pro (incl. code guidelines) is free for
public repos.
- `vitest` skill left out (generic framework reference, not our
conventions).
- The `telemetry-standards` skill is intentionally **not** also wired as
a guideline — the migrated path instruction above is the curated
version; wiring both would double up.

## To test
- PR touching `apps/studio/**/*.tsx` → CodeRabbit cites Studio
conventions
- PR touching `e2e/studio/**/*.spec.ts` → cites E2E conventions
- PR editing `telemetry-constants.ts` with a bad verb / non-camelCase
prop → flagged
- PR that regenerates e.g. `packages/api-types/types/**` → those files
not reviewed
- Confirm Studio guidelines don't bleed into unrelated areas (docs, www)

## Follow-ups (not here)
- Extend `filePatterns` to other scopes: `dev-toolbar-review` →
`packages/dev-tools/**`
- Optionally skip bot PRs via `auto_review.ignore_title_keywords`
- Move any remaining dashboard settings into this file as we find them

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Added/updated automated review configuration to disable org-level
inheritance and enable automatic issue enrichment.
* Excluded generated/vendor artifacts (e.g., lockfiles, API/type
outputs, generated docs/www, UI registry/icon sources) from review.
* Added path-scoped review guidance for telemetry event
naming/verification and tighter review focus for production UI
event-tracking suggestions.
* Extended internal coding guidelines to apply local skill docs across
Studio source, unit/component tests, and Studio Playwright E2E specs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-06-26 16:26:46 +08:00