## Context Noticed while working on #43913 that `copilot-instructions.md` is currently at ~4,600 characters. Per [GitHub's docs on Copilot code review](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review): > Copilot code review only reads the first 4,000 characters of any custom instruction file. Any instructions beyond this limit will not affect the reviews generated by Copilot code review. This means the testing section at the bottom of our current file isn't being read during reviews. ## Proposal Split the single file into path-specific instruction files under `.github/instructions/`, following [GitHub's recommended pattern for repository custom instructions](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions): > These are specified in one or more `NAME.instructions.md` files within or below the `.github/instructions` directory. > If the path you specify matches a file that Copilot is working on, and a repository-wide custom instructions file also exists, then the instructions from both files are used. This gives us separate files that each stay under the 4K limit and get combined automatically by Copilot during reviews: | File | Size | Scope | |------|------|-------| | `copilot-instructions.md` | 929 chars | General repo context + pointers | | `instructions/studio-telemetry.instructions.md` | 3,570 chars | Telemetry rules for `apps/studio/**` | | `instructions/studio-testing.instructions.md` | 1,228 chars | Testing rules for `apps/studio/**` | Note: Copilot reads instructions from the **base branch** of a PR, not the feature branch — so these won't take effect until merged to master. ### New telemetry guidance The telemetry file adds guidance we've been missing — specifically around feature-flagged rollouts: - Flag PRs that use `usePHFlag`/`useFlag` to gate behavior but don't capture the flag state in telemetry - Flag rollouts that track flag state but not user response to the new behavior - Documents the raw flag pattern (read via `usePHFlag`, not coerced wrapper hooks) to avoid the `undefined`→`false` data quality bug we hit in #43913 ### What didn't change All existing telemetry and testing rules are preserved — nothing was removed, just reorganized. The telemetry rules still reference `.claude/skills/telemetry-standards/SKILL.md` as the authoritative source. ## References - [Adding repository custom instructions for GitHub Copilot](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions) — file structure, path-specific instructions, frontmatter format - [Using Copilot code review](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review) — 4K character limit, base branch behavior ## Open questions Would love the team's input on: - Does the file split make sense, or would you prefer keeping everything in one file (and trimming to fit)? - Are there other topics that should get their own instruction file? - Any concerns with the new feature flag telemetry guidance?
3.3 KiB
applyTo
| applyTo |
|---|
| apps/studio/**,packages/common/telemetry* |
Studio Telemetry Review Rules
All comments are advisory — suggest, do not request changes.
When to Flag Missing Telemetry
Use judgment — not every PR needs telemetry. But always flag when:
- Changes to
packages/common/telemetry-constants.ts— validate event naming, property conventions, and JSDoc accuracy. - PostHog feature flags without measurement. If a PR uses
usePHFlagor PostHog-backed hooks likeuseDataApiGrantTogglesEnabledto gate behavior, the flag state should be captured in a telemetry event so the rollout can be measured. Flag if the flag value isn't included in a relevanttrack()call. (Note:useFlagfromcommonreads ConfigCat flags, not PostHog — different system, different guidance.) - Feature-flagged rollouts without outcome tracking. If a flag gates new behavior, there should be telemetry on both the flag state and how users respond to the new behavior (e.g., toggle clicks, opt-in actions).
- Growth-oriented components adding user interactions without tracking — onboarding flows, setup wizards, upgrade CTAs, A/B experiment variants.
When tracking is missing, comment: "This adds a user interaction (or feature flag) that may benefit from tracking." Then propose an event name and useTrack() call.
Feature Flag Telemetry Pattern
When capturing a PostHog flag value for telemetry, read the raw flag via usePHFlag('flagName') — not through wrapper hooks that coerce undefined to false. Use conditional spread so the property is omitted (not false) when the flag store hasn't loaded:
const flagValue = usePHFlag<boolean>('myBooleanFlag') // for boolean flags
track('event_name', {
...(flagValue !== undefined && { myFlagEnabled: flagValue }),
})
For string-valued flags (e.g., experiment variants), use usePHFlag<string>('flagName') instead.
Event Naming
Format: [object]_[verb] in snake_case.
Prefer verbs already in use in packages/common/telemetry-constants.ts: opened, clicked, submitted, created, removed, updated, intended, evaluated, added, enabled, disabled, copied, exposed, failed, converted, closed, completed, applied, sent, moved.
Flag: unapproved verbs (saved, viewed, pressed), wrong order (click_product_card), wrong casing (productCardClicked), passive view tracking on page load (exception: _exposed events for A/B experiments).
Event Properties
- camelCase for new events; match existing convention when extending
- Self-explanatory names — flag generic (
label,value,name,data) - Check
telemetry-constants.tsfor consistency with similar events - Never track PII
Event Implementation
- Use
useTrackfromlib/telemetry/track— avoid introducing newuseSendEventMutationusage - New events need a TypeScript interface in
telemetry-constants.tswith@group Eventsand@sourceJSDoc tags (add@pagewhen applicable for page-specific events), added to theTelemetryEventunion
import { useTrack } from 'lib/telemetry/track'
const track = useTrack()
track('product_card_clicked', { productType: 'database', planTier: 'pro' })
Canonical standards: .claude/skills/telemetry-standards/SKILL.md