Skip to content

Expo + Firebase + Jest rules for AI coding agents

Full stack: Expo (React Native) + Firebase + Zod validation + Jest

Ready-to-commit rules for Expo (React Native) + Firebase + Zod validation + Jest in every major format: AGENTS.md (Codex, Cursor, Copilot), CLAUDE.md (Claude Code), Cursor .mdc project rules, legacy .cursorrules, Copilot instructions, Windsurf rules and GEMINI.md. A mobile app with Expo Router on Firebase Auth and Firestore.

Last reviewed 2026-11-04 · Customise in the generator · Raw: AGENTS.md, CLAUDE.md

The mistake agents make most on this stack

Agents leave Firestore rules open while testing and install native Firebase packages with npm instead of `npx expo install`, breaking the build.

Generated files

AGENTS.md
# AGENTS.md - this project

Instructions for AI coding agents working in this repository.

## Project

A Expo (React Native) + Firebase + Zod validation + Jest project.

Stack: Expo (React Native), Firebase, Zod validation, Jest.

## Commands

- Start dev server: `npx expo start`
- Add a native-compatible package: `npx expo install <package>`
- Check project health: `npx expo-doctor`
- Type-check: `npx tsc --noEmit`
- Local emulators: `firebase emulators:start`
- Deploy rules only: `firebase deploy --only firestore:rules`
- Unit tests: `npx jest`

## Project structure

- Screens are files in `app/` (Expo Router). Layouts are `_layout.tsx`.
- Reusable components in `components/`, hooks in `hooks/`.

## How to work in this repo

- Read the relevant files before editing. Follow the patterns already in the codebase over these generic rules.
- Make the smallest change that solves the task. Do not refactor or reformat unrelated code.
- Before saying a task is done, run the type-check, lint and tests listed under Commands and fix what you broke.
- If requirements are ambiguous, ask one clear question instead of guessing.
- Never commit secrets, API keys or `.env` files. Use env vars and keep `.env.example` up to date.
- Do not add a new dependency when the standard library or an existing dependency already covers it.
- Ask before adding, removing or upgrading any dependency.
- Ask before changing database schemas, auth, payments or CI configuration.
- Never delete files, drop data or run destructive commands (`rm -rf`, `git push --force`, `DROP TABLE`) without explicit approval.
- Keep each change under ~200 changed lines where possible; split larger work into steps.

## Expo (React Native)

- Install packages with `npx expo install` so versions match the Expo SDK.
- Use Expo Router for navigation (`<Link>`, `router.push`). Do not add React Navigation manually unless it is already in use.
- Use React Native primitives (`View`, `Text`, `Pressable`) only. No DOM elements.
- Use `FlatList` / `FlashList` for long lists, never `.map()` inside a `ScrollView`.
- Wrap screens in safe-area handling (`react-native-safe-area-context`).
- Env vars must start with `EXPO_PUBLIC_` to reach the app, so they are public. Keep secrets on a server.
- Store tokens with `expo-secure-store`, not AsyncStorage.
- Do not edit `ios/` or `android/` by hand when using Continuous Native Generation; use config plugins in `app.json` / `app.config.ts`.

## Firebase

- Firebase web config is public by design; security comes from Firestore/Storage Security Rules. Never ship `allow read, write: if true`.
- Every collection needs rules that check `request.auth` and validate the written fields.
- Admin SDK credentials are server-only (Cloud Functions or your backend).
- Model Firestore data for your queries: avoid deeply nested data and unbounded arrays; denormalize deliberately.
- Test rules and functions against the Emulator Suite, not production.

## Zod validation

- Validate all untrusted input (request bodies, form data, env vars, third-party API responses) with a Zod schema at the boundary.
- Derive TypeScript types from schemas with `z.infer<typeof schema>`; do not hand-write duplicate types.
- Use `safeParse` where you need to return validation errors to the user.

## Jest

- Co-locate tests as `*.test.ts(x)` or in `__tests__/`, matching the existing convention.
- Use React Native Testing Library or Testing Library queries by role/text, not implementation details.
- Reset mocks between tests; no shared mutable state across tests.

## Reference docs

