@@ -39,6 +39,52 @@ For cross-platform changes, use the repo-wide aggregates: `dev lint`,
3939`dev <platform> format` for formatting; `fix` remains an alias for existing
4040workflows.
4141
42+ ## Worktrees
43+
44+ Use git worktrees to isolate feature work. **Auto-create a worktree** when
45+ starting a self-contained task that benefits from isolation (a new feature or a
46+ standalone fix) — you don't need to ask first.
47+
48+ - **Location:** create worktrees under a `worktrees/` directory at the repo
49+ root. `**/worktrees/` is gitignored, so worktree checkouts never appear as
50+ untracked changes.
51+ - **Branch naming:** name branches `<area>/<topic>`, where `<area>` is the
52+ platform or subsystem and `<topic>` is a short kebab-case description.
53+ Examples: `web/css-minify`, `swift/deeplink-cancel`,
54+ `protocol/full-envelope`, `android/maven-local-fix`, `ci/draft-pr-checks`.
55+ - **Creating:** mirror the branch in the directory path, e.g.
56+ ```bash
57+ git worktree add worktrees/web/css-minify -b web/css-minify
58+ ```
59+
60+ ### Before running ` dev up ` in a new worktree
61+
62+ A fresh worktree is a clean checkout and does ** not** include the gitignored
63+ root ` .env ` that sample app setup reads from. From inside the new worktree, run:
64+
65+ ``` bash
66+ dev copy-env # copies the root .env (and other root-level config) from the main checkout
67+ dev up # regenerates all nested sample config (Android/Swift/RN) from it
68+ ```
69+
70+ ` dev copy-env ` copies only the root-level source-of-truth files; ` dev up ` 's
71+ ` setup_storefront_env ` step regenerates the nested sample configuration
72+ (Android ` .env ` , Swift ` Storefront.xcconfig ` , RN sample ` .env ` ) from the root
73+ ` .env ` , so those do not need to be copied by hand. Treat all of these as
74+ sensitive (see ** Sensitive configuration** ) — never print or commit their
75+ contents. Remember the ` shadowenv exec --dir <worktree_path> -- ` prefix when
76+ running these outside an interactive shell.
77+
78+ ### Cleanup
79+
80+ When the branch has merged or the work is abandoned, remove the worktree and
81+ delete the branch:
82+
83+ ``` bash
84+ git worktree remove worktrees/< area> /< topic> # add --force if it has throwaway changes
85+ git branch -d < area> /< topic>
86+ ```
87+
4288## Swift Xcode builds
4389
4490Prefer the ` dev swift ... ` commands for Swift package and sample builds. When
0 commit comments