Skip to content

[codex] add worktree-safe Nx setup for Codex environments#4448

Merged
ScriptedAlchemy merged 3 commits intomainfrom
codex/nx-worktree-setup
Feb 15, 2026
Merged

[codex] add worktree-safe Nx setup for Codex environments#4448
ScriptedAlchemy merged 3 commits intomainfrom
codex/nx-worktree-setup

Conversation

@ScriptedAlchemy
Copy link
Copy Markdown
Member

@ScriptedAlchemy ScriptedAlchemy commented Feb 15, 2026

Problem

Running this repo in multiple Git worktrees can produce unstable Nx daemon behavior (for example intermittent missing project graph state across worktrees). This aligns with Nx issue nrwl/nx#31447, where NX_DAEMON=false was a reliable workaround.

Codex setup in this repo currently used a plain pnpm install, which does not apply that workaround automatically in worktree environments.

Root Cause

Nx daemon/workspace-data behavior can become inconsistent between sibling worktrees that represent different branch states. That inconsistency can surface as project graph errors or missing project resolution.

Fix

This PR adds worktree-aware setup and command wrappers without changing pnpm store locations:

  • Add scripts/codex-setup.sh
    • Detects Git worktree by comparing git-dir and git-common-dir
    • In worktrees: runs NX_DAEMON=false pnpm install
    • Primes project graph cache via NX_DAEMON=false pnpm exec nx show projects --json
    • In main checkout: runs normal pnpm install
  • Add scripts/nx-worktree.sh
    • Runs Nx with NX_DAEMON=false only in worktrees
  • Add npm scripts in package.json
    • setup:codex => ./scripts/codex-setup.sh
    • nx:safe => ./scripts/nx-worktree.sh

Validation

  • Installed deps in a clean branch and confirmed Husky hooks were properly bootstrapped (.husky/_/husky.sh)
  • Shell syntax checks passed for both scripts
  • package.json parses cleanly
  • Manual external-worktree check:
    • scripts/codex-setup.sh --frozen-lockfile
    • scripts/nx-worktree.sh show projects --json
    • Verified worktree-safe path executes successfully with daemon disabled in worktree context

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 15, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 2c38281
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/699230afd8fcb400085161d0
😎 Deploy Preview https://deploy-preview-4448--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 15, 2026

⚠️ No Changeset found

Latest commit: 2c38281

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy ScriptedAlchemy changed the title chore: add worktree-safe nx setup scripts [codex] add worktree-safe Nx setup for Codex environments Feb 15, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 15, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/devtools@4448

@module-federation/cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/cli@4448

create-module-federation

pnpm add https://pkg.pr.new/module-federation/core/create-module-federation@4448

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/data-prefetch@4448

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/dts-plugin@4448

@module-federation/enhanced

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/enhanced@4448

@module-federation/error-codes

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/error-codes@4448

@module-federation/managers

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/managers@4448

@module-federation/manifest

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/manifest@4448

@module-federation/metro

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro@4448

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnc-cli@4448

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnef@4448

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/modern-js-v3@4448

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/retry-plugin@4448

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rsbuild-plugin@4448

@module-federation/rspack

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspack@4448

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspress-plugin@4448

@module-federation/runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime@4448

@module-federation/runtime-core

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-core@4448

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-tools@4448

@module-federation/sdk

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/sdk@4448

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/third-party-dts-extractor@4448

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-frontend@4448

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-server@4448

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/webpack-bundler-runtime@4448

@module-federation/bridge-react

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react@4448

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react-webpack-plugin@4448

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-shared@4448

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-vue3@4448

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/inject-external-runtime-core-plugin@4448

commit: 15854cb

@github-actions
Copy link
Copy Markdown
Contributor

Bundle Size Report

No bundle size changes detected.

Total dist: 6.66 MB (no change)
Total ESM gzip: 138.1 kB (no change)

@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review February 15, 2026 20:43
@ScriptedAlchemy ScriptedAlchemy merged commit 2ced0e8 into main Feb 15, 2026
13 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the codex/nx-worktree-setup branch February 15, 2026 20:49
@2heal1 2heal1 mentioned this pull request Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant