This file provides guidance to agents when working with code in this repository.
rnx-kit is a monorepo of React Native tooling created by Microsoft. It
provides battle-tested tools for dependency management, Metro bundling
enhancements, TypeScript integration, and cross-platform development (iOS,
Android, macOS, Windows).
packages/- Stable, published packages (e.g.,@rnx-kit/cli,@rnx-kit/align-deps,@rnx-kit/metro-*)incubator/- Experimental packages (marked with"experimental": truein package.json)scripts/- Internal build tooling (rnx-kit-scriptsCLI)docsite/- Documentation website (separate Yarn workspace with its ownyarn.lock; not in rootworkspaces).changeset/- Changeset configuration for versioning
Uses Nx for task orchestration with Yarn Berry workspaces. Node linker
is pnpm. Required Node.js version: see engines.node in the root
package.json.
rnx-kit-scripts build runs the tsc binary from typescript (version: see
catalog.typescript in .yarnrc.yml). In Nx, build depends on lint, so
building a package also lints it.
yarn # Install dependencies
yarn build # Build all packages
yarn build-scope <pkg> # Build specific package with dependencies (e.g., yarn build-scope @rnx-kit/cli)
yarn test # Build and test all packages
yarn lint # Lint all packages
yarn format # Format all packages
yarn clean # Clean build artifacts (git clean)
yarn show-affected # Show affected projects
yarn update-readme # Regenerate API docs in READMEs (TypeDoc)yarn build # Build current package only
yarn build --dependencies # Build current package and its dependencies
yarn test # Run tests
yarn lint # Lint current package
yarn format # Format current package- Default test runner: Node.js built-in test runner (
node:test) — most packages use this - Jest: Used only by packages that have a
"jest"field inpackage.jsonor ajest.config.js(seeuseJest()inscripts/src/commands/test.js) - The
rnx-kit-scripts testcommand auto-detects which runner to use - Tests live in
test/directories with.test.ts(or.test.mtsfor ESM) extension - Run specific test:
yarn test path/to/file.test.ts(from package directory)
Node test runner style:
import { equal } from "node:assert/strict";
import { describe, it } from "node:test";- Passing any argument to
yarn testdisables the default test glob (seescripts/src/commands/test.js), so include it explicitly, e.g.yarn test --coverage 'test/**/*.test.ts'for coverage - Source files that use bare
require: seepackages/tools-react-native/test/metro.test.mts - Modules with a
require.main === moduleguard: seepackages/third-party-notices/test/index.test.ts - Code that reads or writes files: use
@rnx-kit/tools-filesystem/mocks(seepackages/tools-filesystem/src/mockfs/index.tsandpackages/cli/test/bundle/metro.test.tsfor usage) or checked-in fixtures instead of temporary directories. Don't change production APIs solely to enable mocking - Fixtures that need a
node_modulesfolder: see the__fixtures__exception in the root.gitignore - Inspect and reuse existing fixtures and helpers before creating new ones; add only missing scenarios, and don't remove or weaken existing assertions
- Do not override globals or system values in tests (e.g.
process.platform) unless absolutely necessary, such as settingglobal.requirefor sources loaded as ESM (seepackages/tools-react-native/test/metro.test.mtsfor how to set it inbefore()and restore it inafter())
yarn build:ci # Build and test affected packages
yarn build:ci:all # Build and test ALL packages
yarn bundle:ci # Bundle affected packages
yarn change:check # Verify change files exist (CI passes --since origin/<base>)- Each package uses
rnx-kit-scriptsfor build/test/lint/format commands - TypeScript source in
src/, compiled output inlib/ - Entry point typically at
src/index.ts - Standard dev dependencies:
@rnx-kit/scripts,@rnx-kit/tsconfig @rnx-kit/jest-presetis only added when a package uses Jest (not default)- Packages share the root lint configuration; a package may override it with its
own config (see
scripts/src/commands/lint.jsfor which tool and config files are used) - Many published packages use a
"typescript"export condition pointing tosrc/index.tsfor development - Files named
types.tsmay only contain type exports (enforced by thetype-definitions-onlylint rule)
yarn new-package <name> # Creates in packages/
yarn new-package <name> --experimental # Creates in incubator/Uses packages/template as baseline; see scripts/new-package.ts for the
initial version and other manifest fields it sets. Adds an experimental banner
for incubator packages.
Uses Changesets for versioning:
yarn change # Create change file for PROne change file per feature/fix. No need for multiple entries when addressing PR
feedback. Releases are automated via CI — on merge to main, the changesets
action creates a release PR or publishes to npm.
Don't add change files for private packages ("private": true), e.g.
@rnx-kit/template and test apps.
Follow .github/pull_request_template.md. Write the description for reviewers
and users: give an overview of the change and explain the reasoning behind it,
such as the motivation, alternatives considered and why they were rejected,
breaking changes, and user-facing impact. Skip implementation details that can
be inferred from the diff, such as file-by-file summaries or how the code was
changed.
Verify each finding before reporting it. Reproduce it with a test, a command or
the relevant source (including dependencies in node_modules), and cite the
evidence. Don't report a finding based only on how the code might behave, for
example assuming what a token can access, what shape a dependency's output has,
or that a third-party service or API is still available. If a finding can't be
verified, say so and explain what would confirm it, or leave it out. Order
findings by impact, and separate confirmed bugs from suggestions.
@rnx-kit/cli- Main CLI (rnx-cli) integrating all tools@rnx-kit/align-deps- Dependency version alignment across repos@rnx-kit/metro-*- Metro bundler plugins (TypeScript, config, tree-shaking, duplicate detection, cyclic deps)@rnx-kit/tools-*- Platform-specific utilities (android, apple, node, react-native, filesystem, shell, workspaces, etc.)@rnx-kit/config- Configuration loading frompackage.jsonrnx-kitfield@rnx-kit/eslint-plugin- Custom lint rules (seepackages/eslint-plugin/src/rules/for the current list)@rnx-kit/oxlint-config- Shared oxlint config;packages/oxlint-config/private.tsis the config used by this repo@rnx-kit/eslint-config- ESLint config published for consumers; not used to lint this repo@rnx-kit/typescript-react-native-resolver- TypeScript resolver for React Native
The repo uses align-deps to maintain consistent dependency versions. Run from
root:
yarn rnx-align-deps --write # Fix misaligned dependenciesThese all run in CI and should pass before merging:
yarn format # Formatting
yarn lint # Linting
yarn rnx-align-deps --write # Dependency alignment
yarn constraints --fix # Yarn constraints (consistent author, homepage, repository fields)
yarn knip # Detect unused dependencies
yarn dedupe --check # Prevent package duplicates in lockfile
node scripts/lint-tsconfig.ts # Validate TypeScript configs
node scripts/lint-node-version.ts # Prevent lowering minimum Node versions
yarn update-readme # Regenerate API docsCI uses suggestion-bot to post code review suggestions for format,
constraints, align-deps, and readme issues.
After creating a pull request, or pushing changes to one, run the evals and post the report on the pull request:
cd evals
yarn eval:reportThis audits the current session and posts the report as a comment. Do not edit
the report. Post it again after every push; if there is no report for the latest
commit, the Agent evals workflow replaces it with an audit of the diff.
- When triaging issues, ignore the issue titled "Dependency Dashboard" (opened
by Renovate). It tracks dependency updates (see
.github/renovate.json) and is not a real bug or feature request.
- Test apps:
packages/test-app(iOS/Android),packages/test-app-macos,packages/test-app-windows - Native builds require platform toolchains (Xcode, Android Studio, Visual Studio)
- CocoaPods installation is handled in CI via
microsoft/react-native-test-appGitHub actions
- Run
yarn formatandyarn lintbefore committing (CI enforces both) - Don't format, lint or build by hand or call the underlying tools (e.g.
oxfmt,oxlint,tsc) directly — thernx-kit-scripts format,lintandbuildcommands (scripts/src/commands/) decide which tools and configs are used - The formatter also sorts imports and
package.jsonfields - Prefer consuming existing helpers over redesigning shared internals. Ask before adding new shared abstractions; optimize for total complexity, not individual file length