worktree-isolation
Skill4 starsChanged 6 months agoMITView on GitHub
Prepare any repository for running multiple git worktrees in parallel with isolated runtimes. Use whenever the user mentions parallel worktrees, parallel AI agents/sessions on one repo, port conflicts between checkouts, per-worktree databases or env files, `claude -w`, worktrunk, or asks why two dev servers collide — even if they don't name falq.
- Reads credentials
5 other projects use a version of this.
Adopted by
Most recently taken up by
- niksavis/basiclytheir own version, first seen Oct 5, 2026
- aditya-deokar/software-factorytheir own version, first seen Sep 29, 2026
- orkait/hyperstacktheir own version, first seen Jun 14, 2026
- nicolai-bernsen/backlogdtheir own version, first seen Jun 7, 2026
- alex-voloshin-dev/ai-skillstheir own version, first seen May 17, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- alex-voloshin-dev/ai-skills★ 2same name
- nicolai-bernsen/backlogd★ 2same name
- aditya-deokar/software-factory★ 1same name
- orkait/hyperstack★ 1same name
- niksavis/basicly★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- llms.txtllms.txt
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 3 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 45
Every config file: .env*, config/, settings.*, application*.yml, vite.config.*, next.config.*, appsettings*.json, launchSettings.json, …
- Very specific: line 85
Write falq.yaml at the repo root.
- Distinctive: line 87
Prefer the generate tier (render a full template file) over patch (dotted-path edits).
- Very specific: line 97
Make the worktree runnable in one apply: add the dependency-install line for the stack(s) present (pnpm install, uv sync, bundle install, …
- Very specific: line 102
Every resource created in post_apply needs a matching pre_remove: createdb ↔ dropdb, stream create ↔ stream delete, queue declare ↔ queue …
- Very specific: line 108
Always include an agent_context.template naming this worktree's PORT, DB, and compose project — agents that can't see those facts hardcode …
- Distinctive: line 147
Never declare the repo ready without this:
- Distinctive: line 168
If anything failed, see references/troubleshooting.md (port thieves, zombie compose stacks, stale slots) — fix and re-prove.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Worktree Isolation with falq
Git worktrees isolate files. Nothing isolates the runtime: parallel worktrees
collide on ports, database names, queue prefixes, cache keys, and docker
compose project names. Your job: inspect this repo, write a falq.yaml
manifest that makes every worktree self-contained, validate it, and prove
it by booting two worktrees side by side.
How falq works: each worktree gets a slot (main = 0, others = lowest free
integer). Ports derive as base + slot × stride. falq apply provisions the
current worktree from the manifest; a git post-checkout hook runs it
automatically; falq remove tears down. Templates are minijinja with
variables slot, port, stride, branch, branch_slug, repo,
worktree_path, main_path (arithmetic allowed: {{ port + 1 }}).
Full schema: references/manifest-schema.md.
Step 1 — Discover
First, identify the architecture — it shapes everything below:
- Workspace files (
pnpm-workspace.yaml, rootpackage.jsonworkspaces,nx.json,turbo.json,lerna.json, Cargo[workspace],go.work,settings.gradle) → monorepo: enumerate every package and the port its dev server wants. - Several compose files / many services → multi-service.
- One app at the root → single app.
- Independent repos run together → polyrepo (one manifest each).
Patterns for each: references/architectures.md.
Then read the repo before writing anything (works for any stack — the per-stack map of where ports/DBs/queues live and what to feed is in references/stacks.md):
- Every config file:
.env*,config/,settings.*,application*.yml,vite.config.*,next.config.*,appsettings*.json,launchSettings.json,config/runtime.exs,Procfile. - Compose files (
docker-compose.{yml,yaml},compose.{yml,yaml}): list every service, port mapping, volume, network. - Dev-server commands in
package.jsonscripts (per package in a monorepo),Makefile,Taskfile,justfile,mix.exs,*.csproj— note every port. - Grep for EVERY hardcoded port/host — including build-target configs. A
literal
--port 8000in an Nxproject.json,turbo.json,Procfile, orpackage.jsonscript binds that port regardless of the manifest, and it's the #1 reason a worktree still collides after a clean apply. Use the explicit recipe and file list in references/discovery.md; don't rely on a narrowlocalhost:3000grep. - Identify DB/queue/cache clients (postgres, mysql, mongo, redis, nats, kafka, rabbitmq, sqlite paths) and where their names/prefixes come from. Per-stack map: references/stacks.md.
Step 2 — Classify
Split every discovered value into:
- Per-worktree-varying: ports, database names, queue/cache key prefixes, compose project name, debug ports, local file paths for sockets/caches. These go in the manifest.
- Shared: API keys, feature flags, third-party URLs. These stay in the
copied env file untouched — falq copies
env.copyfiles from main and only rewrites the keys you list inupsert. - Hardcoded ports/hosts: distinguish wiring from logic.
- Wiring — a port literal in a build-target/config file (
project.json,Procfile,vite.config.*,package.jsonscript): part of the isolation contract. Compute the env-reading refactor (--port "${PORT:-8000}", keeping the literal as the fallback somainis unchanged), present the diff, and write it to.worktree/pending-refactors.mdso it's never lost. The human applies it (falq never edits code);falq doctorkeeps flagging any that remain. Details: references/discovery.md. - Logic — a literal in feature/business code: flag as a proposed diff and stop. Never edit it.
- Wiring — a port literal in a build-target/config file (
Step 3 — Generate
Write falq.yaml at the repo root. Guidelines:
- Prefer the generate tier (render a full template file) over patch (dotted-path edits). Generate is format-agnostic and merge-proof; patch only when the app has no local-override file layer. Format guidance: references/formats.md.
- Choose
base/strideso every needed port fits one stride per worktree and stays inside 1024–9999 (avoid 6000/6665/6666/6697 — browser-blocked). Monorepo: one slot owns a contiguous port BLOCK; give each package a fixed offset (web=+0, api=+1, …), sizestrideto hold the largest offset (20–50 for big workspaces), andgeneratea per-package env file. Full pattern: references/architectures.md. - Make the worktree runnable in one apply: add the dependency-install
line for the stack(s) present (
pnpm install,uv sync,bundle install, …) topost_apply, so a fresh worktree hasnode_modules/.venvafter the hook runs andfalq run -- pnpm devworks first try. Per-ecosystem recipes: references/post_apply_recipes.md. - Every resource created in
post_applyneeds a matchingpre_remove:createdb↔dropdb, stream create ↔ stream delete, queue declare ↔ queue delete. Asymmetric hooks leak resources. - With compose, interpolate host ports from env (
"${APP_PORT:-3000}:3000") and let falq setCOMPOSE_PROJECT_NAME. Details and the additive-merge!overridegotcha: references/compose.md. - Always include an
agent_context.templatenaming this worktree's PORT, DB, and compose project — agents that can't see those facts hardcode 3000. Pointagent_context.filesat a gitignored file (default.falq/context.md, imported once from a committedCLAUDE.md/AGENTS.mdvia@.falq/context.md) so the per-worktree block never shows as a git change. You add that one import line during setup; falq gitignores.falq/. Details + theCLAUDE.local.mdshortcut: references/manifest-schema.md.
Then: falq init (if not done), keep your manifest, and confirm the
post-checkout hook is installed (falq hook status).
Step 4 — Validate
falq doctor --jsonFix every finding: stale slots, unignored outputs (everything falq writes
must be gitignored), compose lints (container_name:, fixed host ports,
network_mode: host, external networks, top-level name:), hook version.
Re-run until "ok": true. doctor also warns about hardcoded ports it
finds in build-target configs (--port 8000 in project.json, etc.) — these
don't fail doctor but tell you which wiring refactors from Step 2 still need
applying. Then falq apply --dry-run and read the plan — it must match what
you intended.
Step 5 — Prove
First commit the manifest. git worktree add populates a new worktree from
committed state — an uncommitted or untracked falq.yaml (plus its
generate templates and .gitignore changes) will NOT exist in the worktree,
so falq apply there exits 13 (no manifest) and the worktree comes up
unprovisioned. Commit before adding any worktree:
git add falq.yaml .gitignore .worktree/ # + any generate templates
git commit -m "chore: add falq worktree-isolation manifest"Never declare the repo ready without this:
git worktree add ../$(basename "$PWD").proof-a -b proof-a
git worktree add ../$(basename "$PWD").proof-b -b proof-b
(cd ../*proof-a && falq run -- <dev server command> &)
(cd ../*proof-b && falq run -- <dev server command> &)
# hit BOTH health endpoints — expect 200 from two DIFFERENT ports
curl -s -o /dev/null -w '%{http_code}\n' "http://localhost:$(cd ../*proof-a && grep '^PORT=' .env | cut -d= -f2)/health"
curl -s -o /dev/null -w '%{http_code}\n' "http://localhost:$(cd ../*proof-b && grep '^PORT=' .env | cut -d= -f2)/health"Show the user the two distinct live ports (and distinct
COMPOSE_PROJECT_NAMEs if compose is involved). Then tear down cleanly:
(cd ../*proof-a && falq remove) && git worktree remove --force ../*proof-a
(cd ../*proof-b && falq remove) && git worktree remove --force ../*proof-b
falq slots # must show no proof-* entriesIf anything failed, see references/troubleshooting.md (port thieves, zombie compose stacks, stale slots) — fix and re-prove.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

