You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
Further updates to AGENTS.md, motivated by cloning this repo in additional environments (Cursor Cloud).
**Changes**
Restructure the guidance around what an agent needs to know before it starts, and correct several details against the repo.
- Add an Environment section covering the package manager and which toolchain each surface needs.
- Rescope Gotchas to the Yarn install and codegen build rough edges.
- Correct the commands table: `yarn format-check` checks Prettier only, `yarn fantom` builds a native tester on first run, and JavaScript CI is the `lint`, `test_js`, and `build_js_types` jobs.
- Separate RNTester into its own section.
Changelog: [Internal]
Pull Request resolved: #58099
Test Plan: —
Reviewed By: christophpurrer
Differential Revision: D117215889
Pulled By: Abbondanzo
fbshipit-source-id: 29f83724bbf09540d16cc6fe6b904aa8d11f6e30
Copy file name to clipboardExpand all lines: AGENTS.md
+30-15Lines changed: 30 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,6 @@
2
2
3
3
A framework for building native applications using React.
4
4
5
-
This file provides guidance for coding agents working in this repository.
6
-
7
5
## Repo structure
8
6
9
7
React Native is a monorepo: the `react-native` package, the packages published alongside it, and the apps and tooling used to develop them.
@@ -22,32 +20,49 @@ React Native is a monorepo: the `react-native` package, the packages published a
22
20
23
21
Architecture notes live in `__docs__` directories beside the code they describe, indexed by [`__docs__/README.md`](__docs__/README.md). Treat them as reference for the subsystem you are working in, not as required reading.
24
22
25
-
## Common commands
23
+
## Environment
26
24
27
-
Run these from the repository root:
25
+
- Yarn v1, pinned via `packageManager`. Run commands from the repository root.
26
+
- JavaScript work — lint, type checks, Jest, Metro — needs only Node and Yarn, on any platform.
27
+
- Native builds need a platform toolchain: Xcode with CocoaPods or Swift Package Manager for iOS (macOS only), and the Android SDK and NDK with Gradle for Android. See [Building from source](https://reactnative.dev/contributing/how-to-build-from-source).
28
+
29
+
## Common commands
28
30
29
31
| Command | Purpose |
30
32
| --- | --- |
31
33
|`yarn test <path>`| Jest unit tests, found in `__tests__` directories |
32
-
|`yarn fantom <path>`|[Fantom](private/react-native-fantom/__docs__/README.md) integration tests, named `*-itest.js`|
33
-
|`yarn lint`| ESLint |
34
-
|`yarn format`| Prettier and clang-format |
34
+
|`yarn fantom <path>`|[Fantom](private/react-native-fantom/__docs__/README.md) integration tests, named `*-itest.js` — builds a native tester on first run |
35
+
|`yarn lint`| ESLint (`--max-warnings 0`) |
35
36
|`yarn flow-check`| Flow |
36
-
|`yarn start`, `yarn android`| Metro, and RNTester on Android. See [RNTester](packages/rn-tester/README.md) for iOS |
37
+
|`yarn format`| Prettier and clang-format (`yarn format-check` for Prettier only) |
38
+
39
+
JavaScript CI is the `lint`, `test_js`, and `build_js_types` jobs in [`.github/workflows/test-all.yml`](.github/workflows/test-all.yml); Fantom and the native platforms have their own jobs.
37
40
38
-
Native builds use Gradle on Android, and CocoaPods or Swift Package Manager on iOS. See [Building from source](https://reactnative.dev/contributing/how-to-build-from-source).
41
+
### Verification: Running RNTester
42
+
43
+
Needed only for changes that have to be seen running, such as user interface behavior.
44
+
45
+
`yarn start` serves [RNTester](packages/rn-tester/README.md) over Metro at `http://localhost:8081`; `yarn android` builds and installs it on Android. Check the bundler with `curl "http://localhost:8081/js/RNTesterApp.bundle?platform=ios&dev=true"`.
39
46
40
47
## Gotchas
41
48
42
-
- JavaScript sources are typed with Flow, and the public API is exported from `packages/react-native/index.js`. TypeScript types are generated from those sources, and `packages/react-native/ReactNativeApi.d.ts` is a committed snapshot of that API — run `yarn build-types` to regenerate both whenever the public API changes.
43
-
- The public native API is snapshotted as well: C++ under `scripts/cxx-api` (`yarn cxx-api-build`), and Android in `packages/react-native/ReactAndroid/api/ReactAndroid.api`. CI validates both.
44
-
- Native modules and components are declared by JavaScript specs (`Native*.js`, `*NativeComponent.js`), from which their native counterparts are generated. Do not hand-edit generated code.
45
-
-`CHANGELOG.md` is compiled at release time. Changelog entries belong in the pull request description.
49
+
-`yarn install` dirties the working tree: a `preinstall` hook (`scripts/try-set-hermes-compiler-prebuilt.js`) resolves the `hermes-compiler` placeholder in `packages/react-native/package.json` (`0.0.0` → a real version) and touches `yarn.lock`. Expected — do not commit it.
50
+
- Metro cannot bundle until codegen is built once — `yarn --cwd packages/react-native-codegen build`. Without it, bundling fails with `Cannot find module '@react-native/codegen/lib/parsers/flow/parser'`. Every other package runs from source — `yarn build` is not needed for development (see [`scripts/build/README.md`](scripts/build/README.md)).
51
+
52
+
## Generated code
53
+
54
+
Never hand-edit generated output — change the source and regenerate. CI validates the committed snapshots.
55
+
56
+
- Native modules and components are declared by JavaScript specs (`Native*.js`, `*NativeComponent.js`); their native counterparts are generated at build time.
57
+
- Feature flags are declared in `packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js`; `yarn featureflags` regenerates the JavaScript, Java, and C++ accessors.
58
+
- JavaScript sources are typed with Flow, and the public API is exported from `packages/react-native/index.js`. TypeScript types are generated from those sources, and `packages/react-native/ReactNativeApi.d.ts` is a committed snapshot of that API — run `yarn build-types` to regenerate both whenever the public API changes, then `yarn test-generated-typescript` to type-check the result.
59
+
- The public native API is snapshotted as well: C++ under `scripts/cxx-api` (`yarn cxx-api-build`), and Android in `packages/react-native/ReactAndroid/api/ReactAndroid.api`.
60
+
-`CHANGELOG.md` is compiled at release time from pull request descriptions.
46
61
47
62
## Contributing guidelines
48
63
49
64
- Keep each change focused — no unrelated refactors, formatting, or dependency updates.
50
65
- Complete the pull request template — the motivation and the user-visible effect, and a [changelog entry](https://reactnative.dev/contributing/changelogs-in-pull-requests) with its category and type tags.
51
-
- In the test plan, give the exact commands you ran and their results, plus screenshots or a video for user-interface changes.
66
+
- In the test plan, give the exact commands you ran and their results, plus screenshots or a video for user-interface changes. Say which checks you could not run.
52
67
53
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full process, including how to report bugs.
68
+
The full process is on [reactnative.dev](https://reactnative.dev/contributing/overview).
0 commit comments