- [Expo docs](https://docs.expo.dev)
- [Firebase docs](https://firebase.google.com/docs)
- [Zod docs](https://zod.dev)
- [Jest docs](https://jestjs.io/docs/getting-started)

Commands your agent should run

TaskCommand
Start dev servernpx expo start
Add a native-compatible packagenpx expo install <package>
Check project healthnpx expo-doctor
Type-checknpx tsc --noEmit
Local emulatorsfirebase emulators:start
Deploy rules onlyfirebase deploy --only firestore:rules
Unit testsnpx jest

What the rules cover

Expo (React Native)

Expo + React Native app with Expo Router and TypeScript. Scoped to app/**/*.tsx, src/**/*.tsx, src/**/*.ts, components/**/*.tsx in Cursor, Copilot and Windsurf.

  • Install packages with npx expo install so versions match the Expo SDK.
  • Use Expo Router for navigation (<Link>, router.push). Do not add React Navigation manually unless it is already in use.
  • Use React Native primitives (View, Text, Pressable) only. No DOM elements.
  • Use FlatList / FlashList for long lists, never .map() inside a ScrollView.
  • Wrap screens in safe-area handling (react-native-safe-area-context).
  • Env vars must start with EXPO_PUBLIC_ to reach the app, so they are public. Keep secrets on a server.
  • Store tokens with expo-secure-store, not AsyncStorage.
  • Do not edit ios/ or android/ by hand when using Continuous Native Generation; use config plugins in app.json / app.config.ts.

Source docs: Expo docs

Firebase

Firebase Auth, Firestore and Cloud Functions. Scoped to firestore.rules, functions/**, **/firebase/** in Cursor, Copilot and Windsurf.

  • Firebase web config is public by design; security comes from Firestore/Storage Security Rules. Never ship allow read, write: if true.
  • Every collection needs rules that check request.auth and validate the written fields.
  • Admin SDK credentials are server-only (Cloud Functions or your backend).
  • Model Firestore data for your queries: avoid deeply nested data and unbounded arrays; denormalize deliberately.
  • Test rules and functions against the Emulator Suite, not production.

Source docs: Firebase docs

Zod validation

Runtime schema validation with Zod. Scoped to **/*.ts, **/*.tsx in Cursor, Copilot and Windsurf.

  • Validate all untrusted input (request bodies, form data, env vars, third-party API responses) with a Zod schema at the boundary.
  • Derive TypeScript types from schemas with z.infer<typeof schema>; do not hand-write duplicate types.
  • Use safeParse where you need to return validation errors to the user.

Source docs: Zod docs

Jest

Unit tests with Jest. Scoped to **/*.test.ts, **/*.test.tsx, **/__tests__/** in Cursor, Copilot and Windsurf.

  • Co-locate tests as *.test.ts(x) or in __tests__/, matching the existing convention.
  • Use React Native Testing Library or Testing Library queries by role/text, not implementation details.
  • Reset mocks between tests; no shared mutable state across tests.

Source docs: Jest docs

How to install

  1. Copy AGENTS.md to your repo root. That covers Codex, Cursor, GitHub Copilot and most other agents.
  2. Using Claude Code? Add a CLAUDE.md with the single line @AGENTS.md, or use the standalone CLAUDE.md tab above.
  3. Want rules that only load for certain files in Cursor? Add the .cursor/rules/*.mdc files.
  4. Commit the files so your whole team (and every agent) shares them.

FAQ

Where do I put the AGENTS.md for Expo (React Native) + Firebase + Zod validation + Jest?

Save it as AGENTS.md in the root of your repository, next to your main config file. Codex, Cursor and GitHub Copilot pick it up automatically. For Claude Code, add a CLAUDE.md containing @AGENTS.md (or use the standalone CLAUDE.md on this page).

What is the most common mistake AI agents make with Expo (React Native)?

Agents leave Firestore rules open while testing and install native Firebase packages with npm instead of npx expo install, breaking the build.

Which commands should the agent run to check its work?

For this stack: npx expo start, npx expo install <package>, npx expo-doctor, npx tsc --noEmit. They are listed in the generated files so the agent runs them before finishing a task.

Do these Expo (React Native) + Firebase + Zod validation + Jest rules work with Cursor and Claude Code?

Yes. This page includes the same rules as AGENTS.md, CLAUDE.md, Cursor .mdc project rules, a legacy .cursorrules file, GitHub Copilot instructions, Windsurf rules and GEMINI.md.

Can I customise these rules?

Yes. Open this stack in the generator to add or remove libraries, set your project name and package manager, switch beginner explanations on, and download everything as a zip.

Related stacks