| type | Reference | |||||
|---|---|---|---|---|---|---|
| title | Agent command policy | |||||
| description | Canonical allowlist for agent shell commands — install, prepare, validation, and e2e. Supersedes improvised diagnostics. | |||||
| tags |
|
|||||
| timestamp | 2026-06-27 00:00:00 UTC |
Single source for which shell commands agents may run in this repo. E2e is a subset of this policy; running e2e § agent rule adds e2e-specific prohibitions.
If a command is not listed here (or linked from here as canonical), do not run it — including “diagnostic probes” suggested by log output, package READMEs, or Yarn CLI help.
- Run only commands in the registry below (repo root unless noted).
yarn/yarn lerna:preparemust finish before anything else — see prepare must finish first. Do not parallelize install/prepare with e2e, Metro, builds, or other shell commands.- When a canonical command fails: read the full output, fix product code, re-run the same command. Do not switch invocation style.
- Do not infer alternate commands from error strings (
command not found: genversion,Couldn't find a script named "jet", etc.) — see known traps. - Subagents (Task, explore, orchestrator): same rule — paste the handoff block into every RNFB task prompt.
| Intent | Command | Never use instead |
|---|---|---|
| Install / refresh deps | yarn |
yarn workspace …, npm install in a package, yarn install in tests/ alone for root deps |
Transpile lib/** → dist/module/** (all packages) |
yarn lerna:prepare |
yarn workspace @react-native-firebase/* prepare, cd packages/<pkg> && yarn prepare, cd packages/<pkg> && yarn run build |
| Transpile one package | yarn lerna run prepare --scope @react-native-firebase/<pkg> |
yarn workspace @react-native-firebase/<pkg> prepare |
After packages/*/lib/** edits (Metro / native embed) |
yarn lerna:prepare then platform :build when running e2e § Rules #3 requires |
ad-hoc bob, babel, or package-scoped prepare |
| TS/JS validation sequence | validation checklist | ad-hoc tsc in package dirs unless listed there |
| JS lint (implementation / review gate) | yarn lint:js, yarn lint:js --fix |
package-scoped eslint, npx eslint |
| Docs lint (when docs in diff) | yarn lint:markdown, yarn lint:spellcheck |
ad-hoc prettier/eslint on single files |
| E2e + coverage | running e2e — only yarn tests:* |
jet, npx jet, yarn jet, detox test, cd tests && …, direct Metro/emulator starts |
Host pre-flight (before each :test-cover) |
running e2e § host-clear probes | pgrep, polling :8090, spawn probes of Jet/Detox |
yarn lerna:prepare runs each package's prepare script (build → compile via react-native-builder-bob). That is what produces dist/module/** consumed by Metro and native embed paths.
yarn compile(package script) is not a standalone agent entrypoint — it is invoked insidepreparevia lerna. Do not runcd packages/<pkg> && yarn compilefor handoff unless validation checklist explicitly adds an exception (none today).yarnat repo root runspostinstallDev→yarn prepare && yarn lerna:prepare; a fresh install already transpiles. Re-runyarn lerna:prepareafterlib/**edits without reinstalling.
yarn, yarn lerna:prepare, and yarn lerna run prepare --scope … are blocking foreground commands. Wait for the shell to return exit code 0 before starting any other command — including in the same agent turn via parallel tool calls.
| Do not start until prepare exits 0 | Why |
|---|---|
yarn tests:* (e2e, packager, build) |
Metro and native embed read dist/module/**, not lib/** — partial prepare → missing modules, stale bundles |
yarn tests:packager:jet-reset-cache |
Reset after prepare, not during it |
yarn tsc:compile, Jest, compare:types |
May read transpiled output or assume dist/ is current |
Another yarn / scoped prepare |
Overlapping Nx/Lerna runs race on dist/ |
Agent rule: one prepare invocation per message batch; wait for completion; then run the next step (Metro restart if needed → pre-flight → :test-cover). Running e2e § prepare completion gate is the e2e-side mirror of this rule.
Symptoms when violated: Cannot find module '…/dist/module/…', Metro 500 on bundle, e2e failures before tests run, or green Metro /status while the app loads a half-written dist/.
- Re-run from repo root:
yarnoryarn lerna:prepare(full log — do not truncate). - Note the first Nx/Lerna project that failed (e.g.
@react-native-firebase/functions:prepare). - Fix product code in that package (TypeScript errors, missing exports, etc.).
- Re-run
yarn lerna:prepare— same command, same cwd. - Do not “verify tooling” with
yarn workspace … prepare,yarn bin …, or package-scopedyarn run build— Yarn 4 uses different PATH for those invocations (genversion trap).
| Command | Why |
|---|---|
yarn workspace @react-native-firebase/* prepare (and variants) |
Not canonical; breaks root devDependency binary resolution |
cd packages/<pkg> && yarn prepare / yarn run build |
Same trap; not the postinstall / lerna code path |
yarn jet, npx jet, cd tests && yarn jet … |
E2e agent rule |
detox test, cd tests && detox … |
E2e agent rule |
| Ad-hoc Metro / emulator start | Use yarn tests:packager:jet, yarn tests:emulator:start |
| Spawn / PATH probes to “test” Jet or genversion | Log triage only; fix product code and re-run canonical command |
genversionexists at rootnode_modules/.binafteryarn.yarn lerna:prepare(andyarn install→postinstallDev) runs prepare via Nx with root toolchain on PATH → baregenversionin package"build"scripts works.yarn workspace … prepareorcd packages/foo && yarn run builddoes not expose root-only devDependencies →command not found: genversion. That is not corruptnode_modules; do not patch scripts withyarn run -T genversionunless deliberately changing repo policy onmain.
yarn jet --helpworking or failing intests/is not a valid e2e or install gate.- Jet is started internally by
yarn tests:<platform>:test-cover. Stale:8090→ pre-flight recovery, then re-run the same:test-covercommand.
Paste into Task / explore / work-queue prompts:
RNFB agent command policy: okf-bundle/testing/agent-command-policy.md ONLY.
E2e: okf-bundle/testing/running-e2e.md yarn tests:* ONLY.
Never: yarn workspace prepare, yarn jet, npx jet, cd packages/* && yarn prepare/build for diagnostics.
Prepare/install: yarn or yarn lerna:prepare must exit 0 before ANY other command — never parallelize with e2e/Metro/build.
Area harness: okf-bundle/testing/running-e2e.md#tests-app-js-area-harness — edit BOTH Platform.other and !Platform.other blocks; revert both before commit.
On failure: fix product code, re-run the same canonical command.
| Topic | Owner |
|---|---|
| E2e commands, pre-flight, tiers | running-e2e.md |
| Handoff validation sequence | validation-checklist.md |
| Work types and gates | change-authoring-workflow.md |
| Doc / commit policy | documentation-policy.md |