Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ yarn-error.log*
# Misc
.DS_Store
*.pem

# Agent skills scratch files
.scratch/
14 changes: 14 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,17 @@ Unit tests live beside each domain under `src/lib/**/tests/`. Prefer small, focu
Recent history mostly follows Conventional Commit-style subjects such as `feat:`, `fix:`, and `chore:` with short imperative summaries. Keep commits narrowly scoped and descriptive.

PRs should include a clear summary, linked issue if applicable, and the commands you ran locally (`pnpm lint`, `pnpm check-types`, relevant tests). Include screenshots or screen recordings when a playground or UI behavior changes. Avoid loose dependency ranges: this repo enforces exact versions in every `package.json`.

## Agent skills

### Issue tracker

Linear, Engineering team (`ENG`); skills use the Linear MCP tools. See `docs/agents/issue-tracker.md`.

### Triage labels

No triage labels: the five roles map onto Linear workflow states. See `docs/agents/triage-labels.md`.

### Domain docs

Single-context: `GLOSSARY.md` at the repo root and ADRs in `docs/adr/`. See `docs/agents/domain.md`.
36 changes: 36 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Glossary

Terms the React Native SDK (`packages/react-native`) uses, grouped by area. Use these words in issues, code and tests; the `/domain-modeling` skill adds new ones as they get resolved.

## Setup and configuration

- **Workspace**: the Formbricks space the app's surveys, action classes and styling belong to, identified by `workspaceId` (`TWorkspace`, `src/lib/workspace/`). Replaces the older term _environment_: `environmentId` is a deprecated alias that still works, and stored configs that use it are migrated.
- **App URL**: the Formbricks instance the SDK talks to (`appUrl`), passed to `setup()` with the workspace ID.
- **Config**: the SDK's persisted state (`TConfig`, `RNConfig`): workspace ID, app URL, workspace state, user state and filtered surveys, stored in AsyncStorage.
- **Workspace state**: the workspace's surveys, action classes and settings as fetched from the server, cached with an expiry (30 minutes) and refetched when it lapses.

## Users

- **User ID**: the app's identifier for the signed-in user, set with `setUserId()`. Without one the user is anonymous; `logout()` clears it.
- **Attributes**: key/value facts about the user (`setAttribute()`, `setAttributes()`, `setLanguage()`), sent to the server and used for targeting.
- **User state**: what the server knows about the user (`TUserState`): user ID, segments, displays, responses, last display time and language.
- **Segment**: a server-defined group of users; the SDK only receives the IDs of the segments a user belongs to and never evaluates segment filters itself.
- **Interaction refresh**: refetching a user's segments after a survey display, response or finish, gated per survey by `interactionRefresh` (`src/lib/user/interaction-refresh.ts`).

## Surveys

- **Action**: a named event the app reports with `track(name)`; it can trigger a survey.
- **Action class**: the workspace's definition of an action (`TActionClass`), either `code` (tracked from the app) or `noCode`.
- **Trigger**: an action class a survey listens for (`survey.triggers`).
- **Display option**: how often a survey may show to one user (`displayOnce`, `displayMultiple`, `displaySome`, `respondMultiple`).
- **Filtered surveys**: the surveys this user is eligible for after display options, recontact days and segments are applied (`filterSurveys`).
- **Display**: one time a survey was shown to a user.
- **Response**: a user's answers to a survey.
- **Embedded Data**: app context attached to responses with `setEmbeddedData()` / `clearEmbeddedData()`. Held in memory, synchronous and never queued. A survey takes a snapshot of it when it opens, so later changes reach only surveys opened afterwards; values land only on fields the survey declares as ingested.
- **Survey web view**: the WebView that renders a survey with the Formbricks renderer (`src/components/survey-web-view.tsx`), mounted by the `<Formbricks />` component.
- **Appearance**: how surveys render, `light`, `dark` or `system` (`setAppearance()`); kept in memory only, never sent to the server.

## Internals

- **Command queue**: runs the public async methods (`track`, `setUserId`, `setAttributes`, `logout`, …) one at a time, in order (`CommandQueue`).
- **Update queue**: debounces user ID and attribute updates into one request to the server (`UpdateQueue`).
26 changes: 26 additions & 0 deletions docs/agents/domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Domain Docs

How the engineering skills should consume this repo's domain documentation when exploring the codebase.

## Before exploring, read these

- **`GLOSSARY.md`** at the repo root.
- **`docs/adr/`**: read ADRs that touch the area you're about to work in. The folder does not exist until the first ADR is recorded.

This is a single-context repo: one glossary and one ADR folder for the whole repo, with terms grouped under headings by area. ADR files are numbered in sequence (`NNNN-short-title.md`); take the next free number. The `/domain-modeling` skill adds terms and ADRs as they get resolved.

This repo has no documentation site; the README points to the product docs at formbricks.com/docs. ADRs are engineering records, not product docs, and stay in this repo.

## Use the glossary's vocabulary

When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `GLOSSARY.md`. Don't drift to synonyms the glossary explicitly avoids.

If the concept you need isn't in the glossary yet, that's a signal: either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`).

## Flag ADR conflicts

If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:

> _Contradicts ADR-0002 (Embedded Data stays in memory and never goes through the command queue), but worth reopening because…_

(Illustrative only: there is no ADR-0002 yet.)
63 changes: 63 additions & 0 deletions docs/agents/issue-tracker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Issue tracker: Linear

SDK work items live as Linear issues in the Engineering team (`ENG`), the same team as `formbricks/formbricks`; specs and PRDs live as Linear project documents (see below). Use the Linear MCP tools.

## Conventions

- **Create**: `save_issue` with team `Engineering`, plus the project and milestone the work belongs to, a priority and labels. File straight into Todo. Triage is only for externally reported items and vulnerabilities, which follow the security process.
- **Read**: `get_issue` by identifier (`ENG-1234`); `list_comments` for the thread.
- **List**: `list_issues`, filtered by project, state, label or assignee.
- **Sub-issue**: `save_issue` with `parentId`.
- **Comment**: `save_comment`.
- **Labels**: `addLabels` / `removeLabels`, using existing labels only. Don't create labels without asking.
- **Close**: state `Done`; won't do → `Canceled`; duplicate → `duplicateOf`.
- **Blocking**: `blocks` / `blockedBy` relations.
- Never put secrets (keys, passwords, tokens) in Linear. A vulnerability ticket holds everything needed to fix it, exploit detail included.

## Pull requests

This repo has no PR template: PRs link to issues through a ticket line in the PR description (`Fixes ENG-1234` / `Ref ENG-1234`). PRs are not a triage surface.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

A PR built from a spec names the build's Linear issue on that line. The spec document and local tickets have no issue identifier, so the PR never references them.

## When a skill says "publish to the issue tracker"

Create a Linear issue in `ENG`, in the project the work belongs to. Issues are for units of work.

A spec or PRD (for example from `/to-spec`) is not a unit of work: publish it as a Linear document in the project the work belongs to, numbered after the project's existing documents (`5. Engineering spec`). Tickets are cut from it when the build needs them (next section).

## Before running `/to-tickets` on a spec

Tickets earn their place for one of two readers:

- **Agents**: the build outgrows one session. A session that holds the spec, the code it touches and the tests can build it in one go; past that, the build needs tickets, each sized for one fresh session. Rough guide: one session holds a PR of a few dozen hand-written files.
- **People**: engineers split the build between them and track it in the weekly sync.

Pick the path from those two questions:

| The build | Path | Where the tickets go |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| Fits one session | `/implement` against the spec, in the session that wrote it | No tickets. One Linear issue for the build, which the PR closes |
| Outgrows one session, one engineer runs it | `/to-tickets`, then `/implement-spec` to build them in parallel, or `/implement` per ticket in a fresh session each | Local files under `.scratch/<feature-slug>/issues/`, plus one Linear issue for the build, which the PR closes |
| Engineers split it | `/to-tickets`, then each engineer runs `/implement` per ticket | Linear issues, as in Conventions, with `blockedBy` edges |

This table decides where `/to-tickets` publishes, ahead of the configured tracker: the middle row writes local files even though the tracker is Linear.

Local tickets are the agent's working files: they follow `/to-tickets`' local template, close by setting their `Status:` line to `done` (whenever a skill says to resolve a ticket the way the tracker closes work), and stay out of git (`.scratch/` is gitignored).

Because `.scratch/` is gitignored, a new worktree has no copy of it. When a skill hands a local ticket to a subagent in its own worktree (as `/implement-spec` does), pass the ticket's absolute path in the main checkout, or its full contents.

When `/to-tickets` asks about granularity, cut the coarsest vertical slices that still fit one fresh context window.

## When a skill says "fetch the relevant ticket"

An `ENG-1234` identifier: `get_issue`. A local ticket (a `.scratch/<feature-slug>/issues/` path, or a ticket number or title from that folder): read the file. That includes `/implement` given a local ticket.

## Wayfinding operations

- **Map**: one parent issue holding the Notes / Decisions-so-far / Fog body.
- **Child ticket**: a sub-issue of the map. Its type goes in a title prefix (`Research:`, `Prototype:`, `Grill:`, `Task:`), not a label.
- **Blocking**: Linear `blockedBy` relations. A ticket is unblocked when every blocker is Done or Canceled.
- **Frontier**: children in Todo with no open blocker and no assignee; first in map order wins. Children waiting on information stay in Backlog, so they are never picked.
- **Claim**: assign to yourself, as the session's first write.
- **Resolve**: comment the answer, set Done, and append a gist plus link to the map's Decisions-so-far.
13 changes: 13 additions & 0 deletions docs/agents/triage-labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Triage roles

Engineering uses no triage labels (`agent-ready` was retired on 23 Sep 2026). The five roles the skills speak of map onto Linear workflow states:

| Role | In Linear | Meaning |
| ----------------- | ------------------------------------------------- | ---------------------------------------------------------------------------- |
| `needs-triage` | **Triage** state | Externally reported items and vulnerabilities only; internal tickets skip it |
| `needs-info` | **Backlog**, plus a comment naming what's missing | Waiting on the reporter; never picked up as work |
| `ready-for-agent` | **Todo** | Fully specified; whoever picks it up decides who works it |
| `ready-for-human` | **Todo** | Same as above |
| `wontfix` | **Canceled** state | Will not be actioned |

When a skill says "apply the ready-for-agent label", move the issue to Todo instead. A spec is a Linear document and has no state, so `/to-spec` skips this step; the build's Linear issue goes to Todo.
Loading