Skip to content

Commit f66a39d

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Update AGENTS.md (#58099)
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
1 parent c35d3b4 commit f66a39d

1 file changed

Lines changed: 30 additions & 15 deletions

File tree

AGENTS.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
A framework for building native applications using React.
44

5-
This file provides guidance for coding agents working in this repository.
6-
75
## Repo structure
86

97
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
2220

2321
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.
2422

25-
## Common commands
23+
## Environment
2624

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
2830

2931
| Command | Purpose |
3032
| --- | --- |
3133
| `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`) |
3536
| `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.
3740

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"`.
3946

4047
## Gotchas
4148

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.
4661

4762
## Contributing guidelines
4863

4964
- Keep each change focused — no unrelated refactors, formatting, or dependency updates.
5065
- 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.
5267

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

Comments
 (0)