Skip to content

Commit e687fe6

Browse files
Saadnajmiclaude
andcommitted
docs: add backporting guide and Claude Code project guidelines
Add a contributing guide for backporting changes to stable branches, covering branch naming conventions, commit message scoping, and the workflow for creating matching PRs. Also add CLAUDE.md with project context for Claude Code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1861bd3 commit e687fe6

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

CLAUDE.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# React Native macOS - Claude Code Guidelines
2+
3+
## Repository structure
4+
5+
This is a monorepo fork of React Native with macOS support. Key directories:
6+
- `packages/react-native/` — Main `react-native-macos` package
7+
- `packages/virtualized-lists/` — Forked `@react-native-macos/virtualized-lists`
8+
- `packages/nx-release-version/` — Internal versioning tooling (private)
9+
- `private/` — Internal packages (eslint plugins, test utils)
10+
- `docsite/` — Docusaurus documentation site
11+
- `scripts/releases/` — Release and version bump scripts
12+
13+
## Branching and backporting
14+
15+
When making changes that apply to both `main` and a stable branch (e.g., `0.81-stable`):
16+
17+
1. **Branch naming**: Use `<name>` for main, `0.81/<name>` for stable
18+
2. **Commit messages**: Use `fix: ...` for main, `fix(0.81): ...` for stable
19+
3. **Code parity**: Code changes should be identical between branches — only version numbers and branch-specific values should differ
20+
4. **Create two PRs**: One targeting `main`, one targeting the stable branch
21+
22+
Example:
23+
```shell
24+
# Main branch
25+
git checkout -b fix-something main
26+
# make changes, commit, push
27+
28+
# Stable branch
29+
git checkout -b 0.81/fix-something 0.81-stable
30+
# apply same changes, commit, push
31+
32+
# Create PRs for both
33+
gh pr create --base main --head fix-something
34+
gh pr create --base 0.81-stable --head 0.81/fix-something
35+
```
36+
37+
## Versioning
38+
39+
- **`@react-native/*` packages**: Track upstream React Native version (from `react-native-macos`'s peerDependency on `react-native`). These are all private in this fork.
40+
- **`react-native-macos` + `@react-native-macos/virtualized-lists`**: Track the macOS release version. Published to npm.
41+
- **`@react-native-macos/nx-release-version`**: Private internal tooling, pinned to `0.1.0`.
42+
- Releases are done via `yarn nx release` on stable branches.
43+
- Run `yarn constraints` to verify version consistency. Use `yarn constraints --fix` to auto-fix.
44+
45+
## Testing changes
46+
47+
- `yarn constraints` — Verify monorepo version consistency
48+
- `yarn eslint` — Lint check (includes package.json manifest rules)
49+
- `yarn jest` — Run tests
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
sidebar_label: 'Backporting changes'
3+
sidebar_position: 4
4+
---
5+
6+
# Backporting changes to stable branches
7+
8+
When a fix or feature lands on `main`, it often needs to be backported to an active stable branch (e.g., `0.81-stable`). To keep code changes consistent between branches, we create matching PRs against both `main` and the stable branch.
9+
10+
## Branch naming convention
11+
12+
| Target branch | PR branch name |
13+
|---|---|
14+
| `main` | `<name>` |
15+
| `0.81-stable` | `0.81/<name>` |
16+
17+
For example, for a fix called `fix-release-constraints`:
18+
- `fix-release-constraints` → targets `main`
19+
- `0.81/fix-release-constraints` → targets `0.81-stable`
20+
21+
## Step-by-step guide
22+
23+
### 1. Create the main branch first
24+
25+
```shell
26+
git checkout -b fix-something main
27+
# Make your changes
28+
git commit -m "fix: description of the fix"
29+
git push origin fix-something
30+
```
31+
32+
### 2. Create the stable branch with the same changes
33+
34+
```shell
35+
git checkout -b 0.81/fix-something 0.81-stable
36+
# Apply the same code changes (cherry-pick, manual, etc.)
37+
git commit -m "fix(0.81): description of the fix"
38+
git push origin 0.81/fix-something
39+
```
40+
41+
:::tip
42+
Code changes should be identical between both branches. The only differences should be version numbers or other branch-specific values that naturally differ between `main` and stable.
43+
:::
44+
45+
### 3. Create two PRs
46+
47+
- One PR from `fix-something``main`
48+
- One PR from `0.81/fix-something``0.81-stable`
49+
50+
Use the `(0.81)` scope in the commit message and PR title for the stable branch version:
51+
- `main`: `fix: description of the fix`
52+
- `0.81-stable`: `fix(0.81): description of the fix`
53+
54+
### Cherry-picking as an alternative
55+
56+
If the changes apply cleanly, you can cherry-pick from the main branch:
57+
58+
```shell
59+
# After committing on the main branch
60+
git checkout -b 0.81/fix-something 0.81-stable
61+
git cherry-pick <commit-sha-from-main>
62+
# Resolve any conflicts, then push
63+
git push origin 0.81/fix-something
64+
```
65+
66+
### Running constraints after changes
67+
68+
After making changes on a stable branch, always verify that yarn constraints pass:
69+
70+
```shell
71+
yarn constraints
72+
```
73+
74+
If there are violations, you can auto-fix them:
75+
76+
```shell
77+
yarn constraints --fix
78+
```

0 commit comments

Comments
 (0)