You can dogfood mx by treating its source as just another repo in an mx runtime — running several parallel feature branches of mx itself the same way you'd run parallel features of any product.
One-time, on your productive runtime:
mx repo add git@github.com:rousan/mx.gitPer feature (repeat for as many parallel mx features as you want):
mx work new improve-mx-status-ui
mx work -n improve-mx-status-ui worktree add mx --branch improve-mx-status-ui
cd "$(mx work -n improve-mx-status-ui path)"/mx
pnpm install
pnpm buildNow the source lives at <runtime>/works/improve-mx-status-ui/mx/ as its own worktree on its own branch. Each feature work is fully independent: own branch, own .mx/ sandbox if testing, own commits, own pushes. Switch between them by cd — no mode to remember.
There are two mx binaries available inside a self-hosted worktree, and they must be used for different things:
| binary | what it runs | use for |
|---|---|---|
mx (on $PATH) |
the globally installed @rousan/mx — published version |
productive runtime operations: mx i, mx work archive feat, etc. Safe against the productive runtime. |
pnpm mx ... or node npm/bin/mx.js ... |
the locally-built CLI from your in-progress code | testing only — must always be pointed at a sandbox runtime, never the productive one. |
The locally-built CLI never sees the productive runtime. Before any test, set $MX_RUNTIME to a sandbox:
export MX_RUNTIME="$PWD/.mx" # gitignored, per-worktree sandbox (recommended)
# or, for a fully throwaway one:
export MX_RUNTIME=/tmp/mx-sbx-$(date +%s)If you forget and run pnpm mx sync (or any locally-built mx) without $MX_RUNTIME pointing at a sandbox, it would re-stamp the productive runtime's CLAUDE.md with whatever template version is currently in your branch — possibly a broken WIP one. Always set $MX_RUNTIME first.
If you spend significant time in this setup, automate $MX_RUNTIME so you don't have to remember:
With direnv — create .envrc in the worktree:
export MX_RUNTIME="$PWD/.mx"direnv allow once; from then on, cding in/out of the worktree flips $MX_RUNTIME automatically.
With a shell function in your ~/.zshrc:
# In `.zshrc`
function chpwd() {
if [[ -f "$PWD/.mx-sandbox-here" ]]; then
export MX_RUNTIME="$PWD/.mx"
else
export MX_RUNTIME="$HOME/mx" # your productive runtime
fi
}Touch .mx-sandbox-here (gitignored) in each mx-feature worktree. Outside, $MX_RUNTIME stays at the productive runtime; inside, it's the sandbox.
Inside <runtime>/works/<feature>/mx/, Claude Code walks up the directory tree looking for CLAUDE.md and finds two:
- The source repo's
CLAUDE.md(this repo) — developer rules for working on mx (use pnpm, the build pipeline, etc.). - The runtime's
CLAUDE.md(stamped fromtemplates/CLAUDE.md) — feature-session rules (never editrepos/, never hand-editwork.json, etc.).
Both load. They describe different layers and don't conflict — the source repo's CLAUDE.md is about working on mx; the runtime's is about working inside an mx runtime. The runtime CLAUDE.md template explicitly acknowledges the self-hosting case (after v1.11.0) and points back to the worktree's own developer rules.
- Don't archive the work you're sitting in.
mx work -n improve-mx archiveremoves the worktree directory; your shell ends up in a deleted path.cdout first. - Releases land on whatever branch the worktree is on.
pnpm release'sgit push origin HEADpushes the current branch — which inside a feature worktree is the feature branch, notmain. If you do an end-of-feature release, either: (a) merge the feature branch tomainfirst and run release from a main worktree, or (b) explicitly push the feature branch tomainwithgit push origin <feature>:mainif it's a clean fast-forward. - Both
CLAUDE.mdfiles loading is informative, not redundant — be aware that Claude sees both layers of rules. - The Vitest suite isolates itself in
/tmp/...regardless of where you run it from, so unit tests work the same in every feature work. - The build output lives in
npm/inside the worktree (gitignored). Different worktrees of mx don't sharenode_modules— each gets its ownpnpm install.
pnpm release runs the same script regardless of where the worktree lives. The script:
- checks
npm whoami(must be logged in) - checks the working tree is clean
- checks the version in
npm/package.jsonisn't already on npm - checks no
vX.Y.Ztag exists locally or on origin - runs
pnpm typecheck && pnpm lint && pnpm test && pnpm build - shows a tarball preview
- asks
Publish @rousan/mx@X.Y.Z and tag vX.Y.Z? (y/N) - on
y:npm publish --auth-type=webfromnpm/,git tag -a,git push origin HEAD,git push origin <tag>
The --auth-type=web step opens a browser for confirmation (handles 2FA). The push step uses the current branch — see the caveat above about feature-branch vs main.
See release for the full release runbook.