A skill for AI coding agents
React Native Guardrails
AI agents write React Native code fast. Left alone, they also add a global store "for later", wrap every component in useMemo and invent folders you'll never use. This skill gives them a rule book that keeps the code simple now and still lets it grow.
Checked against the official docs on 2026-12-01:React Native 0.88Expo SDK 58React Compiler 1.0TanStack Query v5FlashList v2React Navigation 7Zod 4
What it is
It's a single Markdown file. Install it as a skill, open a React Native or Expo project, and ask your agent to set up guardrails. The agent reads your code, asks you a few questions, and writes a GUARDRAILS.md that fitsthis repo: your stack, your team size and whatever is hurting right now.
The file is written for agents first, so every rule has an ID they can cite, and for the humans reviewing their work second. The rules don't change from repo to repo. The skill picks the ones that apply, rewords them for your stack and leaves the rest out. It never makes up new ones.
How it works
Five steps, always in this order. Open any step to see exactly what the agent is told to do.
1Detect
It reads your repo first and asks nothing yet.Read, without modifying anything:
package.json: React Native and Expo versions, and which libraries fill each job: navigation (expo-router,@react-navigation/*), server data (@tanstack/react-query,@reduxjs/toolkit,swr), client state (zustand,redux,mobx,jotai), styling (nativewind,tamagui,styled-components, plainStyleSheet), lists (@shopify/flash-list), animation (react-native-reanimated,react-native-worklets), testing (jest,jest-expo,@testing-library/react-native,reassure), schema (zod,valibot,yup).- Framework mode:
app.json/app.config.*andexpoin dependencies mean Expo; committedios/andandroid/folders without Expo config mean bare. - React Compiler:
experiments.reactCompilerin the app config, orbabel-plugin-react-compilerin the Babel config. - Folder shape: feature-based (
src/features/*), type-based (src/screens,src/componentsat the top) or mixed. Count files in shared folders and how many importers each has. - Team and process signals:
CODEOWNERS, CI config (.github/workflows,.eas/workflows, others), lint config (flat or legacy),tsconfig.jsonstrictness, lockfile and package manager,.nvmrc/engines. - Monorepo signals: workspaces,
apps/andpackages/folders. - Existing agent files:
AGENTS.md,CLAUDE.md,.cursor/rules, an existingGUARDRAILS.md.
Classify the repo as existing repo (app code beyond the starter template) or new project.
2Ask
Then it asks only what the code couldn't tell it, four questions at most, each with a default.Ask in one message, at most four questions, each with a default:
- Team size today, to set the level (Starter 1–3 devs, Growing 4–10, Scale 10+). Default: Starter.
- What hurts right now (slow screens, merge conflicts, bugs from one area breaking another, flaky releases). Default: nothing specific.
- For each detected choice that looks accidental (two state libraries, mixed folder shapes): keep it or pick one? Default: keep what exists (A2).
- Critical journeys and budgets (bundle size, render time). Default: sign-in, sign-up, the core money or checkout flow; budgets left unset.
For a new project, also ask the open choices from N1 (Expo or bare, navigation, styling) and offer the defaults table.
If nobody answers, take every default and say so at the top of the output.
3Assess
It works out which rules apply to your stack, and where you already break them.- Pick the level per area, not for the whole app: structure, state, CI and releases can sit at different levels.
- For every rule, mark it applies, adapted (reworded to the detected stack, for example RTK Query instead of TanStack Query under ST11) or not applicable (drop it from the output, for example push rules in an app without notifications).
- Note current violations with file paths and counts. Example: “
src/components/has 40 files, 12 used by only one screen (P3)”. - Never recommend migrating an existing library. Mention an alternative only as an optional “consider when” note tied to a measured pain.
4Write
It writes GUARDRAILS.md and a short pointer in AGENTS.md.Create
GUARDRAILS.mdat the repo root with this shape:## Stack: level per area, framework, navigation, state, styling, critical journeys, budgets, any changed thresholds, each with a one-line reason (N5).- The applicable rules, grouped as in the rule set below, keeping every rule ID unchanged so agents and reviewers can cite them. Reword only to match the stack.
## Current violations: the list from Assess, with paths, so the first cleanup tasks are obvious. Never fix them inside this task.## Next scale triggers: the triggers closest to firing, with the evidence.- The PR checklist, trimmed to the applicable rules.
Then add a short pointer for agents:
- If
AGENTS.mdexists, append a clearly marked section; otherwise create it. Keep it to 20–40 lines: the five most important rules for this repo, the conflict order, and “Read GUARDRAILS.md before writing code.” - If
CLAUDE.mdor.cursor/rulesalready exist, add one line pointing toGUARDRAILS.md. Do not create them.
5Enforce
It offers lint checks to back the rules up, and only adds them if you say yes.Offer, never apply by default:
- Lint boundaries (
import-x/no-restricted-pathsoreslint-plugin-boundaries), circular-dependency check, and the other CI checks for the chosen level. - Start every new lint rule as
warn, report the current violation count, and suggest switching toerroronce it reaches zero.
Safety rules for this skill:
- Never overwrite an existing config,
AGENTS.mdorGUARDRAILS.md. Show a diff or append a marked section. - Never install packages; list them for the human to approve (A3, V1–V8).
- On a re-run, diff against the existing
GUARDRAILS.md: report new violations, triggers that fired and rules that changed. Keep the human’s own edits.
- Lint boundaries (
Install
Claude Code. Save the file as a personal skill so it's there in every project:
mkdir -p ~/.claude/skills/react-native-guardrails && curl -fsSL https://adnanradjam.com/portfolio/rn-guardrails/SKILL.md -o ~/.claude/skills/react-native-guardrails/SKILL.mdTo share it with your team, put it in the repo at .claude/skills/react-native-guardrails/SKILL.md and commit it.
Claude apps. Put SKILL.md in a folder named react-native-guardrails, zip the folder and upload it as a custom skill in Claude's settings.
Other agents. It's plain Markdown. Any agent that can read a file can follow it. Point it atSKILL.md and ask it to run the workflow.
Then, in your project, just ask:
Running it again later is safe. It compares against your existing GUARDRAILS.md, tells you what changed, and keeps any edits you made by hand.
What you get
GUARDRAILS.md
Your stack and the reasons behind it, then the rules that apply, with their IDs unchanged so anyone can cite them.
An AGENTS.md pointer
Twenty to forty lines: the five rules that matter most in your repo, how to settle a clash between rules, and "read GUARDRAILS.md first".
A cleanup list
Where the code already breaks a rule, with file paths, so the first tidy-up tasks are obvious. It doesn't fix them in the same pass.
Nothing you didn't ask for
It doesn't install packages or overwrite configs. Lint rules only go in if you say yes, and they start as warnings.
The rules are grouped into 11 sections, and each one has its own page here:
Why the rules look like this
If you've read a few style guides, the format might look strict. That's on purpose: an agent follows clear instructions better than good advice.
Three words, three meanings
A rule says MUST, SHOULD or NEVER, and each one means something exact. Breaking a MUST or NEVER isn't banned, but the agent has to say so in the code with a
// guardrail-exceptioncomment and in the PR. You always know where the rules were bent, and why.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. A fixed answer when rules disagree
Rules will sometimes pull in different directions. Instead of letting the agent guess, there's a tie-break order. A few security and shipping rules sit at the top, and no comment can waive them. Only you can.
- 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.
Your code comes first
In an existing repo, the patterns already there win (A1,A2). The agent doesn't swap your state library or move your folders because a rule book said so. It fills the gaps.
Heavier patterns wait for a reason
Global stores, form libraries, import lint rules and monorepos are all fine eventually. Each one has a trigger, like "3+ unrelated screens share this state". Until that happens, it doesn't go in. SeeAnti-patterns & scale triggers.
It doesn't trust its own memory
React Native and Expo move fast, and training data goes stale. Before using any version-specific API, the agent has to check the official docs for the version you have installed (A5). That keeps the rules useful as libraries change.