Worktrees
A worktree is a linked copy of your git repository checked out in a separate directory on its own branch. When you start a new chat in Fabriqa, it provisions a dedicated worktree for that session — meaning every agentic run has its own isolated filesystem and branch from the start.Fabriqa ties one session to one worktree. The agent works inside the worktree’s directory and commits only to that branch, never directly on your main branch.
Why Worktrees
Parallel sessions
Run multiple chats at the same time without them overwriting each other’s file changes.
Safe by default
Each session has a dedicated branch. Nothing lands on main until you decide to merge or open a PR.
Clean rollback
Discard a session’s worktree and its branch disappears with it — no stray commits to clean up.
Isolated tooling
Dependencies, build artifacts, and environment files are scoped per worktree, so one session’s state doesn’t bleed into another.
How Panels Change Per Worktree Chat
Opening a chat in a worktree session changes several panels compared to a standard main-branch chat.Execution context strip
Execution context strip
A strip at the top of the chat displays the active worktree path, the branch name (e.g.
fabriqa/worktrees/worktree-session-3), and the session identifier. This tells you at a glance which isolated context the agent is running in.Chat list and session tabs
Chat list and session tabs
Sessions are labeled and grouped by their worktree context in the sidebar and tab bar. Worktree sessions appear with a branch icon to distinguish them from chats running on the main workspace.
Git changes panel
Git changes panel
The diff view is scoped to the worktree’s branch. You see only the changes made inside this session — not unrelated work on other branches or the main workspace.
Terminal panel
Terminal panel
The integrated terminal opens with its working directory set to the worktree root, not the workspace root. Commands like
npm run dev or go build run in the isolated checkout.Setup notifications
Setup notifications
A toast appears when the worktree finishes its post-provision setup (or if setup fails). You can start chatting immediately, but you may want to wait for the success toast before running commands that depend on installed dependencies.
Configuring Your Project
Fabriqa looks for two optional configuration files in your project to customize what happens when a new worktree is provisioned. Place them in a.fabriqa/ directory at your project root (recommended), or directly at the root if you prefer.
.worktreeinclude — Copy Files Into New Worktrees
.worktreeinclude lists files and directories that should be copied from your main workspace into every new worktree on creation.
Format: gitignore-style glob patterns — one entry per line, # for comments.
Safety rule: An entry is only copied if it also appears in your .gitignore. This prevents accidentally exposing tracked files. If a pattern isn’t gitignored, Fabriqa skips it silently.
When to use it
Use.worktreeinclude for files that:
- Must exist for the project to start (
.env,.env.local) - Improve the development experience but are gitignored (
.vscode/,.idea/) - Are generated locally and not committed (auth tokens, local TLS certs)
Example — e-commerce project
.worktreesetup — Run Setup Commands After Provision
.worktreesetup is a shell script that Fabriqa executes inside the new worktree after file copying completes. Use it for anything that needs to run — installing packages, generating code, seeding a local database.
Execution: runs via sh in the worktree directory, asynchronously with a 5-minute timeout.
Result: Fabriqa emits a notification toast when the script finishes. If it times out or exits with an error, you’ll see a failure toast.
When to use it
Use.worktreesetup for operations that:
- Install dependencies (
npm install,pip install,go mod download) - Generate code or type definitions from schemas
- Initialize a local database or run migrations
- Build assets needed before the dev server can start
Example — e-commerce project
The script runs with the worktree directory as its working directory. Relative paths in your script resolve from the worktree root.
Choosing the Right File
Both files are optional and independent. Use neither, one, or both depending on what your project needs.| Situation | Use |
|---|---|
You have a .env the agent needs to read | .worktreeinclude |
| You have IDE settings you want shared across sessions | .worktreeinclude |
You need npm install or pip install to run in each worktree | .worktreesetup |
| You generate types from an API schema on setup | .worktreesetup |
You need .env and npm install | Both — include copies the file, setup installs deps |
Worktree Policy Settings
Worktree behavior can be configured per workspace in Workspace Settings:- Enable or disable worktrees for a specific workspace (override the app default)
- Set the new chat default mode — whether new chats open in a worktree or on the main branch by default
- Completion action — whether finishing a session suggests merging back or opening a PR
