How to read these rules
| Keyword | Meaning for the agent |
|---|---|
| MUST | Always do it. Break it only with a // guardrail-exception: <rule id> <reason> comment at the spot and one line in the PR description. |
| NEVER | Never do it. Same exception path as MUST. |
| SHOULD | The default. Deviate only with a one-line reason in the PR description; no code comment needed. |
When two rules seem to conflict, apply the first match:
- Security and shipping rules cannot be broken with a guardrail-exception comment: ST9, AP7, AP8, R4, R6, V2. Only the human, explicitly, in the conversation, can waive them.
- The human’s explicit instruction for the current task.
- In an existing repo, the pattern the repo already uses (A2).
- A specific rule beats a general one (PF4 beats P4; NV2 beats any general import advice).
- MUST and NEVER beat SHOULD.
- Still unclear: ask the human once, with both options and a recommendation.
Terms used in the rules:
- Existing repo: has app code beyond the starter template. Otherwise it is a new project.
- Feature: one product-domain folder under
src/features/. - Level: read from the
## Stacksection ofGUARDRAILS.md; Starter if none is set. - Stack section: the
## Stackpart ofGUARDRAILS.mdholding the level, framework, navigation, state, styling, critical journeys, budgets and any changed thresholds (N5). - Short list: up to ~50 items with a fixed size. Long list: more than ~50 items, paginated or unbounded.
- Measured: a number from a release build (profiler,
console.time, Reassure, Flashlight), written in the PR. - Critical journey: listed in the Stack section; by default sign-in, sign-up and the app’s core money or checkout flow.
- ~N lines: a prompt to check, not an exact limit; count the whole file.
| Prefix | Area | Prefix | Area |
|---|---|---|---|
| A | Before writing code | AP | API layer |
| V | Vetting a dependency | DL | Deep links |
| N | New project | PN | Push notifications |
| P | While writing code | PF | Performance |
| D | Done means | MZ | Memoization |
| S | Project structure | AN | Animations |
| ST | State & data | T | Testing |
| SE | Side effects | TW | Test writing |
| EB | Errors | UT | Unit tests |
| C | Components | FT | Functional tests |
| SY | Styling | TL | Tooling |
| NV | Navigation | CI | CI checks |
| TS | TypeScript | R | Builds & releases |
Before writing code in an existing repo
- A1 MUST read
package.json, the app entry and 2 existing features before adding a new one, then copy the patterns found there. - A2 MUST use the stack already in the repo: Expo or bare, state library, styling, navigation. NEVER add a second library for a job one already does, and NEVER migrate unasked.
- A3 NEVER add a dependency without asking the human first. State the package, why it is needed, and how far the installed tools get without it.
- A4 MUST post a 3–5 line plan (files to create and touch) before any change touching more than 5 files.
- A5 MUST check the official docs for the installed version before using any React Native, Expo or library API: reactnative.dev, docs.expo.dev (append
.mdto any page for an agent-readable copy) and the library’s own docs. NEVER rely on memory for version-specific APIs; training data goes stale. Example: the coreSafeAreaViewis deprecated since RN 0.81, so usereact-native-safe-area-context.
Vetting a new dependency
Applies in both modes, every time A3 comes up. The agent runs these checks itself, live, and shows the results to the human with the A3 ask.
- V1 MUST prefer, in order: React Native core → Expo SDK module (Expo projects) → a library from an established maintainer (Expo, Software Mansion, Callstack, Shopify, Infinite Red, Meta) → anything else.
- V2 MUST confirm New Architecture support on React Native Directory (reactnative.directory) or in the library’s docs, for the exact version being installed. In Expo projects, also run
npx expo-doctorafter installing. NEVER install a library without New Architecture support. - V3 MUST confirm active maintenance: a release or commit in the last 6 months, and maintainers answering recent issues.
- V4 MUST confirm real usage: 10,000+ weekly npm downloads by default. A niche native SDK may fall below this; say so and why.
- V5 SHOULD confirm more than one active contributor in the last 12 months, unless an established maintainer (V1) owns it.
- V6 NEVER install a package npm marks as deprecated, or one whose README points to a replacement.
- V7 MUST install the latest stable version compatible with the project:
npx expo install <pkg>in Expo projects (it picks the version matching the SDK), the library’s stated RN range in bare projects. NEVER pin an old major version unasked. - V8 MUST, when any check fails, not install. Report which check failed and offer an alternative library or a small in-house version (under ~50 lines).
Report format for the A3 ask:
| Check | Result |
|---|---|
| New Architecture | yes, since v2.0 (React Native Directory) |
| Last release | 2026-11-02 |
| Weekly downloads | 1.1M |
| Active contributors (12 mo) | 14 |
| Deprecated | no |
The thresholds above are defaults; a project can change them in its ## Stack section, and the agent follows the project’s numbers.
Starting from scratch
In a new project the agent sets the patterns every later change will copy, so it picks the boring default and writes each choice down.
- N1 MUST ask the human, in one message, the choices this doc leaves open: Expo or bare, navigation, styling. Offer the defaults below and take the default for anything left unanswered.
- N2 MUST start with the minimum: current stable React Native or Expo SDK, TypeScript strict, ESLint + Prettier, React Compiler on, the Project structure layout with one example feature, and a query library for server data. Nothing else.
- N3 NEVER pre-install libraries “we’ll need later” (forms, i18n, analytics, global store, animation). Add each when the first feature needs it, asking per A3.
- N4 NEVER create empty folders or placeholder files for future features.
shared/starts empty and grows per P3. - N5 MUST record each stack choice and its one-line reason in a
## Stacksection ofGUARDRAILS.md, so later agents follow it through A2. - N6 MUST start at the Starter level and level up only when a trigger shows.
| Choice | Default | Pick the other when |
|---|---|---|
| Framework | Expo (prebuild + EAS), the framework the React Native docs recommend | Bare: adding RN to an existing native app, or a native SDK that config plugins cannot cover |
| Architecture | New Architecture only; no opt-out since RN 0.82 | No alternative. A library without New Architecture support is not an option |
| Navigation | Expo Router with Expo, React Navigation with bare | The human prefers the other |
| Memoization | React Compiler on | Leave it off only if a required library breaks under it |
| Server data | TanStack Query v5 | The team already standardizes on another query library |
| Client state | useState, then Context |
A small store (Zustand) once 3+ unrelated screens share mutable state |
| Styling | StyleSheet + theme tokens |
The team already works in NativeWind or Tamagui |
| Lists | FlatList for short lists |
FlashList v2 (New Architecture only, no size estimates) for long or mixed-height lists, or once a list measurably drops frames |
While writing code
- P1 MUST build only what the task asks. No speculative props, config options or “future-proof” layers.
- P2 NEVER create an abstraction (shared component, hook, util, base class) for one use. Two copies are fine; extract on the third real use.
- P3 MUST colocate: new code goes in the feature that uses it. Move it to
shared/only when a second feature imports it. - P4 Memoization depends on React Compiler. With the compiler on (the default in new Expo apps since SDK 54), the compiler memoizes and the agent hand-writes
useMemo,useCallbackorReact.memoonly for the escape hatches in Performance → When to memoize. With it off, memoize only in the cases that table lists, never by habit. - P5 MUST keep features deletable: removing a feature folder needs 5 or fewer line changes outside it.
- P6 Share shape, not meaning.
shared/holds only UI primitives, slot-based templates (layout only: no fetching, navigation or stores) and infrastructure utilities (API client,formatRupiah, analytics). NEVER put domain logic or domain-named components inshared/. A template that needs a 4th boolean prop gets split, or the variation is composed inside the feature. - P7 SHOULD keep diffs to one concern. NEVER reformat or refactor code the task does not touch.