How to use Claude Code on a React Native project: what I add for the bugs that throw no error
Claude Code writes React Native as well as any TypeScript. What it misses are the bugs that throw no error: a list that no longer scrolls, a style that is ignored, a test that never ends. On my apps I add four things: a gotchas file imported by `CLAUDE.md`, which the agent extends whenever something fails without an error, a check script that prints only what is broken and names the stuck test, one agent at a time on the simulator and Metro, and dedicated commands for review and dependencies.
The problem: the worst mobile bugs are silent
On a web or backend project, an error almost always shows up somewhere: a type, a test, a stack trace. In React Native, a good share of bugs leave no trace at all. Two examples from ResellStats, one of my apps:
- A `Pressable` around a `ScrollView` stops scrolling. The list renders correctly and simply refuses to move. No error, no warning.
- A NativeWind class on a Reanimated component does nothing. The code compiles, the tests pass, the style is never applied.
An agent that sees green tests and clean types declares the work done. It is right by everything it can observe. The bug only shows on the device, and often only after one specific gesture.
My method: write down what the code does not say
- A gotchas file, loaded in every session. The project
CLAUDE.mdholds the line@docs/gotchas.md, which imports that file. It only contains what you cannot see by reading the code you are about to change. - An instruction to fill it. Before claiming work is done, the agent checks four triggers: it rebuilt something that already existed, something failed with no error, I corrected it on a fact about the project, it worked around some debt. The second one is marked as the most valuable, because those are the bugs that cost an hour.
- React Native rules in the project `CLAUDE.md`. For example: no NativeWind on a Reanimated component, use a
StyleSheetinstead. Every piece of text goes through a translation key. - A check script that shows only errors. Lint, types and tests, one summary line when everything passes. A
--fastoption runs only the tests related to changed files, and a deadline makes it printHUNG:with the name of every suite that never answered. I explain what this filtering saves in the article on tokens. - One agent on the device. There is one simulator and one Metro server. I run agents in parallel to read code, never to drive the app. My React Native review follows that rule: four angles at once, design, accessibility, performance and security, and none of them touches a file.
- A command for dependencies.
/my-depsrunsnpx expo-doctor@latest, looks for outdated or unused packages, then checks suspicious libraries on the web. Its instructions forbid flagging a library as abandoned without a real public signal, such as an archived repository or a deprecation notice.
A real example: the test that never ended
On August 12, a test suite ran for more than 300 seconds, then Jest killed the worker running it, out of memory. No assertion had failed. For five minutes, the diagnosis was "the machine is slow".
The cause was in the test, not in the app. A hook was mocked by a function that returned a new object on every call. The component had an effect that depended on that object: on every render the object changed, the effect ran again, and the loop never stopped. The real hook keeps its value in a useState, so it does not change between renders, and production had no bug.
Two things came out of it:
- The script now names the hang. After the deadline, it prints
HUNG:followed by every suite that returned no result, with a reminder of the usual cause. - A line in the gotchas file. A mocked value the component depends on is declared once, as a module constant, and not rebuilt on every call.
The gotchas file holds other cases of the same kind. After adding a new screen, the type check fails with an error that quotes the list of routes, while the real cause is a types file generated by Expo that only starting Metro updates. In late October, a review found a dead button: a double tap guard set with useRef was never released, because in a native navigation stack the previous screen stays mounted. The test checked the guard, not its release. Since then, an instruction that adds a guard must say when it is released, and a test must prove it.
What went wrong
- The gotchas file grew too big. It now holds 196 gotchas and more than 110,000 characters. It loads in full in every session: the Claude Code documentation states that an import does not reduce context cost, and advises staying under 200 lines per
CLAUDE.md. The path it suggests is to move what concerns only part of the code into rules in.claude/rules/scoped to certain paths, which load only when Claude touches those files. - A hook that did nothing. This project runs
npx tsc --noEmit 2>&1 | head -20after everyEditorWrite. While preparing this article, I reread the hooks documentation: after a tool runs, standard output with exit code 0 is not shown to Claude. Andheadalways returns 0. So type errors only reached the agent when it ran the check script itself. - A fixture changed to agree with the code. During a fix, a test state was changed to express the new rule. The tests then checked a state the real flow never produced. The rule that came out of it: a fix that changes what a state means lists everything that writes it and everything that clears it, and adds a test that goes through the real lifecycle.
How to start
- Create
docs/gotchas.md, import it from yourCLAUDE.mdwith@docs/gotchas.md, and write the instruction: when something fails without an error, a line gets added here. One or two lines per gotcha, and a gotcha that is no longer true gets deleted. - Give the agent a check script that prints only failures, with a deadline on the tests.
- Keep a single agent on the simulator. Driving it is covered in the article on the iOS simulator.
- If you want Claude to see type errors after each change, the hook must exit with code 2 and write to standard error:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npx tsc --noEmit > /tmp/tsc.log 2>&1 || { head -20 /tmp/tsc.log >&2; exit 2; }"
}
]
}
]
}
}Then let the gotchas file fill up as bugs come. It is what saves the next agent the hour the previous one lost. And to have tests catch these bugs before the device does, the method is in the article on unit tests.
Article written with the help of AI, from my daily practice and my projects.
The whole notebook