Gates test-only code (debug menu, debug link, simulated clock/offline) behind a single TEST_ONLY switch for React Native/Expo apps. Use when adding debug screens or test hooks that must be stripped from production builds.
Ships in react-native. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Development and preview builds carry a debug menu, one strict debug deep link and a simulated clock
and network that reach every reader, all through one literal gate; production builds contain none of
it, and a checker proves the gate, the entry, the wiring, the registry and the simulations on the
app's own code. Verified on 2026-10-10 with Expo SDK 57 (expo 57.0.26), React Native 0.86.3,
expo-router 57.0.24 and knip 6.38.0, in Jest and with back-to-back expo export bundles (iOS);
re-verified on 2026-10-17 wired through the root slots in the library's reference app, with
development and production exports for iOS and Android passing check-variant-bundle; not yet
driven on a simulator or an emulator.
src/test-only.ts is the only way into test-only code:
export const TEST_ONLY: TestOnlyApi | null = process.env.EXPO_PUBLIC_APP_VARIANT === 'production' ? null : (require('./test-only-entry') as TestOnlyApi); and nothing else runs there. Why: Metro
folds only that literal comparison before it collects require() calls; an imported constant, a
helper, __DEV__ or NODE_ENV ships the code to the store or strips it from preview builds
(app-variants-and-environment owns that rule). (gate-file, gate-form)TestOnlyApi is typeof the entry, never hand-written. import type * as TestOnlyEntry from './test-only-entry'. Why: the gate casts the require(), so a hand-written type is never compared
with the exports (TEST_ONLY.x is not a function in a preview build), and knip reported every
entry export as unused with one (measured). (api-derived)export { ... } from lines and
TEST_BUILD_SENTINEL = '<APP>_TEST_BUILD_ONLY', a string no other app file contains. Why: the
bundle and build checks prove the strip by that string, and a copy in shipped code fails every
production proof. (entry-manifest, sentinel)TEST_ONLY, from declared test-only folders. Each member is used
as TEST_ONLY?.member by the startup, the root stack or a debug route, and each folder the entry
re-exports from is in contracts/architecture.json testOnlyFolders. Why: an unread export is
forgotten wiring, and an undeclared folder lets a static import ship it unnoticed.
(entry-reachable, test-only-folders)TEST_ONLY?.createTestHooks({ services: device, ... }) in the app registry's prepareRootKits
(src/services/create-root-kits.ts), which AppRoot's startApp calls first, before the data layer
opens, swaps clock and, when the services hold it, connectivity inside the services; every
reader gets testHooks?.services ?? device. Why: one wrapper reaches every reader (due dates,
repositories, TanStack Query through services.connectivity, banners, ads); a simulated port
handed out beside the services leaves those readers on the real one. (hooks-wired, and the
createTestHooks test)today() only. It reads the simulated day on every call; nowMs()
and msUntilNextLocalDay() call the real clock every time. Why: timers, timestamps and the
next-day countdown must never jump, and useToday() still turns at the real midnight.
(simulated-clock)ConnectivityPort on the reachability hub. none while
simulating, the real reachability otherwise, isOnline derived from it, unchanged reports dropped,
stop() releases the real adapter. Why: every consumer then follows the switch exactly as it
follows a real outage. (simulated-connectivity)<scheme>://debug/setup?... is the route src/app/(debug)/debug/setup.tsx, which renders
TEST_ONLY?.DebugSetupRoot with useLocalSearchParams() and redirects home in production (the
canonical AppStack keeps the (debug) group behind Stack.Protected until the debug kit opens it);
DEBUG_LINK_PARAMS and contracts/debug-links.json list the same parameters and values. Why:
Expo Router delivers cold-start and running links once the navigator is ready, and flows read the
contract, not the TypeScript. (debug-registry, link-route)debug-link-* failure, applies nothing, is logged and shown as debug.setup-error. Why: a
typo that is ignored makes a flow test the wrong state and pass. (registry-strict)DebugSettingsTarget; refused when there is none), then router.replace to the screen; a
direction restart ends the run. Every step sets a value, so a link applied twice changes nothing
more. Why: reloads re-deliver the launch link and React's development effects run twice.src/stores/debug-overrides/
(reducer, cases, persist before publish) in expo-sqlite/kv-store under debug.overrides; the
link and the menu write it through the same actions. Why: a reload or a kill keeps them, Maestro's
clearState wipes them, and the menu always shows what a link set.TEST_ONLY?.createDebugKit, registered in the app's root-kit registry) fills the root's motion
slot: TestHooksRoot takes MotionConfig's place and passes preference="on" while
motion=still; canvas probes
render only while probe=1. Why: screenshots and E2E rest on the one reduce-motion path, never a
second switch, and screenshots never show a probe.--clear and run
app-variants-and-environment's check-variant-bundle on both. Why: only the bundle shows that the
gate, the cache key and the variables worked together.ConnectivityPort and its hub (networking-and-server-state), src/core/result.ts, date-key.ts,
languages.ts, the settings store if links change settings, and app-variants-and-environment's
variants and Metro cache key.templates/src/test-only.ts and
test-only-entry.ts (rename TASKS in the sentinel), templates/src/services/test-hooks/,
templates/src/services/debug-storage/, templates/src/stores/debug-overrides/,
templates/src/features/debug/ (the debug kit debug-root-kit.tsx included),
templates/src/app/(debug)/, the debug.* keys of templates/src/i18n/catalogs/, and
templates/contracts/debug-links.json with its schema. The test-hook kit (the gate, the hooks,
the switches store, the storage, TestHooksRoot and the debug kit) is canonical in the library
(its shared templates): the copies here are synced, never edited here.src/features/debug/, src/services/test-hooks/,
src/services/debug-storage/ and src/stores/debug-overrides/ to contracts/architecture.json
testOnlyFolders; with a second persisting store, add state-management-zustand's
contracts/stores.json.prepareRootKits makes the hooks
and returns their services, and createRootKits registers TEST_ONLY?.createDebugKit(hooks) (the
motion slot and the (debug) group); a settings target
(examples/settings-target.ts) once the app saves language and theme.contracts/debug-links.json.npx jest src/features/debug src/services/test-hooks src/services/debug-storage src/stores/debug-overrides --ci --maxWorkers=2
and npm run typecheck, npx eslint . --max-warnings 0, npx knip.check-variant-bundle on each; rm -rf dist/variant-proof after.node ${CLAUDE_SKILL_DIR}/scripts/check-test-hooks.mjs .; fix each FAIL
line (file, rule, fix) and rerun until RESULT: PASS.src/test-only.ts is the template's expression with the derived TestOnlyApi; nothing else
require()s code.src/test-only-entry.ts holds re-exports and one unique <APP>_TEST_BUILD_ONLY sentinel; every
export is read through TEST_ONLY?. outside the test-only folders.prepareRootKits returns testHooks?.services ?? device and createRootKits
registers TEST_ONLY?.createDebugKit (TestHooksRoot in the motion slot, the (debug) group
opened); the root files are the canonical ones, unedited; the group layout is a plain Slot
and both leaf routes redirect in production.contracts/debug-links.json equals the registry; a bad link shows debug.setup-error.testOnlyFolders; tests, typecheck, ESLint and knip pass.check-variant-bundle (the sentinel in development, absent in production).node ${CLAUDE_SKILL_DIR}/scripts/check-test-hooks.mjs . prints RESULT: PASS. Allowed:
SKIP contracts/architecture.json [test-only-folders] not yet created (architecture-and-boundaries creates it),
NOT APPLICABLE: the app has no test-only code: ... before this skill is adopted, and the
note: link-route line on React Navigation.const IS_TEST_BUILD = ... in a config file, then IS_TEST_BUILD ? require(...) : null.
Metro keeps the module in production. The literal comparison, in the gate.if (__DEV__) showDebugMenu(). Strips the menu from the preview builds testers use, and keeps
nothing out of the bundle. Read TEST_ONLY?.DebugMenuRoot.TEST_ONLY and redirect when it is undefined.TestOnlyApi with @public tags or knip ignores to quiet it. Derive the type.Linking.addEventListener('url') handler for debug links. It misses the launch link and
duplicates the router; let Expo Router open the route.offline=true. Refuse the link; booleans are 0/1.setDate() that replaces nowMs(), or a "simulate offline" that patches one screen. Wrap the
port once, in the startup.services.connectivity stays
the device adapter and TanStack Query never hears the switch; let createTestHooks swap it inside.xcrun simctl openurl for a debug link, or adb -s <serial> shell am start -d with the URL
quoted once. iOS waits on an "Open in …?" alert nobody accepts; the device shell cuts the URL at
&. Use the Maestro subflow with the guarded accept step (references/debug-deep-link.md).<Redirect> in the (debug) group layout. navigation-and-routing's flow-by-guard fails it,
and Stack.Protected plus the leaf routes' redirects already keep production out.| File | What it is | Read/run when |
|---|---|---|
references/gate-and-entry.md | Owners, the gate, the derived type (knip measurement), the manifest, the sentinel, test-only folders, the measured strip proof, pitfalls | Workflow step 1, always |
references/debug-deep-link.md | The URL, Expo Router delivery on iOS and Android, the link screen's order, strict parsing, idempotence, tool commands, adding a parameter | Workflow steps 1 and 6 |
references/simulated-clock-and-connectivity.md | createTestHooks, the clock and network wrappers, the switches store, the kv persistence, tests, pitfalls | Workflow steps 1 and 6 |
references/wiring-and-menu.md | The startup order, the four edits, the debug routes, the menu, other skills' hooks, what is left out | Workflow steps 4 and 5 |
references/checker.md | Every rule, the SKIP, NOT APPLICABLE and note lines, configuration keys, multi-package, the self-test | Workflow step 9, a FAIL line |
templates/src/test-only.ts | The gate | Workflow step 3 |
templates/src/test-only-entry.ts | The entry: re-exports and the sentinel | Workflow step 3 |
templates/src/services/test-hooks/ | createTestHooks, the simulated clock and connectivity, DebugSettingsTarget (+ tests) | Workflow step 3 |
templates/src/services/debug-storage/ | The storage port, the kv-store adapter and the fake (+ tests) | Workflow step 3 |
templates/src/stores/debug-overrides/ | The switches: codec, reducer, cases, store, selectors (+ tests) | Workflow steps 3 and 6 |
templates/src/features/debug/ | The registry and plan, the link screen and the menu (model, view, root), TestHooksRoot and the debug kit debug-root-kit.tsx (canonical, synced), the model, gate and route tests | Workflow steps 3 and 6 |
templates/src/app/(debug)/ | The group layout, /debug and /debug/setup routes | Workflow step 3 |
templates/src/i18n/catalogs/en.json | The debug.* keys in the source language (merged into the app's catalog) | Workflow step 3 |
templates/src/i18n/catalogs/ar.json | The same keys in the RTL example locale | Workflow step 3 |
templates/contracts/debug-links.json | The link contract (mirrors the registry; a synced copy of the canonical file other skills' checkers read, edited only at its canonical home) | Workflow steps 3 and 6 |
templates/contracts/debug-links.schema.json | Its JSON schema (synced copy) | Workflow step 3 |
examples/create-root-kits.ts | The app's root-kit registry with the test build's lines: prepareRootKits (the hooks, their services) and the debug kit (also the self-test's base) | Workflow step 5 |
examples/settings-target.ts | A DebugSettingsTarget over the settings store and the direction restart | Workflow step 5 |
examples/debug-setup-flow.yaml | A Maestro subflow that opens the link, accepts iOS's "Open in …?" alert (guarded) and proves the state | Writing flows (hand to e2e-maestro) |
scripts/check-test-hooks.mjs | The checker (13 rules) | Workflow step 9 |
scripts/lib/hook-probes.mjs | Its behaviour probes (registry, clock, connectivity) | Never by hand |
scripts/selftest.mjs | Proves the checker against tests/fixtures/ | After changing the checker |
scripts/check-lib.mjs | Synced checker library (do not edit here) | Never by hand |
scripts/lib/app-modules.mjs | Synced: loads the app's pure TypeScript for the probes | Never by hand |
scripts/lib/source-scan.mjs | Synced: import resolution and test-file detection | Never by hand |
tests/fixtures/ | Overlay cases: good, one bad per rule, pass and error cases | After changing the checker |
tests/bases/ | The minimal app the cases start from (with synced canonical files) | After changing the checker |
assets/shared.json | The synced-file manifest | When a shared file is added |
app-startup-and-bootstrap - the root slots the debug kit fills (prepareRootKits, motion, opensDebugRoutes).app-variants-and-environment - the literal-comparison rule, the Metro cache key and the bundle proof.architecture-and-boundaries - the import side of the gate, testOnlyFolders, the composition root.navigation-and-routing - Stack.Protected for the debug group and the startup skeleton.e2e-maestro - flows that open the debug link and wait on testIDs.ios-simulator-build - the sentinel in a built .app and the ready marker.dates-streaks-and-statistics - useToday() and what a simulated day must keep real.networking-and-server-state - the ConnectivityPort and its hub.state-management-zustand - the store rules the switches follow.motion-and-animation, skia-canvas-rendering, audio-and-haptics-feedback - motion held still, canvas probes, recorded feedback.assets/shared.json (opens in a new tab)examples/create-root-kits.ts (opens in a new tab)examples/debug-setup-flow.yaml (opens in a new tab)examples/settings-target.ts (opens in a new tab)references/checker.md (opens in a new tab)references/debug-deep-link.md (opens in a new tab)references/gate-and-entry.md (opens in a new tab)references/simulated-clock-and-connectivity.md (opens in a new tab)references/wiring-and-menu.md (opens in a new tab)scripts/check-lib.mjs (opens in a new tab)scripts/check-test-hooks.mjs (opens in a new tab)scripts/lib/app-modules.mjs (opens in a new tab)scripts/lib/hook-probes.mjs (opens in a new tab)scripts/lib/source-scan.mjs (opens in a new tab)scripts/selftest.mjs (opens in a new tab)templates/contracts/debug-links.json (opens in a new tab)templates/contracts/debug-links.schema.json (opens in a new tab)templates/src/app/(debug)/_layout.tsx (opens in a new tab)templates/src/app/(debug)/debug/index.tsx (opens in a new tab)templates/src/app/(debug)/debug/setup.tsx (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/react-native:debug-menu-and-test-hooksfrom react-native
npx claudepluginhub zakariaf/reactnative-skills --plugin react-native73 skills in this plugin
/accessibility-as-codeEnforces a11y labels, 44pt targets, 200% text, VoiceOver, TalkBack. Use when adding a pressable, swipe or a11y label, text clips when large, contrast fails or Reduce Motion is missed. Not for RTL (rtl-and-direction)./adaptive-layoutLays screens out by window, not device: breakpoints, master-detail panes, readable widths, grids. Use when making screens responsive or for tablets, iPad, foldables, rotation, split screen, orientation lock. Not for tab bars (navigation-and-routing)./admob-ads-and-consentBuilds AdMob ads behind a port - banners, interstitials, rewarded, UMP consent then ATT, pacing, ADS_MODE test IDs. Use when touching ads, consent, ATT, ad IDs or rewarded perks. Not for purchases (in-app-purchases).Other plugins' skills for the same job