flutree is a Go CLI that manages Git worktrees for multi-repo Flutter workflows: one workspace folder with a root app and its local packages, wired together with pubspec_overrides.yaml.
It has native AI agent support: flutree mcp install plugs it into Claude Code, Cursor, VS Code, Codex, OpenCode, Gemini CLI, Claude Desktop and Windsurf through the Model Context Protocol (MCP).
Copy this prompt into your AI coding agent (Claude Code, Cursor, VS Code Copilot, Codex, OpenCode, Gemini CLI, Claude Desktop or Windsurf). It installs flutree, connects it to the agent and explains how it works.
Install and set up flutree (https://github.com/EndersonPro/flutree) for me:
1. Check if `flutree --version` already works. If not, install it at a stable
location on my PATH:
- macOS: `brew tap EndersonPro/flutree && brew install EndersonPro/flutree/flutree`
- Windows: `scoop bucket add flutree https://github.com/EndersonPro/scoop-flutree && scoop install flutree`
- Linux (or if the above are not available): download the archive for my
OS/architecture from the latest release
(https://github.com/EndersonPro/flutree/releases/latest), verify it against
checksums.txt, and put the `flutree` binary on my PATH. The binary is at the
root of the archive. Ask me before using sudo.
2. Register flutree in yourself with `flutree mcp install --client <you>`, where
<you> is one of: claude-code, cursor, vscode, codex, opencode, gemini,
claude-desktop, windsurf. Use `--dry-run` first and show me what it will
write. Do not touch other MCP servers, and ask me before using `--force`.
3. Run `flutree mcp doctor` and fix any [ERR] line.
4. Tell me how to restart or reload you so the flutree MCP server is loaded.
5. Explain in 5 short bullets how flutree works and what I can ask you to do
with it (read `flutree --help`, or the `flutree://guide` MCP resource once
it is loaded).
- Workspace:
flutree create <name>creates Git worktrees for a root app and the packages you pick, under~/Documents/worktrees/<name>/(root/andpackages/), on afeature/<name>branch. Your original checkouts are not touched. - Overrides: it writes
pubspec_overrides.yamlso the root and every package resolve each other from the worktrees, keeping the overrides you already had. - Opt-in remote link: while a ticket spans several repositories,
link-remotewrites temporary git overrides (your ticket branches) into everypubspec.yamlso CI can resolve them, andunlink-remotetakes them out again. It is the only command that editspubspec.yaml, only when you ask, only between marker comments. - Lifecycle:
add-repoattaches more packages,remove-repotakes one out (its branch stays),pubgetruns pub get everywhere,completeremoves the worktrees and keeps the branches. - With an agent: through MCP the agent can discover your repos, show you a plan, ask you for missing decisions (base branch, packages) and only create or delete after you confirm.
- Let your AI agent set it up
- Features
- Installation
- Set up flutree for your AI agent (MCP)
- Quickstart (CLI)
- Multi-repo ticket end to end
- Commands Reference
- Workspace layout
- Non-interactive behavior and JSON output
- Exit Codes
- Registry
- Testing
- Project structure
- Contributing
- License
- Acknowledgments
- AI-native (MCP): a built-in MCP server (
flutree mcp serve) with 33 tools, resources and prompts. The agent discovers your repos, plans a workspace, asks you for the missing decisions and creates it only after you confirm. - Interactive create: a wizard that works from any directory, with a folder navigator, filter-as-you-type lists and a dry plan before anything is written.
- Overrides and dependency graph: a
pubspec_overrides.yamlin the root worktree and in every package worktree that depends on other selected packages. They keep the overrides already in yourpubspec.yamland resolve the whole dependency graph from the selected worktrees. The rule is the same whether or not the workspace was ever linked: a package worktree's file always carries path overrides to every sibling workspace package in its resolved graph (including one it reaches only through a hub, when itspubspec.lockor the hub's cached pubspec says so), fromcreateon, so a localpub getin a package resolves its siblings from the worktrees.create,add-repo,remove-repo,sync,link-remoteandunlink-remoteall regenerate these files with the same function, so the same workspace state gives the same bytes; entries you committed in a package's ownpubspec.yamlstay. - Remote-linked overrides (opt-in):
link-remote/unlink-remotewrite and remove a marked block of git overrides in everypubspec.yaml(real branch per repository, origin URL,path:for subfolders, transitive and hub dependencies), andcheck-unlinkedstops them from being merged. - Team profiles (no files in your repos):
profile export/profile importshare defaults (packages, base branches, hub, branch template, SDK manager,link-remotedefaults, stale days) as one versioned file kept outside the product repositories;create,add-repoandlink-remoteapply the one matching the root's origin URL, andconfig show --originsays where every value comes from. - Multi-repo workspaces: root and package worktrees grouped in one folder, with an optional VSCode
.code-workspace. - Packages in subfolders: a repository with no
pubspec.yamlat its root but packages one level below it (a hub withpkg_a/andpkg_b/) is selected one package at a time as<repo>:<subpath>. It gets one worktree and one branch, each selected package is a workspace member with its own name, and the overrides that point at it carry its subfolder (see Packages in subfolders). - SDK setup: runs
fvmorpuroin every new worktree so each one uses the right Flutter SDK. --jsoneverywhere: machine-readable output and JSON error envelopes for scripts and CI.- Shell completion:
flutree completion <bash|zsh|fish|powershell>.
brew tap EndersonPro/flutree
brew install EndersonPro/flutree/flutreeUpgrade:
brew update
brew upgrade flutree
# or via the flutree helper command
flutree update
# if an AI agent can no longer start the MCP server after the upgrade
flutree mcp install --repairscoop bucket add flutree https://github.com/EndersonPro/scoop-flutree
scoop install flutreeUpgrade:
scoop update flutreeEach release ships these archives plus a checksums.txt (SHA-256):
| Platform | Archive |
|---|---|
| Linux amd64 | flutree-<version>-linux-amd64.tar.gz |
| Linux arm64 | flutree-<version>-linux-arm64.tar.gz |
| macOS arm64 | flutree-<version>-macos-arm64.tar.gz |
| Windows amd64 | flutree-<version>-windows-amd64.zip |
| Windows arm64 | flutree-<version>-windows-arm64.zip |
Linux example (replace amd64 with arm64 if needed):
# latest release version, without the leading "v"
VERSION=$(curl -s https://api.github.com/repos/EndersonPro/flutree/releases/latest | grep -o '"tag_name": *"v[^"]*"' | cut -d'"' -f4 | tr -d v)
ARCHIVE=flutree-${VERSION}-linux-amd64.tar.gz
curl -LO https://github.com/EndersonPro/flutree/releases/download/v${VERSION}/${ARCHIVE}
curl -LO https://github.com/EndersonPro/flutree/releases/download/v${VERSION}/checksums.txt
# verify the download (prints "<archive>: OK")
sha256sum --ignore-missing -c checksums.txt
# extract and put the binary on your PATH
tar -xzf ${ARCHIVE}
sudo install -m 0755 flutree /usr/local/bin/flutree
flutree --versionOn macOS use shasum -a 256 -c checksums.txt instead of sha256sum. On Windows, extract the .zip and move flutree.exe to a folder that is on your PATH.
Requires Go >=1.25 (see go.mod) and Git.
go build -o ./flutree ./cmd/flutree
./flutree --helpNote: go install github.com/EndersonPro/flutree/cmd/flutree@<version> does not work for v2 releases, because the module path has no /v2 suffix. Use one of the methods above.
Requirements at runtime: Git available in PATH. fvm or puro are optional (see SDK setup).
flutree includes an MCP server, so an AI coding agent can create and manage your Flutter workspaces for you. Setup takes one command.
The agent's config stores the absolute path of the flutree binary. Install it with Homebrew, Scoop or a release archive (see Installation) so the path stays valid. Do not install from a temporary location or with go run: the path in the agent's config would break as soon as the binary disappears, and flutree mcp doctor warns about it ([WARN] binary: binary lives in a temporary directory).
flutree mcp install # auto-detect installed clients
flutree mcp install --client claude-code # one or more clients: --client cursor,codex
flutree mcp install --scope project # write the repo-shared config of the current directory
flutree mcp install --dry-run # preview target file and entry, write nothing
flutree mcp install --repair # fix entries that point to a deleted or version-pinned binaryThe installer is non-destructive: existing keys and other servers are preserved, and an existing flutree entry is kept unless you pass --force. It always writes the stable path of the binary (the one on PATH, the Homebrew bin or Scoop shim), never a Cellar/<version> path.
After brew upgrade flutree (or any upgrade that moves the binary), run flutree mcp install --repair if an agent stops starting the MCP server: it rewrites only the command of every flutree entry that is missing or version-pinned (an in-place edit of that one value: key order, indentation, line endings and comments of the file stay byte for byte), shows a diff per file, and copies each file it changes to <file>.flutree-bak-<timestamp>. --dry-run shows the diffs without writing, --json prints {dry_run, binary, warning?, fixes: [{client, config_path, from, to, reason, diff, status?, backup?}]}. flutree doctor --fix and flutree mcp doctor --fix apply the same repair. --force has no effect on a repair: mcp doctor --force is deprecated and mcp install --repair --force prints a deprecation warning on stderr; drop the flag. A config that cannot be read (for example malformed JSON) is reported as an error (reason: unreadable, exit code 1) and never rewritten.
flutree mcp doctor| Line | Meaning |
|---|---|
[OK] |
The check passed: binary resolved, entry present with an existing command, or handshake succeeded. |
[-] |
Informational: the client is not detected, or it is detected but has no flutree entry yet. |
[WARN] |
A real warning, for example the binary lives in a temporary directory and may disappear. |
[ERR] |
A detected client's config cannot be read, the entry's command path is broken, or the live mcp serve handshake failed. doctor exits 1. |
Restart the agent (or reload its MCP servers) so it picks up the new entry. See the per-client notes below.
After upgrading flutree the same applies: a client keeps its running MCP server (and the old tool schemas) until it restarts. The server checks the installed binary on every tool call and, when it is newer, adds server_outdated: {running, installed, hint} plus a WARNING server_outdated text line to the result; the agent tells you to restart the client. flutree mcp doctor shows running_version, installed_version and server_outdated (--json). flutree never restarts or kills a client.
Ask your agent, in plain language:
- "Create a flutree workspace feature-login with root app and packages core and ui"
- "Show the status of workspace feature-login"
- "Finish workspace feature-login"
For the first prompt the agent discovers your repositories (discover_repos, inspect_repo, list_branches), asks you for what it does not know (base branches, packages), calls plan_create and shows you the plan, and only after you confirm calls create_workspace. For the second it calls workspace_status; for the third it checks the status, asks for your approval and calls complete_worktree.
flutree mcp install --client claude-code- Writes
~/.claude.json(user) or.mcp.jsonin the current directory (--scope project), keymcpServers.flutree. - Restart Claude Code, then run
/mcpto seeflutreelisted as connected. - Caveat: Claude Code may ask you to approve a project-scoped server from
.mcp.jsonthe first time.
flutree mcp install --client cursor- Writes
~/.cursor/mcp.json(user) or.cursor/mcp.json(--scope project), keymcpServers.flutree. - Restart Cursor and check Settings, MCP, where
flutreeshould appear with its tools. - Caveat: Cursor is detected by its config directory (
~/.cursor) or acursorbinary onPATH.
flutree mcp install --client vscode- Writes
<VS Code user dir>/User/mcp.json(user) or.vscode/mcp.json(--scope project), keyservers.flutree. - In VS Code run "MCP: List Servers" from the Command Palette to see and start
flutree; use it from Copilot Chat in agent mode. - Caveat:
mcp.jsonmay contain JSONC comments or trailing commas. The installer refuses to rewrite such a file unless you pass--force, which strips the comments. The per-OS user directory is not documented by VS Code, so verify the path with--dry-run.
flutree mcp install --client codex- Writes
~/.codex/config.toml(user) or.codex/config.toml(--scope project), table[mcp_servers.flutree]. - Restart Codex; the server starts with the session.
- Caveat: TOML comments are not preserved on the round-trip, so a config that has comments needs
--force.
flutree mcp install --client opencode- Writes
~/.config/opencode/opencode.json(user) oropencode.json(--scope project). - Restart OpenCode and check that
flutreeis listed among the MCP servers. - Caveat: new files use the
mcp.servers.flutreelayout; if your file already uses the legacymcp.flutreelayout, that layout is kept and uninstall and doctor read both.
flutree mcp install --client gemini- Writes
~/.gemini/settings.json(user) or.gemini/settings.json(--scope project), keymcpServers.flutree. - Start
geminiagain and run/mcpto list the server and its tools. - Caveat: none known beyond the usual restart.
flutree mcp install --client claude-desktop- Writes
claude_desktop_config.jsonin the Claude app folder: macOS~/Library/Application Support/Claude/, Windows%APPDATA%\Claude\, Linux~/.config/Claude/. KeymcpServers.flutree. - Quit and reopen Claude Desktop completely;
flutreeappears in the tools menu of a chat. - Caveat: user scope only.
--scope projectreportsunsupported_scope.
flutree mcp install --client windsurf- Writes
~/.codeium/windsurf/mcp_config.json(user scope only), keymcpServers.flutree. - Reload Windsurf and open the Cascade MCP panel to check that
flutreeis listed. - Caveat: the path follows Windsurf's long-standing convention but could not be verified against its current official docs. Check it with
--dry-run.
Detection never makes network calls: a client counts as present when its binary is on PATH or its config directory or file already exists.
Tools (32). All paths in results are absolute.
| Tool | Use it to |
|---|---|
discover_repos |
Find the Flutter repositories under a folder (start here). A repository without a root pubspec.yaml is listed once per package found one level below it, with the selector (hub:pkg_a) to pass in packages / repos. |
inspect_repo |
Describe one repository: branches, SDK pin, path dependencies (and, for a repository without a root pubspec.yaml, its packages). |
list_branches |
List local and origin/* branches of a repository, to propose base branches. |
plan_create |
Dry-run a workspace: validates everything and returns the plan, changes nothing. |
create_workspace |
Create the workspace after the plan; needs confirm=true or the user's confirmation. from_existing=true (also on plan_create) joins or restores a ticket whose branches already exist, and reports branch_plan per repository. The result says where it is (container_path) and the directory to open the agent from (agent_dir, with agent_dir_reason); the agent must tell you both. |
workspace_status |
Read one workspace: validated status, branches, dirty state, ahead/behind (against origin/<base> when it exists), overrides. |
list_worktrees |
List registered workspaces with their validated status (show_all, global_scope). |
doctor |
Diagnose the state (registry vs disk, broken/prunable worktrees, missing source clones, merged branches, dirty worktrees, disk size, MCP binary). Read-only; fix=true applies the safe repairs after confirmation (prune_worktrees=true also prunes git worktree metadata in the known source repositories); base forces the base of the merged-branches check. |
create_worktree |
Legacy one-shot create with no confirmation step; prefer plan_create + create_workspace. |
add_repo |
Attach more repositories to an existing workspace. A package of a repository without a root pubspec.yaml is attached as <repo>:<subpath>: the first one creates the repository's worktree, later ones join it (added_packages lists them). On a linked workspace it re-runs link_remote for the new repositories and reports link_refresh (relink=false opts out). |
remove_repo |
Take ONE package repository out of a workspace: removes its worktree, registry entry and overrides entries, and re-runs link_remote on a linked workspace. The branch is kept (branch_command prints git branch -d <branch>). dry_run=true reports the plan; uncommitted or unpushed work is refused (details.at_risk) unless force=true; the root and a single package of a multi-package repository are refused. Always asks the user first (confirm=true). |
complete_worktree |
Remove a workspace's worktrees (branches stay unless delete_merged_branches=true, which deletes the ones whose merge is proven: git branch -d, or -D for a proven squash or rebase merge). Always asks the user first. |
prune |
Report the workspaces that are merged, broken, missing or stale, with size, age and what removal would lose. Read-only; apply=true removes the safe ones (plus any named in select, or every workspace with all=true) after confirmation; include_unregistered=true also removes the unregistered folders it lists; base forces the base of the merge checks. Branches are never deleted. |
pubget |
Run pub get across the packages of a workspace. |
verify_remote |
Check that a workspace resolves (and with analyze=true compiles) without its local overrides, in a temporary copy. Read-only for the workspace, but it runs network commands and needs git credentials. |
link_remote |
Opt-in: write temporary git overrides (ticket branches) into the pubspec.yaml of the root (every workspace package) and of each package that needs siblings for its own CI, so CI resolves them. Edits pubspec.yaml, so it always asks the user first; dry_run=true only reports. Conflicts with manual overrides and unpushed branches come back as questions (on_conflict, on_unpushed); root_only_graph, package_overrides and offline tune the plan, and an unreachable origin stops it (could not check branches on origin). |
unlink_remote |
Remove exactly what link_remote wrote (byte-identical restore) and regenerate pubspec_overrides.yaml; pin replaces a managed override with a pinned tag, branch or sha (a tag or branch is checked on origin; a sha is accepted with a warning; offline skips the check); force removes a hand-edited block. Asks the user first. |
push_workspace |
Pushes the workspace branches to origin in dependency order (leaves first, root last), never forced; dry_run returns the plan, the user is always asked before it pushes. workspace_status shows what is ready to push (ready_to_push). |
check_unlinked |
Read-only: report the pubspec.yaml files under a path that still hold a flutree managed block (what CI and hooks run through flutree check-unlinked). |
sync_workspace |
Bring origin/<base> into every repository of a workspace (fast-forward, merge --no-edit by default, strategy=ff-only or rebase). dry_run=true plans without changing a worktree; applying needs confirm=true or the user's confirmation. Dirty, detached or mid-merge repositories are skipped with a reason, a conflict is aborted and reported (conflicts[]) while the others still sync, and the local base branch is never moved. Returns flutree.sync/v1. |
clean_worktree |
Clean the managed worktree that contains the server's working directory. |
get_config |
Read scope.root, workspace.generate, sdk.manager, cleanup.stale_days, sync.update_local_base or create.base_source. With project (a root repository path) it also reads the per-project keys and returns the value with its source. |
set_config |
Write one of those config keys; with project it saves a per-project default in your local config (same validation as flutree config set --project). Only when you ask. |
unset_config |
Remove a per-project key, or the whole project section when key is omitted (project required). |
list_config |
List the global settings and the roots that have a project section, or with project the values of that section. |
list_profiles / get_profile |
Read the team profiles (shared defaults for a root repository, matched by its origin URL) of your local config. Read-only. |
import_profile |
Import a team profile from a file or an https URL: validates it, returns the diff and writes only after you confirm (dry_run=true only shows the diff). A failed fetch is a typed error and changes nothing. |
sync_profile |
Refresh the local profile from FLUTREE_PROFILE_SOURCE or profile.source, with the same diff and confirmation. Never runs on its own. |
export_profile |
Render a profile as a standalone flutree.profile/v1 file to share outside the product repositories; writing a file (out) asks the user first. |
remove_profile |
Remove one profile from your local config. Always asks the user first. |
show_config |
Show every effective value with the layer that decided it (project, profile:<name>, global, default), optionally for one root repository (project). Read-only. |
get_version |
Return the flutree binary version. |
Resources. flutree://guide (usage guide), flutree://workspaces (all workspaces), flutree://workspace/{name} (status of one workspace) and flutree://config (effective configuration).
Prompts. create_workspace_flow, add_package_flow and finish_workspace_flow walk the agent through the recommended steps.
Asking the user and confirmation. The agent never decides base branches, packages or destructive actions for you. When the client supports MCP elicitation, flutree asks you directly with a form (missing base branch, packages, a yes/no before create_workspace, link_remote and unlink_remote, and always before complete_worktree and prune with apply=true; pubget only with force=true). If you decline or cancel, nothing is executed and the agent must not retry on its own.
Fallback without elicitation. Nothing is executed. The tool returns needs_user_input: true (for example status: "confirmation_required") with a questions list; the agent asks you in the chat and calls the tool again with your answers or confirm=true.
Full details (arguments, results, errors) are in docs/mcp.md.
flutree mcp uninstall # remove only the flutree entry from every detected client
flutree mcp uninstall --client cursor # one client
flutree mcp uninstall --dry-run # show what would be removedOther keys and servers are preserved. Each client reports removed, not_found (no flutree entry), not_installed (client not detected) or unsupported_scope.
For clients mcp install does not handle, add this stdio entry manually:
{
"mcpServers": {
"flutree": {
"type": "stdio",
"command": "/path/to/flutree",
"args": ["mcp", "serve"]
}
}
}Replace /path/to/flutree with the output of which flutree. The server speaks JSON-RPC over stdin/stdout; do not pass --json to mcp serve (it would corrupt the transport framing).
- The agent does not list flutree: run
flutree mcp doctor; if the client shows[-] ... no flutree entry, runflutree mcp install --client <name>, then restart the agent. [WARN] binary: ... temporary directory: reinstall flutree at a stable path and runflutree mcp install --force.[ERR]on a command path (for example a deletedCellar/<version>binary after an upgrade): runflutree mcp install --repair(orflutree doctor --fix, which reports these entries as[ERR]undermcp_binaryand repairs them), then restart the agent.[ERR] handshake: runflutree mcp serveby hand; it should wait silently on stdin. Check that the entry does not pass--json.- Install refuses to touch a config with comments: pass
--force(comments are stripped). unsupported_scope: that client has no project config; use the default user scope.- Project config not picked up:
--scope projectwrites into the current directory, so run it from the repository root.
Interactive create works from any directory:
flutree create feature-loginIf the scope (--scope > scope.root > current directory) has no Flutter repositories, a folder navigator opens. Keys: Up/Down (or j/k) move, Enter opens a folder (.. goes up), Tab selects the current folder as scope, Esc goes up one folder, ctrl+o changes folder from the root step or adds packages from any folder on the packages step. Folders that are Flutter repos are marked [flutter]. Lists filter as you type, and create shows a dry plan and asks for confirmation before writing anything.
Non-interactive (scripts and CI):
flutree create feature-login --scope ~/code --root-repo app --package core --package ui --yes --non-interactiveThen:
flutree list # workspaces of the current repo (global outside a repo)
flutree pubget feature-login # pub get across packages, root last
flutree add-repo feature-login --repo analytics --non-interactive --yes
flutree complete feature-login --yesSet a default discovery folder once with flutree config set scope.root ~/code.
Shell completion:
flutree completion zsh > "${fpath[1]}/_flutree"One ticket that touches the app (app) and two package repositories (core, and ui, which depends on core). Teams that work this way can also read Adopting flutree in a team.
-
Create the workspace. The root and the packages get a worktree on the ticket branch, and
pubspec_overrides.yamlpoints every workspace package to its worktree.flutree create abc-1 --root-repo app --package core --package ui --yes --non-interactive
If a package repository keeps its packages in subfolders instead of at its root (a hub with
pkg_a/andpkg_b/), select them one by one:--package hub:pkg_a --package hub:pkg_b --package-base hub=main. The hub gets one worktree and one branch,link-remotepushes it once and writes one git override per package withpath: <subpath>(details).To join or restore a ticket whose branches already exist (a teammate pushed them, or you completed the workspace earlier), add
--from-existing(MCP:from_existing=true): each repository uses the branch it already has, with its real name, tracksorigin, and gets a new branch only when it has none. The plan showssourceand ahead/behind per repository, a branch that diverged fromoriginrefuses the create before anything is made, and no local commit is lost. Branches that differ only by case (feature/xandFeature/x) at the same commit are one branch (the plan reportscase_variants,resolution: same_commit); at different commits the error lists each ref and--branch-for <repo>=<exact ref>(MCPbranch_for) picks one. A branch checked out in another worktree is refused naming that worktree and, when it belongs to a registered workspace, that workspace (work in it, grow it withadd-repo, or complete it first).flutree create abc-1 --root-repo app --package core --package ui --package-base core=main --package-base ui=main --from-existing
-
Develop with path overrides.
pub getresolvescoreanduifrom the worktrees, so changes are visible across repositories at once.pubspec.yamlis untouched andpubspec_overrides.yamlstays out of git (.git/info/exclude).flutree pubget abc-1
-
Link the branches for CI. CI only sees the committed
pubspec.yaml.link-remotewrites temporary git overrides to the ticket branches inside a marked block of thepubspec.yamlof the root (one override for every workspace package) and of each package repository that needs siblings (the ones in its own graph), and prints the push order and the delivery consequences below.flutree link-remote abc-1 --dry-run flutree link-remote abc-1
Later in the ticket,
flutree add-repo abc-1 --repo extraon a linked workspace re-runslink-remotefor the new repository (link_refreshin--json), andflutree remove-repo abc-1 --repo extra --yestakes it out again (the branch stays) and refreshes the blocks.What that means for delivery (the plan prints it too, and
--jsoncarries it asdelivery):- A package's CI only passes once the sibling branches it points to are pushed, so the push order covers the packages too, leaf first.
- Mutual dependencies are a cycle. If
coreanduioverride each other, the plan lists them undercyclesand both must be pushed before either CI can pass. - Every repository with a managed block runs
unlink-remote(or--pinto the released tag) before merging into its base, packages included, not only the root. check-unlinkedbelongs in the CI of every repository, packages included (snippets in docs/usage.md).
-
Commit and push in order: leaf packages first (
core), then the packages that depend on them (ui), the root last. flutree never commits or pushes. If origin cannot be reached, step 3 stops withcould not check branches on origin: <reason>instead of planning;--offlineplans without that check (remote_checked: false). -
Check what CI will resolve.
verify-remoteresolves the root against the remote refs only, in a temporary copy, and changes nothing. It does not resolve the package repositories (their own CI does) and never refreshes apubspec.lock: when a repository tracks one, runpub getin a clean checkout of its pushed branch (withoutpubspec_overrides.yaml), commit the lockfile and push again.flutree verify-remote abc-1
-
Merge the packages and tag them, leaves first, in each package repository.
-
Pin the released versions.
unlink-remote --pinreplaces a managed override with the tag outside the block; without--pinthe block is removed andpubspec.yamlis byte-identical to what it was beforelink-remote.flutree unlink-remote abc-1 --pin core=v1.4.0 --pin ui=v2.0.0
When the root reaches the packages through a hub,
link-remote,push --dry-runandstatusprint the whole release order (even when the hub is not a workspace member), each step with its command or "manual": merge the package PRs; tag them if your team does so; update the hub on a ticket branch to the merged or tagged refs, then merge and tag it; pin the hub tag in the root and remove the overrides it covers; merge the root.--jsonhas it inrelease_plan[]. Step 4 isunlink-remote --pin-dependency: it edits only theref:of the hub dependency, shows the diff, checks the tag on the hub's origin, never creates it, and--drop-coveredremoves only the overrides the pinned hub provably covers (anything it cannot prove is reportedunverifiedand kept):flutree unlink-remote abc-1 --pin-dependency hub_pkg=v2.1.0 --drop-covered flutree unlink-remote abc-1 # removes what is left of the block -
Merge the root. A pre-push hook or the CI of the pull request can run
flutree check-unlinkedto make sure no temporary block reaches a protected branch. -
Close the workspace and delete the branches that are merged.
flutree complete abc-1 --yes --delete-merged-branches -
Clean up what is left over from older tickets.
flutree prune --dry-run flutree prune --yes
Global flags on every command:
--help/-h(alsoflutree help <command>)--json: machine-readable output and JSON error envelopes. Works before or after the command (flutree --json list).--version(root command only): print the version.
Flags may appear before or after positional arguments. Long flags need two dashes.
Creates a managed workspace (worktrees, branches, overrides, registry entry).
flutree create <name> [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--branch |
string | feature/<name> |
Target branch name |
--base-branch |
string | detected | Base branch of the root worktree; default: config or profile base_branch, else origin/HEAD, else the local default branch (main, master or develop); the plan marks it (detected), and a base that does not exist is refused at plan time |
--scope |
string | . |
Directory scope for Flutter repo discovery |
--root-repo |
string | Root repository: name, package name or path to a Flutter repo, may be outside --scope (required with --non-interactive) |
|
--package |
stringArray | Package repository: name, package name or path to a Flutter repo, or <repo>:<subpath> for a package of a repository with no root pubspec.yaml (repeatable) |
|
--repo |
stringArray | Alias of --package (repeatable) |
|
--package-base |
stringArray | Override package base branch as <selector>=<branch> (repeatable). Without it the base comes from the project config or profile, else it is detected like the root base (origin/HEAD, then the local default branch) and marked (detected); in a terminal the prompt offers the detected base. A base that does not exist, or none detected with --non-interactive / --dry-run, fails with exit 2 before changing anything |
|
--no-package |
bool | false |
Root-only workspace; conflicts with --package and --package-base |
--workspace |
bool | true |
Generate a VSCode workspace file (default from config workspace.generate) |
--no-workspace |
bool | false |
Disable VSCode workspace generation |
--copy-root-file |
stringArray | Extra root file or pattern to copy (repeatable). .env and .env.* are copied by default |
|
--reuse-existing-branch |
bool | false |
Allow non-interactive reuse of an existing branch |
--sync-with-remote |
bool | false |
Fetch each base branch from origin and start every worktree from origin/<base> (needs network); without it the local base is used and the plan warns when it is behind origin/<base> (local refs). |
--from-existing |
bool | false |
Join or restore a ticket whose branches already exist: use each repository's existing local or origin branch (real name, case-insensitive), create it only when missing, track origin, refuse a diverged branch. --json adds branch_plan, linked, linked_files, linked_as |
--branch-for |
stringArray | With --from-existing: exact ref for one repository, <repo>=<exact ref> (repeatable); use it when branches differ only by case at different commits |
|
--offline |
bool | false |
With --from-existing: read local refs instead of asking origin (warns they may be stale) |
--non-interactive |
bool | false |
Disable prompts |
--yes |
bool | false |
Auto-acknowledge the dry plan in non-interactive mode |
flutree create feature-login
flutree create feature-login --scope ~/code --root-repo app --package core --non-interactive --yes
flutree create feature-login --scope ~/code --root-repo app --package hub:pkg_a --package hub:pkg_b --package-base hub=main --non-interactive --yesWhen it succeeds, create prints where the workspace is (Location) and Open your agent from: the workspace folder when it has packages (so the agent sees root/ and packages/), the root worktree when it is root-only. --json adds container_path, agent_dir and agent_dir_reason (next_step is unchanged); add-repo reports the same fields.
If create fails, the branches it created are deleted again; pre-existing branches are never touched. If the scope you picked in the navigator differs from scope.root, the review step offers to save it as the default (s toggles, on by default).
create names the branch, in order: --branch, --branch-template, the project config or profile branch_template, else feature/<name>. A template mixes three placeholders, at least one required: {name} (slug of the workspace name), {ticket} (--ticket, used verbatim, so ABC-123 keeps its case) and {desc} (slug of --desc).
flutree config set --project ~/code/app branch_template "feature/{ticket}/{desc}"
flutree create --ticket ABC-123 --desc "refactor taxes" --root-repo app --non-interactive --yes
# branch feature/ABC-123/refactor-taxes in every repository; folder abc-123-refactor-taxes- The workspace folder stays slugified and lowercase. Without a
<name>,--ticketand/or--descdecide it: the slug of<ticket>-<desc>(abc-123-refactor-taxes). With a<name>it is used as before. - A placeholder the template uses whose value is missing is an input error (exit
2) naming the flag, for exampleBranch template 'feature/{ticket}/{desc}' needs --ticket.An explicit--branchneeds none of them. Unknown placeholders are input errors; old{name}templates keep working. branch_pattern(profile, project config,flutree config set --project <root> branch_pattern <regexp>) is an optional Go regular expression, matched case-sensitively and unanchored (use^...$for the whole name).create,create --from-existingandadd-reporefuse a branch that does not match (input error, exit2, the pattern is shown, nothing is created). Default: no pattern.- The branch is used with its exact case in every repository, in
link-remoterefs and in every report (push --dry-run,status); only folders are lowercased. - Case-collision checks for new branches use only local refs (loose or packed). A tracking ref like
origin/Feature/old/xdoes not blockfeature/new/y. On a case-insensitive volume, a local collision is refused with the existing local spelling and up to five example refs. - MCP:
plan_createandcreate_workspacetaketicket,descandbranch_template;namestays required there. Agents ask the user for the ticket and description when the template needs them.
Attaches repositories to an existing workspace and regenerates pubspec_overrides.yaml. In an interactive terminal without --repo it opens a multiselect wizard with a final review.
flutree add-repo <workspace> [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--repo |
stringArray | Repository to attach: name, package name or path to a Flutter repo, may be outside --scope, or <repo>:<subpath> for a package of a repository with no root pubspec.yaml (repeatable). Skips the wizard |
|
--scope |
string | . |
Directory scope for Flutter repo discovery |
--sync-policy |
string | auto |
Sync behavior before create: auto, always or never |
--package-base |
stringArray | Override package base branch as <selector>=<branch> (repeatable) |
|
--package-branch-source |
stringArray | Override package target branch as <selector>=<branch> (repeatable) |
|
--copy-root-file |
stringArray | Extra root file or pattern to copy (repeatable) | |
--reuse-existing-branch |
bool | false |
Allow non-interactive reuse of an existing branch |
--non-interactive |
bool | false |
Disable the wizard and prompts; requires deterministic selectors |
--no-relink |
bool | false |
On a linked workspace, do not re-run link-remote for the new repositories |
On a workspace that link-remote linked, add-repo re-runs link-remote so the managed blocks cover the new repositories and reports it as link_refresh (--json); if that refresh fails the add is kept and the exit code is 1.
flutree add-repo feature-login
flutree add-repo feature-login --repo core --sync-policy never --non-interactive --yes
flutree add-repo feature-login --repo hub:pkg_a --repo hub:pkg_b --package-base hub=main --non-interactive --yesTakes one package repository out of an existing workspace: removes its worktree, its registry entry and its entries in pubspec_overrides.yaml (root and packages) and in the .code-workspace file. The branch is kept: the output prints the command that deletes it (git branch -d <branch>, run in the repository). The workspace location and Open your agent from are reported like after create (container_path, agent_dir in --json).
flutree remove-repo <workspace> --repo <selector> [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--repo |
string | Package repository to remove: folder name, package name or path (required). A repository with packages in subfolders is removed whole (--repo hub) |
|
--dry-run |
bool | false |
Report what would be removed and what is at risk (at_risk, requires_force); change nothing |
--yes |
bool | false |
Confirm without asking (required without a terminal, else exit 2 and nothing changes) |
--force |
bool | false |
Remove although the worktree has uncommitted changes (lost) or unpushed commits (kept on the branch) |
--no-relink |
bool | false |
On a linked workspace, do not re-run link-remote |
- A worktree with uncommitted changes or commits on no origin ref is refused (precondition error;
error.details.at_riskwith--json) unless--force; a managed block written bylink-remotedoes not count as work. - The root is refused (exit
2; useflutree complete <workspace>), and so is--repo hub:pkg_a, one package of a multi-package repository (exit2, remove the whole repository). - A warning (never blocking) names the packages whose
pubspec.yamlstill declares a removed package. - On a linked workspace
remove-repore-runslink-remoteso the managed blocks stop naming the package (link_refreshin--json; the root block is taken out when no package is left). - If a step after the worktree removal fails (registry, overrides, link), the report is
partial(errors[],link_refresh.error) and the exit code is1.
flutree remove-repo feature-login --repo core --dry-run
flutree remove-repo feature-login --repo core --yesSome repositories have no pubspec.yaml at their root: their packages live one level below it (a "hub" with pkg_a/ and pkg_b/). flutree detects those packages and selects them one at a time as <repo>:<subpath>:
flutree create abc-1 --scope ~/code --root-repo app --package hub:pkg_a --package hub:pkg_b --package-base hub=main --yes --non-interactive
flutree add-repo abc-1 --scope ~/code --repo hub:pkg_c --non-interactive --yes # joins the same hub worktree- Selection never guesses. In a terminal the wizards list every package as its own row (
hub:pkg_a). With--non-interactive,--jsonor MCP, the bare repository name (--package hub) is aninputerror (exit2) that lists the candidates (hub:pkg_a,hub:pkg_b); discovery lists them too (discover_repos,inspect_repo). A root repository needs its ownpubspec.yaml; the subpath form is for packages.<repo>is a name or a path, the subpath is relative to the repository root and may be deeper than one level when you name it yourself. - One worktree, one branch. The repository gets one worktree (
packages/hub) on one branch, whatever the number of selected packages, and one base branch (--package-base hub=main, nothub:pkg_a=main). - Each package is a workspace member. The root's
pubspec_overrides.yamlpoints every member at its own subfolder (pkg_a: path: ../../packages/hub/pkg_a), a member that needs overrides gets its ownpubspec_overrides.yamlnext to its ownpubspec.yaml(git-excluded as/pkg_a/pubspec_overrides.yaml),pubgetruns in each member's folder andstatuslists them undermembers. link-remotetreats the repository as one member: one branch, one push step, one git override per package withpath: <subpath>in the root, and a managed block in thepubspec.yamlof each member that needs one.unlink-remoteandcheck-unlinkedhandle every one of those files.- Registry. The record of such a repository gains an optional
subpathslist; records of ordinary repositories and records written by older versions are unchanged and keep working.
Manages persisted configuration (stored in ~/Documents/worktrees/.flutree_config.json).
flutree config get <key> [--project <root>]
flutree config set <key> <value> [--project <root>]
flutree config unset --project <root> [<key>]
flutree config list [--project <root>] [--json]
flutree config show [--project <root>] [--origin] [--json]
config get --project <root> shows the effective value together with the layer that decided it (project, global or default), taking the root repository's project config into account. With it, get also reads the project-only keys packages, base_branch, package_base, package_base.<selector>, branch_template, branch_pattern and copy_root_files. Without --project the output of get and set is unchanged.
| Key | Description |
|---|---|
scope.root |
Default discovery root for create and add-repo when --scope is omitted. Must be an existing directory |
workspace.generate |
true or false (default true): whether create writes a VSCode .code-workspace when neither --workspace nor --no-workspace is passed |
sdk.manager |
auto, fvm, puro or none (default auto): Flutter SDK manager run in every new worktree |
cleanup.stale_days |
Positive whole number (default 60): age in days after which list flags a workspace as stale and prune offers it |
sync.update_local_base |
ask (default), always or never: after a sync with origin, fast-forward the local base branch when safe (see Updating the local base branch) |
create.base_source |
local (default) or origin: where create starts each worktree. local uses the local <base> and the plan warns per repository when it is behind origin/<base>; origin starts from refs/remotes/origin/<base> as the local refs have it and never moves the source repositories. |
profile.source |
File path or https:// URL (never http://) that flutree profile sync refreshes the team profile from; the FLUTREE_PROFILE_SOURCE environment variable wins. See profile |
config show prints every effective value; with --project <root> the project section and the matching team profile take part, and --origin adds where each value comes from (flag, project, profile:<name>, global, default; project and global are the "user" layer). --json always includes the source (flutree.config_show/v1).
flutree config set scope.root ~/code
flutree config get scope.root
flutree config show --project ~/code/my-app --origin
flutree config set sdk.manager fvm
flutree config set cleanup.stale_days 30
flutree config set sync.update_local_base alwaysAfter create and add-repo, flutree prepares the Flutter SDK in the root and every package worktree:
- fvm: reads
.fvmrc("flutter") or the legacy.fvm/fvm_config.json, then runsfvm use <version> --force --skip-pub-get. - puro: reads
.puro.json("env"), from the source repository too since puro gitignores it, then runspuro use <env>. auto(default) uses fvm when the repo pins an fvm version, otherwise puro.fvmorpuroforce one manager;nonedisables the step.- Repos without a pin are skipped. If the manager fails, the worktree is kept, a
[warning]is printed on stderr andsdk_setupin--jsonoutput reportsfailedwith the reason.
- SDK files. A worktree that already pins the version and has the manager's local link (
.fvm/flutter_sdkfor fvm,.dart_tool/flutter_sdkfor puro) skips the manager:skipped: already pinned. Otherwise, after the manager runs, any tracked file it rewrote (.fvmrc,.vscode/settings.json,.fvm/fvm_config.json, ...) is put back withgit checkout -- <file>when only its formatting changed or it carries the same version (restored_filesinsdk_setup). A real version change is kept and reported inwarningsand as a[warning]on stderr. Untracked files the manager creates are never removed. - Post-create check.
createandadd-reporungit status --porcelainin every new worktree. Anything besides the files flutree owns (pubspec_overrides.yaml, copied root files) is a[warning]on stderr andpost_create_dirty([{repo, path, files}]) in--jsonoutput. It is only reported, never cleaned.
When a sync fetches origin/<base> (create with sync, add-repo --sync-policy always, MCP sync_with_remote), flutree can also fast-forward the local <base> when that is safe: the local branch has no commits outside origin/<base>, and if it is checked out somewhere that checkout is clean (git merge --ff-only there; otherwise git fetch origin <base>:<base>). It never rebases, resets or forces. sync.update_local_base decides: ask (default, asks in a terminal; without one the update is skipped with a note), always or never. The outcome per repo (updated N commits, or skipped with the reason: diverged, dirty checkout, never, non-interactive) is shown in the output and in local_base_updates in --json. A failure here never fails the create.
Per-project defaults live in your local flutree config (~/Documents/worktrees/.flutree_config.json, under projects), keyed by the absolute path of the root repository. Nothing is read from or written into the repository, so nothing is committed or shared; a .flutree.yaml in a repo is ignored. Every key is optional; without a section nothing changes.
Source: docs/diagrams/project-config-flow.html.
flutree config set --project ~/code/my-app packages core,design_system # comma-separated selectors
flutree config set --project ~/code/my-app base_branch develop
flutree config set --project ~/code/my-app package_base.core develop # one base branch per package
flutree config set --project ~/code/my-app package_base.design_system main
flutree config set --project ~/code/my-app sdk.manager fvm
flutree config set --project ~/code/my-app sync.update_local_base never
flutree config set --project ~/code/my-app branch_template "feature/{name}"
flutree config set --project ~/code/my-app copy_root_files .env.local,extra.txt
flutree config list --project ~/code/my-app # what the section sets (--json for machines)
flutree config get base_branch --project ~/code/my-app # value and the layer that decided it
flutree config unset --project ~/code/my-app package_base.core # one key
flutree config unset --project ~/code/my-app # the whole section| Key | Meaning |
|---|---|
packages |
Default package selection (names, package names or paths relative to the root repo); --package / --no-package replace it |
base_branch |
Base branch of the root worktree (--base-branch wins) |
package_base.<selector> |
Base branch of one package; the selector is a folder name, package name or path (--package-base wins) |
sdk.manager |
auto, fvm, puro or none, same values as the global key |
sync.update_local_base |
ask, always or never, same values as the global key |
branch_template |
New branch name. Placeholders: {name} (slug of the workspace name), {ticket} (create --ticket, verbatim: the case is kept) and {desc} (slug of create --desc); at least one is required, e.g. feature/{ticket}/{desc}. --branch wins, then --branch-template; see Branch names that follow team conventions |
branch_pattern |
Optional regular expression every branch must match; create, create --from-existing and add-repo refuse one that does not. No pattern by default |
copy_root_files |
Extra root files to copy (--copy-root-file replaces them) |
<root> must be an existing directory; it is stored as an absolute, cleaned path with symlinks resolved, so the same repo is found however it is spelled. config list without --project shows every global key with its source plus the roots that have a section. config unset removes a key that is not set without error.
Precedence, decided in one place: explicit CLI flags (or MCP arguments) > the project section > the matching team profile > the global config (flutree config) > built-in defaults. create (CLI, wizard defaults and the MCP tools plan_create, create_workspace and create_worktree) uses all keys; add-repo uses package_base, copy_root_files, sdk.manager and sync.update_local_base. A package listed in packages still needs a base branch, from package_base.<selector>, --package-base or the usual develop default; an agent using MCP is still asked for it.
Which layer decided what. With a section present, the dry plan prints one line (Config decided by ...), and the --json result of create / add-repo and the MCP plan_create result carry an additive config_sources object ({"branch": "project", "base_branch": "flag", "sdk.manager": "global", ...} with the values flag, project, profile:<name>, global or default) plus profile (the applied team profile) and config_file (the local config file). Without a section none of this appears.
Validation. config set validates before saving: an invalid value is an input error (exit 2) that names the key and leaves the file unchanged, for example Invalid value for sdk.manager.; branch_template must contain at least one of {name}, {ticket} or {desc} and supports no other placeholder, and branch_pattern must be a valid regular expression. A value edited into the JSON by hand is validated when it is read and fails with the same exit code.
Lists managed workspaces. Inside a repository the scope is that repo; outside one it falls back to the global registry.
The status of every workspace is checked, never assumed. For each worktree flutree verifies that the folder exists, that git rev-parse --git-dir succeeds inside it, that the source repository exists and is a git repository, and that the worktree appears in the source repository's git worktree list --porcelain. A workspace takes the worst status of its worktrees (broken, then missing, then active).
| Status | Meaning |
|---|---|
active |
Every worktree passed all four checks. |
missing |
A worktree folder is gone. |
broken |
A folder exists but git does not accept it. list --json and status --json add a reason: source_repo_missing (the source clone is gone), gitdir_missing (git cannot read the worktree's .git) or not_registered_in_source (the source repository does not list this path). |
completed |
The workspace was completed. |
unmanaged |
Only with --all: a git worktree flutree does not manage. |
flutree list [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--all |
bool | false |
Include unmanaged Git worktrees |
--global |
bool | false |
List across all registered repositories, from any directory |
list also shows each workspace's size on disk and its age, and flags the stale ones. Size is every regular file in the root and package worktrees (build outputs and SDK caches included; symlinks are skipped, never followed). Age counts from the created_at of the registry entry, or from the modification time of the workspace folder when the entry has none. A workspace older than cleanup.stale_days (default 60) is stale. --json adds size_bytes, age_days and stale to every managed row; unmanaged rows (--all) have no size or age.
flutree list
flutree list --global --allShows the validated state of one workspace: its root and package worktrees with their status, dirtiness and ahead/behind.
flutree status <workspace> [--remote] [--json]
Statuses and reasons are the ones described in list; the workspace status rolls up from its worktrees. Ahead/behind are measured against origin/<base> when that remote-tracking ref exists (compared_to names the ref used). local_base_behind says how far the local <base> branch is behind origin/<base>, with a base_warning such as local develop is 270 commits behind origin/develop; ahead/behind is measured against origin/develop. Without an origin/<base> ref the local base is used, as before. Nothing is fetched: run git fetch yourself to refresh the refs.
linked (and linked_files, the pubspec.yaml paths) tell whether the workspace holds a link-remote block; the text output adds a Linked line. stale_overrides[{file, package, ref, branch}] lists block overrides whose ref no longer matches the branch checked out in the repository they point to (re-run link-remote); the text output adds a Stale override: line.
A worktree whose HEAD does not resolve (an unborn HEAD, for example after a case collision in the ref path) is reported as broken: HEAD does not resolve (<ref>), never clean, without ahead/behind; the JSON carries head_ok (false) and head_ref for every existing active worktree, and flutree doctor lists it.
ready_to_push{repos[{repo, role, branch, unpushed_commits, on_origin: true|false|null, on_origin_local?: true|false|"unknown", refs_fetched_at?, new_branch}], total_unpushed, missing_on_origin[], remote_checked} says what push would send. It comes from local refs only (status never fetches): on_origin is true when refs/remotes/origin/<branch> exists, false when the repository has origin refs but not that branch, and "unknown" when it has no origin ref at all; missing_on_origin lists only new branches with commits of their own, like push. --remote asks origin with git ls-remote instead. Each repository also carries remote_checked, remote_source (origin|local_refs) and, from local refs, local_refs_fetched_at (mtime of FETCH_HEAD; text: "based on local refs from , may be stale"); the block has remote_source (origin|local_refs|mixed). When origin cannot be queried (--remote), status never fails: that repository reports on_origin: null, remote_checked: false and remote_error: {kind: network|credentials|no_origin|unreachable, message, hint?}, the text says "origin not checked: (: )", and it is never in missing_on_origin. When origin was not checked (remote_checked: false, the default local-refs mode), on_origin is null: the local answer is in on_origin_local (true, false, or "unknown" with no origin ref at all) with refs_fetched_at, and the text says "not seen on origin: (local refs from , may be stale)", never "branch not on origin"; only when origin was really checked (--remote) does on_origin carry true/false and the text say "branch not on origin".
flutree status feature-login
flutree status feature-login --json
flutree status feature-login --remoteRemoves a workspace's worktrees and cleans its registry entry. Local branches are kept unless you pass --delete-merged-branches. If a recorded path is already missing, it cleans the stale entry and still succeeds.
flutree complete <name> [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--yes |
bool | false |
Skip interactive confirmation |
--force |
bool | false |
Force worktree removal (also allows dirty worktrees) |
--non-interactive |
bool | false |
Disable prompts; requires --yes |
--delete-merged-branches |
bool | false |
After the worktrees are removed, delete each workspace branch merged into origin/<base> |
With --delete-merged-branches, once the worktrees are gone each repository's workspace branch is checked with the merge detector prune and doctor use. A branch merged into origin/<base> is deleted with git branch -d; a squash or rebase merge whose content is proven to be in origin/<base> is deleted with git branch -D (merge_method says which). -D is never used without that proof. A record without a recorded base gets an inferred one like prune does (base_inferred, base_source); on a tie between bases the branch is kept and base_candidates lists them (complete has no --base: record the base with flutree config set --project <root> base_branch <branch> and run it again). A branch with commits on no origin ref is never deleted. Every branch is reported as deleted, or kept with the reason: not merged, unproven, unpushed, tied bases, no base found, checked out in another worktree, or git refused. --json adds a branches array ({repo_root, branch, status, reason?, compared_to?, merge_method?, unpushed_commits?, base_branch?, base_inferred?, base_source?, base_ambiguous?, base_candidates?}).
When a dirty worktree is refused, the message lists per repository the uncommitted files and the unpushed commits (error.details.at_risk with --json). Unpushed commits warn but never block, because the branch is kept; a completed --json result lists them in at_risk (absent when there is nothing dirty or unpushed).
flutree complete feature-login
flutree complete feature-login --non-interactive --yes --force
flutree complete feature-login --yes --delete-merged-branchesTeam profiles share settings across a team without putting any file in the product repositories. A profile lives in your local flutree config (~/Documents/worktrees/.flutree_config.json, under profiles) and is exchanged as one standalone file that the team keeps wherever it already shares things (a wiki, a gist, an internal dotfiles or tooling repository). flutree never adds, requires or reads a file committed in your repositories: a .flutree.yaml or a profile file inside a repo is ignored.
flutree profile list [--json]
flutree profile show <name> [--json]
flutree profile export <name> [--out <file>] [--json]
flutree profile import <file|https-url> [--yes] [--dry-run] [--json]
flutree profile sync [--yes] [--dry-run] [--json]
flutree profile remove <name> [--yes] [--json]
A profile is keyed by the root repository's normalized origin URL (credentials, the scheme or git@host: form, a port and a trailing .git are dropped and the host is lower-cased, so git@GitHub.com:acme/app.git and https://github.com/acme/app are the same repository), with the root package name as fallback (match.package, used only when no profile matches by origin). create, add-repo and link-remote pick the matching profile automatically and print which one was applied; --json and the MCP results carry profile.
The exported file is YAML with a version tag (JSON is accepted on import too):
schema: flutree.profile/v1
name: acme
match:
origin: github.com/acme/app # normalized origin URL of the root repository
# package: acme_app # fallback: the root package name
packages: [core, ui] # default packages for create
base_branch: develop # base branch of the root
package_base: # base branch per package (folder name, package name or path)
core: develop
ui: main
hub: acme_hub # hub package name, used by link-remote --via-hub
branch_template: feature/{name} # {name}, {ticket} (case kept), {desc}
branch_pattern: '^feature/[A-Z]+-[0-9]+/.+$' # optional: refuse other branches
sdk:
manager: fvm # auto | fvm | puro | none
sync:
update_local_base: never # ask | always | never
copy_root_files: [.env.team]
link_remote: # defaults for link-remote (a flag always wins)
via_hub: true
on_unpushed: continue # continue | abort
on_conflict: keep # take-over | keep | abort
package_overrides: graph # graph | all | none
root_only_graph: false # true: the root overrides only what its graph reaches
cleanup:
stale_days: 30 # used by prune when --stale-days is not given- Import validates, shows the diff and asks.
profile importchecks the schema (flutree.profile/v1), rejects unknown keys and wrong types, validates every value, prints what would change against the stored profile of the same name (+ key = value,~ key: old -> new,- key (was old)) and asks before writing.--yesskips the question; without a terminal (or with--json) and without--yesit is refused and nothing is written, so an unattended run never changes your profiles.--dry-runonly shows the diff. An unchanged profile is reported as already up to date. - Only https, never executed. A URL must be
https://(a plainhttp://URL is refused without connecting), redirects to a non-https URL are refused, the download is limited to 1 MiB and times out after 15 seconds. A failed fetch is a typed error (Failed to fetch the profile from <url>, categorygit, exit1, the samefetch failedfamily as git) and leaves the local profile unchanged. Nothing in the file is ever executed or evaluated. - Sync on demand.
FLUTREE_PROFILE_SOURCE(environment variable, wins) or the config keyprofile.source(flutree config set profile.source <file|https-url>) name a file or URL;flutree profile syncrefreshes the local copy with the same validation, diff and confirmation. flutree never fetches a profile automatically. - What each setting does.
packages,base_branch,package_base,branch_template,branch_pattern,copy_root_files,sdk.managerandsync.update_local_basebehave like the project config keys of the same name;hubnames the hub forlink-remote --via-hub(consulted before the dependency-graph heuristic);link_remote.*are defaults forlink-remoteflags;cleanup.stale_daysis the stale thresholdpruneuses for workspaces of that root when--stale-daysis not given (a workspace whose root repository cannot be located keeps the globalcleanup.stale_days). - Precedence, decided in one place: CLI flags (or MCP arguments) > the user's own project section (
config set --project) > the matching profile > the global config > built-in defaults. The source of each value isflag,project,profile:<name>,globalordefault;projectandglobalare the "user" layer, and the existing spellings are kept for compatibility.flutree config show --project <root> --originprints every effective value with its source. - Two layers on purpose: the profile is the team layer (shareable, keyed by origin), the project section is your local override (keyed by path) and wins over it.
flutree profile import https://example.com/team/acme.flutree-profile.yaml
flutree profile list
flutree config show --project ~/code/my-app --origin
flutree profile export acme --out acme.flutree-profile.yaml
FLUTREE_PROFILE_SOURCE=https://example.com/team/acme.flutree-profile.yaml flutree profile syncWith --json: profile list prints flutree.profile_list/v1 ({schema, profiles[{name, match, ...}]}), profile show flutree.profile_show/v1, profile export flutree.profile_export/v1 ({schema, name, path?, content}), and profile import, profile sync and profile remove the flutree.profile_change/v1 document ({schema, name, source, new, changed, applied, diff[{key, old, new}], match}).
Finds the workspaces that can be cleaned up and removes them on request.
flutree prune [--dry-run] [--yes] [--all] [--select <workspace>...] [--stale-days N] [--include-unregistered] [--base <branch>] [--json]
| Flag | Type | Default | Description |
|---|---|---|---|
--dry-run |
bool | false |
Only report; never remove anything |
--yes |
bool | false |
Remove the safe candidates without prompting |
--select |
string, repeatable | none | Workspace to remove even when it is dirty or unmerged |
--stale-days |
int | the root's profile cleanup.stale_days, else cleanup.stale_days (60) |
Age in days after which a workspace is stale; 0 treats every workspace as stale. Without the flag, a candidate whose root repository matches a profile that sets cleanup.stale_days uses it (stale_profile in --json); a workspace whose root cannot be located keeps the global value |
--all |
bool | false |
Select every registered workspace (the report still lists what would be lost; removal still needs --yes or the interactive confirmation) |
--include-unregistered |
bool | false |
Also remove the unregistered folders under ~/Documents/worktrees that the report lists |
--base |
string | none | Force this base branch for every merge check (default: the recorded base, else an inferred one) |
A workspace is a candidate when its branch is merged into origin/<base> in every repository (the local base when there is no origin ref), when it is broken or missing (for example its source clone was deleted), or when it is older than the stale threshold. For each candidate the report shows size, age, dirty state, merge state and the reasons.
- Without
--yesand without a terminal,pruneis a dry run: it prints the report and exits0. In a terminal it offers a numbered selection and asks for confirmation. --yesremoves only the safe candidates: missing ones, and those with no uncommitted changes and nothing unmerged. A broken workspace whose folder still exists cannot be checked by git, so it is reported as unverified and needs--select <workspace>.- A dirty or unmerged workspace is never removed unless named with
--select. The report always lists what that would lose: uncommitted files and unmerged commits (worktrees whose base cannot be compared are flagged as unverified, never treated as safe). - Healthy worktrees go through the same flow as
flutree complete. Broken worktrees, whichgit worktree removecannot handle, have their folder and registry entry deleted, only inside~/Documents/worktrees, only for registry-managed paths and without following symlinks. - Merge detection. A branch counts as merged when it is an ancestor of the base, when its content is already in the base (a squash or rebase merge: merging it would change nothing;
merge_methodissquash), or when origin deleted it and the GitHub CLI (gh) reports a merged pull request whose head is the branch's current tip, so later commits keep it unmerged (merge_methodisforge_pr;ghis optional and is skipped silently when it is missing, fails or has no network). A merge state that cannot be told (for example a branch whose reflog is gone) stays unmerged, never merged. - Base inference. A worktree recorded without
base_branchis not skipped: its base is inferred, in this order, from the configured default base of the repository (base_branchorpackage_baseof the project section, seeconfig set --project), fromorigin/HEAD(the default branch of origin) and from the closest ofdevelop,mainandmasterby merge-base distance; an inferred base must exist in the repository. Inferred bases are marked:base_inferred: true(withbase_branchandbase_source:config,origin_head,closestorflag) in--jsonand "inferred" in the text. When no base can be inferred the worktree stays unverified (never safe, never merged).--base <branch>forces one base for every check, over the recorded one. When several bases are equally close (for exampledevelopandmainat the same distance) flutree never picks one silently: each worktree reportsbase_ambiguous: trueandbase_candidates[{base, compared_to, merged, merge_method}]with the merge state against every tied base (two bases on the same commit are one base, not a tie), and the text report names them. Merged into every tied base keeps the merged verdict; merged into only some of them, or into none, is reported but the worktree is never safe to remove on that guess (merged into only some counts as unverified;unmerged_commitskeeps the real count against the first candidate);doctorlists the merge and the tie without acting on it, and--base <branch>decides.completedoes not infer bases, so it is unaffected. - A workspace whose folders are already gone (including a legacy entry that is not at
<container>/root/<repo>) is removed whatever its layout: its registry entry and the git worktree metadata in the source repositories.flutree completeandflutree doctor --fixuse the same routine for such entries. - Branches are never deleted; use
flutree complete --delete-merged-branchesfor that. - Unregistered folders. Folders under
~/Documents/worktreesthat the registry does not know are always listed (unregisteredin--json,doctorlists them too), classified aslive_worktree(a git worktree of a source repository),dead_git(a checkout whose git metadata is gone),empty_or_non_git(an empty or plain folder, or a symlink) orforeign_git(a checkout whose owning repository cannot be resolved; never removed). A live worktree of a repository the registry does not know is alive_worktreetoo, withowner_from_gitdir: true: its owner (repo_root) is resolved from thegitdirin its.gitfile and confirmed by that repository's owngit worktree list;prune --include-unregisteredremoves it withgit worktree removein that repository under the usual rules (uncommitted files shown, unpushed commits refused unless named inselect).foreign_gitis kept only when the owner cannot be resolved.--include-unregisteredremoves them under the same rules: the report shows the uncommitted files and unmerged commits first,--yesremoves only the safe ones (empty folders, symlinks as links, clean live worktrees with nothing unmerged), the others need--select <path relative to ~/Documents/worktrees>, deletion stays inside the workspaces root, symlinks are never followed, and live worktrees go throughgit worktree removein their owning repository. When the folders of a workspace are already gone,removed[]reports what happened to git's metadata per worktree ingit_metadata[{name, path, status, message, manual_fix}](applied,already_gone,skippedorfailed); the message never says the metadata was removed when git still lists the worktree, and paths through a symlink are compared with symlinks resolved. When git refuses to drop the metadata (for example the worktree is locked), that workspace is reported asfailed, its registry entry is kept so a laterpruneordoctor --fixcan retry,pruneexits non-zero, and thegit_metadataentry carriesmanual_fix, the exact commands to run by hand (git -C <repo> worktree remove --force --force <path>,git -C <repo> worktree prune, thenflutree prune --yes); the text output prints them under the failed entry. Adead_gitcheckout can never be verified:cannot verify unpushed work: branch <b> not found locally or on origin(orbranch unknownwhen nothing remembers it) means it is only removed when named explicitly. --jsonprints one document with"schema": "flutree.prune/v1":{schema, dry_run, stale_days, candidates: [{name, branch, path, status, reason?, size_bytes, age_days, stale, dirty, merged, reasons, safe, selected, would_lose?, worktrees}], summary: {candidates, safe, total_size_bytes, unregistered}, removed: [{name, status, message, kind?}], unregistered: [{name, path, kind, symlink?, repo_root?, branch?, size_bytes, dirty, dirty_files, unmerged_commits, safe, selected, removable, warning?, would_lose?}]}. The exit code is1when a removal failed.
flutree prune
flutree prune --yes
flutree prune --select wip-feature --yes
flutree prune --stale-days 30 --json
flutree prune --all --yes
flutree prune --include-unregistered --yes
flutree prune --include-unregistered --yes --select legacy/packages/pkg_oldRuns pub get in all package repos of a workspace in parallel, then in the root last.
flutree pubget <name> [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--force |
bool | false |
Clean cache and remove pubspec.lock before pub get |
flutree pubget feature-login
flutree pubget feature-login --forceChecks that a workspace resolves, and optionally compiles, the way CI will: without the local pubspec_overrides.yaml files.
flutree verify-remote <workspace> [--analyze] [--json]
| Flag | Type | Default | Description |
|---|---|---|---|
--analyze |
bool | false |
Also run flutter analyze / dart analyze after pub get succeeds |
How it works:
- It copies the root worktree's source tree to a temporary directory outside the workspace (without
.git,.dart_tool,buildandpubspec_overrides.yaml; apubspec.lockis the committed one), runspub getthere (flutterordart, detected from the pubspec) and, with--analyze, the analyzer, then removes the copy. The copy is removed also when a step fails and on Ctrl-C. - Without
pubspec_overrides.yaml, git, hosted and path dependencies resolve as in CI, so you see whether the code works against the git refs yourpubspec.yamlpoints at. - Path dependencies that point outside the repository (for example
path: ../sibling) resolve against the copy's location, not against your checkout, so they will usually fail to resolve. They are reported as warnings and never rewritten. - It never modifies the workspace.
git status --porcelainand the bytes of everypubspec_overrides.yamlare compared before and after, and the report says so. - It needs the network and your git credentials for git dependencies. Git terminal prompts are disabled, so a missing credential fails instead of waiting for input. Network and credential failures are named in the failed step (
kind:networkorcredentials), and URLs in the output never show credentials.
Output: per step (copy, pub_get, analyze) the status and a bounded tail of the tool output. Exit code 0 when every step passes, 1 otherwise. With --json it prints the flutree.verify_remote/v1 document: {schema, workspace, root, tool, analyze, ok, steps[{name, status, command, exit_code, output_tail, output_truncated, message, kind}], warnings[], temp_dir, temp_dir_removed, worktree{unchanged, checked[], differences[]}}.
flutree verify-remote feature-login
flutree verify-remote feature-login --analyze --jsonOpt-in. While a ticket spans several repositories you resolve packages locally through pubspec_overrides.yaml, but CI only sees the committed pubspec.yaml. link-remote writes temporary git overrides pointing at your ticket branches into the pubspec.yaml of every repository of the workspace, so CI resolves them too. This is the one flutree command that edits pubspec.yaml; create, add-repo and the rest never do.
flutree link-remote <workspace> [--dry-run] [--on-conflict take-over|keep|abort] [--on-unpushed continue|abort] [--via-hub [--hub <package>]] [--root-only-graph] [--package-overrides graph|all|none] [--offline] [--non-interactive] [--yes] [--json]
| Flag | Type | Default | Description |
|---|---|---|---|
--dry-run |
bool | false |
Report the plan (entries, conflicts, branches on origin, push order) and write nothing |
--on-conflict |
string | ask / abort | A manual override of the same package already exists outside the block: take-over (replace it while linked; unlink gives it back), keep (leave it, link nothing for that package) or abort |
--on-unpushed |
string | ask / abort | A branch is not on origin yet: continue (warn and link anyway) or abort |
--via-hub |
bool | false |
Link the hub (aggregator package) instead of every package behind it |
--hub |
string | detected | Package name of the hub for --via-hub |
--root-only-graph |
bool | false |
The root overrides only the packages its dependency graph reaches, not every workspace package (see "Which overrides each repository gets") |
--package-overrides |
string | graph |
Which siblings each package repository overrides: graph (its resolved graph), all (every sibling) or none (only the root is linked) |
--offline |
bool | false |
Plan without asking origin which branches exist; the report warns and --json says remote_checked: false |
--non-interactive |
bool | false |
Never prompt. Without a terminal (or with --json) an undecided conflict or unpushed branch aborts with a clear error |
What it writes, between the markers, is a git override per sibling package (see the next list for which repository gets which):
dependency_overrides:
# flutree:managed-begin feature-login
# Temporary: remove before merging into develop
core:
git:
url: git@github.com:team/core.git # origin URL of that package's repository
ref: Feature/ABC-1/login # the branch actually checked out in that worktree
path: packages/core # only when the package is not at the repository root
# flutree:managed-end- Which overrides each repository gets.
- The root gets one for EVERY workspace package. A package is in the workspace because the root consumes it, and the root's
dependency_overridesapply to the whole graph, so they win over whatever a hub pins. This is the default even when the root reaches the packages only through a hub that is not a workspace member.--root-only-graph(or the profile'slink_remote.root_only_graph) falls back to the strict graph rule: only what the root'spubspec.yamlreaches. - Each package repository gets one for every sibling in its own resolved graph. Pub applies only the overrides of the package being resolved, so the root's overrides do not cover a package's own CI. The graph is detected from the package's
pubspec.lock(tracked, or the local onepub getleft in the worktree); without one, from the hub'spubspec.yamlin the pub cache ($PUB_CACHE/git/<repo>-<sha>/<path>) or in a local clone with the same origin URL; when neither is available link-remote stops with an explanation (runpub getthere, or pass--package-overrides all|none), and never assumes "no dependency".--package-overrides allgives every package an override for every sibling (an override for a package outside the graph has no effect, it only adds lines; never for the root application, and those extra lines do not create cycles);nonelinks only the root. A sibling of the same repository that a package declares by git URL also gets an override to the ticket branch (one declared by relativepath:already follows the branch and is left alone). - Why each one is there. Every entry carries a
reasonin the text report ([direct],[lockfile],[hub],[all]) and in--json:direct(declared in that package's ownpubspec.yaml),lockfile(listed in itspubspec.lock),hub(reached through another package'spubspec.yaml, including the hub's cached one) orall(the root rule, or--package-overrides all). - Nested packages. A package that lives inside a repository (
packages/innerof a mono repository) gets its own block in its ownpubspec.yaml, with the siblings of other repositories it depends on;unlink-remoteandcheck-unlinkedhandle those files too. - Nothing silently skipped. A workspace with packages where nothing would be linked exits non-zero (for example "the root does not declare
<pkg>; it is probably reached through<dep>; the root rule was disabled").
- The root gets one for EVERY workspace package. A package is in the workspace because the root consumes it, and the root's
- Surgical edit. Only whole lines between the markers are added. Comments, order, blank lines and every entry outside the block stay byte-identical; if
dependency_overridesdoes not exist it is created inside the block and removed with it.unlink-remoterestores the file byte for byte (also without a final newline and with CRLF). A file holds one block: with--on-conflict take-overthe manual entries move into that block as# flutree:wascomments (with the line they had) and go back exactly there on unlink. Adependency_overrideswritten in flow style ({}) is refused with a clear error: convert it to block style first. - Real branches. The ref is read from each worktree (
git), never derived: one repository can be onFeature/ABC-1/xwhile the others are onfeature/abc-1/x. - Local resolution keeps working. A
pubspec_overrides.yamlreplacesdependency_overrides, so the root's and every package's file is regenerated: committed overrides (the new git ones included) are carried and the workspace packages, including packages inside a repository's subfolder, are swapped to their worktree paths. A localpub getstill resolves to the worktrees. - Origin check. Every referenced branch is looked up with
git ls-remote --heads(nothing is fetched) before anything is decided or written. If origin cannot be queried (authentication, HTTP 403, DNS, timeout) link-remote stops withcould not check branches on origin: <reason>(a git error that still saysfetch failed, asverify-remotereports it), and--on-unpushed continuedoes not hide it;--offlineplans without the check (a warning in the text,remote_checked: falseand nobranchesin--json). An unpushed branch is a warning with a continue/abort choice. The report ends with the push order, packages included: leaf packages first, packages that depend on them next, the root last; repositories that override each other are reported as a cycle (cycles) and all of them must be pushed before either CI can pass. It also prints the delivery consequences (delivery): every repository with a block, packages included, runsunlink-remote(or--pin) before merging into its base, andcheck-unlinkedbelongs in every repository's CI. pubspec.lock. Repositories that track it are reported: it must be refreshed against the remote refs: runpub getin a clean checkout of the pushed branch (withoutpubspec_overrides.yaml) and commit the result.flutree verify-remoteonly checks that the root resolves against the remote refs, in a temporary copy, and never changespubspec.lock.- Hub. With
--via-hubthe other repositories override the hub and the hub's ownpubspec.yamllinks its packages, instead of every transitive package in the root. The hub is detected from the dependency graph (a package repository that depends on two or more other workspace packages and that another repository depends on); several candidates need--hub. A matching team profile names the hub (hub) and supplies defaults for--via-hub,--on-unpushed,--on-conflict,--package-overridesand--root-only-graph(a flag always wins;profileandprofile_defaultsin--jsonsay what it supplied). - Never commits. flutree changes files only; you commit, push and merge.
statusanddoctorshow a linked workspace.
flutree link-remote feature-login --dry-run
flutree link-remote feature-login --on-conflict take-over --on-unpushed continueWith --json it prints flutree.link_remote/v1: {schema, workspace, applied, dry_run, hub?, profile?, profile_defaults?, repos[{repo, role, package, pubspec, branch, base, status, entries[{package, url, ref, path?, repo, took_over?, reason}], kept?}], conflicts[{repo, package, pubspec, existing, resolution?}], branches[{repo, branch, url, on_origin}], unpushed[], push_order[{order, repo, role, branch, path}], tracked_lockfiles[], overrides[], warnings?, root_rule, package_overrides, remote_checked, cycles[[repo]], delivery[]} (root_rule is all, graph or hub; the new fields are additive).
Removes exactly the managed blocks link-remote wrote, gives back the manual entries a take-over kept, and regenerates pubspec_overrides.yaml. If nothing else changed, every pubspec.yaml ends up byte-identical to its content before link-remote. On a workspace that is not linked it does nothing.
flutree unlink-remote <workspace> [--pin <package>=<ref>]... [--pin-dependency <package>=<ref>]... [--drop-covered] [--offline] [--force] [--json]
| Flag | Type | Default | Description |
|---|---|---|---|
--pin |
string (repeatable) | none | Replace that package's managed override with a pinned git override outside the block (same url and path, ref set to the tag or ref you give): the "merge the package, tag it, pin it" step. The ref is first looked up on that package's origin (git ls-remote over tags and branches): a tag or a branch of origin is accepted, a full 40-character commit sha cannot be looked up and is accepted with a warning, anything else fails and writes nothing; an origin that cannot be asked is could not check ref ... on origin: <reason> |
--pin-dependency |
string (repeatable) | none | Hub release step, root only: edit only the ref: line of a regular git dependency of the root pubspec.yaml (diff shown first, ref checked on that dependency's origin, no tag ever created, the managed block stays). Reports pinned_dependencies[] and which overrides it now covers in covered[{package, status: covered|unverified|not_covered, reason}]. Not combinable with --pin |
--drop-covered |
bool | false | With --pin-dependency: remove exactly the covered overrides from the managed block (dropped[]), keep the rest. Without it (and without a terminal) they are only reported |
--offline |
bool | false | Skip that ref check (warning; remote_checked is false in --json) |
--force |
bool | false | Remove a managed block even if it was edited by hand. Without it, an edited block makes unlink-remote list the changed lines per file, fail with a precondition error (exit 1) and change nothing |
flutree unlink-remote feature-login
flutree unlink-remote feature-login --pin core=v1.4.0
flutree unlink-remote feature-login --pin core=v1.4.0 --offline
flutree unlink-remote feature-login --force
flutree unlink-remote feature-login --pin-dependency hub_pkg=v2.1.0 --drop-coveredWith --json it prints flutree.unlink_remote/v1: {schema, workspace, unlinked, files[{repo, pubspec, status, pinned?, restored?}], overrides[], warnings?, pins?[{package, ref, kind, checked}], remote_checked}; remote_checked is true only when origin was asked about at least one pin (false without --pin, with --offline, or when every pin is a sha). Pinning a package that has no managed override is an input error (exit 2) and changes nothing.
Pushes the workspace branch of every repository, leaves first and the root last (the order link-remote reports), so the CI of each repository finds the sibling branches it points to. Without --yes it only prints the plan.
flutree push <workspace> [--dry-run] [--yes] [--offline] [--json]
| Flag | Type | Default | Description |
|---|---|---|---|
--dry-run |
bool | false |
Print the ordered plan ({order, repo, branch, commits, set_upstream, action: push|skip, reason}) and push nothing |
--yes |
bool | false |
Push in order with git push [-u] origin <branch>; stops at the first failure and reports pushed, failed and not_attempted (exit 1) |
--offline |
bool | false |
Plan from local refs without asking origin which branches exist |
It never forces: there is no force option and no + refspec, and a non-fast-forward rejection stops with a hint to run flutree sync. Repositories with nothing to push are skipped; the base branch and a detached HEAD are refused; uncommitted changes and uncommitted link-remote blocks are warned about because push sends commits only. If the dependency graph cannot be detected the packages go before the root, with a warning. MCP: push_workspace (the user is always asked before it pushes).
flutree push feature-login --dry-run
flutree push feature-login --yesExits non-zero when any pubspec.yaml under a path still contains a flutree managed block, so a pre-push hook or the CI of a pull request to a protected branch can stop a temporary link from being merged. It only reads files, needs no registry and skips .git, .dart_tool, build and node_modules.
flutree check-unlinked [path] [--json]
path defaults to the current directory (a pubspec.yaml file is accepted too). Exit 0 when there is no block, 1 when there is at least one, 2 for a path that does not exist. --json prints flutree.check_unlinked/v1: {schema, path, ok, checked, linked[{file, workspace, line}]}.
flutree never installs hooks or files in your repositories. Copy-paste snippets for a shared CI template and a user-level global hook (core.hooksPath) are in docs/usage.md.
No flutree binary on the CI runner? flutree check-unlinked --print-ci-snippet <sh|pwsh|github-actions> (MCP: check_unlinked with ci_snippet) prints a guard that needs only git. It fails when any tracked pubspec.yaml has a line # flutree:managed-begin, ignores .dart_tool/, build/ and the pub cache, prints every file and line, and finds the same files and lines as check-unlinked (which also reads untracked files). POSIX shell version:
root=$(git rev-parse --show-toplevel) || exit 1
rc=0
git -C "$root" grep -n -E '^[[:space:]]*# flutree:managed-begin([[:space:]]*$| )' -- ':(glob)**/pubspec.yaml' ':(exclude,glob)**/.dart_tool/**' ':(exclude,glob)**/build/**' ':(exclude,glob)**/node_modules/**' ':(exclude,glob)**/.symlinks/**' ':(exclude,glob)**/.pub-cache/**' || rc=$?
if [ "$rc" -eq 0 ]; then
echo "error: the pubspec.yaml lines above hold a flutree link-remote block; run 'flutree unlink-remote <workspace>' before merging" >&2
exit 1
fi
[ "$rc" -eq 1 ] || exit "$rc"The PowerShell and GitHub Actions versions, and the "Managed block marker contract v1" (the exact begin and end lines; changing them is a breaking change), are in docs/usage.md.
flutree check-unlinked
flutree check-unlinked ~/code/my-app --jsonBrings origin/<base> into every repository of a workspace (the root and each package), one repository at a time, with a per-repository report. It fetches only the remote-tracking ref: the local <base> branch of your source repositories is never moved.
flutree sync <workspace> [--dry-run] [--yes] [--ff-only | --rebase] [--repo <name>] [--offline] [--json]
- Default: a branch with no commits of its own is fast-forwarded; one with its own commits gets
git merge --no-edit origin/<base>.--ff-onlynever creates a commit (a diverged branch is skipped).--rebasereplays your commits onorigin/<base>. The two flags exclude each other (exit2). - A repository is skipped, with the reason in the report, when it has uncommitted changes, a detached HEAD, a merge/rebase/cherry-pick in progress, no recorded base branch or no origin. flutree never stashes or forces anything.
- A conflict is never left behind: the merge or rebase is aborted, the worktree is verified to be back where it was, the conflicting files are listed (
conflicts[]) and the other repositories still sync. - When a
pubspec.yamlchanged,pubspec_overrides.yaml(and the.code-workspace) are regenerated; a workspace linked withlink-remotealso gets its managed blocks refreshed. --dry-runfetchesorigin/<base>and reports the plan without changing any worktree;--offlineplans and syncs from the refs already local. Applying needs--yes(without a terminal), or an interactive confirmation after the plan.- Exit codes:
0everything synced or up to date,1a conflict or a failure,2invalid input or no confirmation,3a repository was skipped.--dry-runexits0unless a repository could not be examined. --jsonprintsflutree.sync/v1:{schema, workspace, dry_run, offline, strategy, repos[{repo, role, path, branch, base, action: up_to_date|fast_forward|merge|rebase|skipped|conflict|failed, applied, reason?, ahead, behind, conflicts[], pubspec_changed, overrides_regenerated[]}], summary{repos, up_to_date, updated, skipped, conflicts, failed}, overrides_regenerated, overrides_error?, link_refresh?{applied, repos[], error?}, warnings?}.
flutree sync feature-login --dry-run
flutree sync feature-login --yes
flutree sync feature-login --rebase --repo core --yesCleans the current managed worktree (the one containing your current directory).
flutree clean [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--force |
bool | false |
Also remove pubspec.lock |
flutree clean
flutree clean --forceChecks for or applies a Homebrew update. Homebrew is the only supported update channel; for Scoop use scoop update flutree, and for release archives download the new one.
flutree update [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--check |
bool | false |
Check whether a brew update is available, without changing anything |
--apply |
bool | false |
Apply the brew update now (the default behavior of flutree update) |
flutree update --check
flutree updatePrints the CLI version only (stable, parseable output). flutree --version is equivalent.
flutree version
This command has no flags besides the global ones.
flutree version
flutree --json versionGenerates a shell completion script for bash, zsh, fish or powershell.
flutree completion <bash|zsh|fish|powershell>
This command has no flags besides the global ones. Run flutree completion <shell> --help for per-shell setup details.
flutree completion bash > /etc/bash_completion.d/flutree
flutree completion zsh > "${fpath[1]}/_flutree"
flutree completion fish > ~/.config/fish/completions/flutree.fish
flutree completion powershell | Out-String | Invoke-ExpressionRead-only health report of everything flutree tracks.
flutree doctor [--json] [--fix] [--yes] [--prune-worktrees] [--base <branch>]
| Flag | Type | Default | Description |
|---|---|---|---|
--fix |
bool | false |
Apply the safe fixes listed in the report, after confirmation |
--prune-worktrees |
bool | false |
With --fix, also run git worktree prune in every known source repository that lists worktrees whose folder is gone (it also drops the metadata of worktrees flutree does not manage) |
--base |
string | none | Force this base branch for the merged_branches check |
--yes |
bool | false |
Confirm --fix without prompting (required when there is no terminal) |
Checks, each printed as a group with [OK], [WARN] or [ERR] items:
| Check | Reports |
|---|---|
registry_vs_disk |
Registry entries whose folder is gone [ERR], and folders under ~/Documents/worktrees that are not in the registry (orphans) [WARN], with their kind (live_worktree, dead_git, empty_or_non_git, foreign_git); flutree prune --include-unregistered removes them, doctor never deletes folders. |
worktree_health |
Worktrees whose folder exists but git rejects them (gitdir_missing, not_registered_in_source) [ERR]. |
prunable_worktrees |
Per source repository, git worktree list --porcelain entries that are prunable [WARN]. |
source_repos |
Workspaces whose source clone no longer exists [ERR]. |
merged_branches |
Workspace branches already merged into origin/<base> (the local base when there is no origin ref) [WARN]: ancestors, squash or rebase merges (merge_method) and branches origin deleted whose pull request gh reports as merged. A record without a recorded base gets an inferred one (base_inferred, see --base); only a worktree whose base cannot be inferred is skipped. A tie between equally close bases is reported (base_ambiguous, base_candidates) and never acted on. |
dirty_worktrees |
Worktrees with uncommitted changes [WARN]; a worktree whose git status fails is also a [WARN] ("could not check"), never counted as clean. |
disk_usage |
Disk size per workspace (symlinks are not followed). |
linked_overrides |
Only when a workspace is linked: [WARN] per workspace whose pubspec.yaml files hold a link-remote block, with the unlink-remote command, plus one [WARN] per stale override (stale_overrides[{file, package, ref, branch}]: the block ref no longer matches the branch of its repository; re-run link-remote). Absent otherwise. |
mcp_binary |
The flutree binary path, a live mcp serve handshake and the flutree entry of each detected MCP client. |
git_refs |
Only when it finds something: a worktree whose HEAD does not resolve [ERR] (an unborn HEAD, for example after a case collision in the ref path; the message says what to check) and a source repository with a local branch literally named origin/<x> [WARN], which makes refs ambiguous (flutree never deletes it). |
The exit code is 0 when there is no [ERR] and 1 otherwise. --json prints one stable document with "schema": "flutree.doctor/v1": {schema, ok, summary: {ok, warn, err}, checks: [{id, title, status, items: [{status, subject?, message, path?, size_bytes?, kind?, base_branch?, base_inferred?, base_source?, merge_method?, base_ambiguous?, base_candidates?}]}], fixes: [{action, subject, description, diff?}], applied?: [{action, subject, status, message?, backup?}]}.
--fix also plans one repair_mcp_entry action per flutree entry in an AI client config whose command is missing or version-pinned (the [ERR] items of mcp_binary): it shows the diff, copies the file to <file>.flutree-bak-<timestamp> (applied[].backup) and rewrites only that command to the stable path, like flutree mcp install --repair. --fix lists the safe actions, asks for confirmation (or needs --yes when stdin or stdout is not a terminal; otherwise it exits 2 without changing anything) and applies only those: removing registry entries whose folder is gone, and removing the git metadata of exactly those flutree worktrees (remove git metadata of <path> in <repo>); worktrees you added yourself are never touched. A workspace whose root folder is gone but whose package folders still exist is left alone and the report suggests flutree complete <ws> --force. With --prune-worktrees it also plans one prune_worktrees action per known source repository (git worktree prune), which removes the git metadata of every worktree whose folder is gone, flutree-managed or not. It never deletes folders or branches. After the fixes it checks again; applied lists what was done.
flutree doctor
flutree doctor --json
flutree doctor --fix --yes
flutree doctor --fix --prune-worktrees --yesRuns, installs and diagnoses the MCP server for AI agents. See Set up flutree for your AI agent (MCP) for the step-by-step guide.
flutree mcp <serve|install|uninstall|doctor>
Supported clients for --client: claude-code, opencode, codex, cursor, vscode, gemini, claude-desktop, windsurf.
Starts the MCP stdio server. AI clients launch it themselves; you rarely run it by hand. stdout is the JSON-RPC transport, so --json must not be used.
flutree mcp serve
This command has no flags besides the global ones.
flutree mcp serveWrites the flutree entry into every detected client (or the ones you choose). Existing keys and other servers are preserved; an existing flutree entry is kept unless --force.
flutree mcp install [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--client |
string | Comma-separated clients to target. Omit to target all detected clients | |
--scope |
string | user |
user or project (the current directory). Clients without a project config report unsupported_scope |
--dry-run |
bool | false |
Show the target file and entry per client without writing (works with --json) |
--force |
bool | false |
Overwrite existing entries; also strips comments from JSONC/TOML configs |
--repair |
bool | false |
Only rewrite existing flutree entries whose command is missing or version-pinned (Cellar/<version>, scoop/apps/flutree/<version>) to the stable path. Shows a diff per file and backs each changed file up to <file>.flutree-bak-<timestamp>; with --dry-run it only shows the diffs; the edit is made in place (key order, indentation, line endings and comments are kept), so --force is not needed (deprecated and without effect together with --repair: it only prints a warning on stderr) |
flutree mcp install --repair --dry-run
flutree mcp install --dry-run
flutree mcp install --client claude-code,cursor --scope projectRemoves only the flutree entry from each detected client.
flutree mcp uninstall [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--client |
string | Comma-separated clients to target | |
--scope |
string | user |
user or project |
--dry-run |
bool | false |
Show what would be removed without writing |
flutree mcp uninstall --dry-run
flutree mcp uninstall --client opencodeReports the resolved flutree binary, per client whether it was detected, its config path, whether the flutree entry exists and its command is an executable, and runs a live mcp serve initialize handshake (5s timeout). Exits 1 on [ERR].
flutree mcp doctor [flags]
| Flag | Type | Default | Description |
|---|---|---|---|
--scope |
string | user |
Config scope to inspect: user or project |
flutree mcp doctor
flutree --json mcp doctor --scope projectDefault destination root is ~/Documents/worktrees. Each workspace is one folder:
~/Documents/worktrees/<worktree-name-slug>/
root/<root-repo-folder>/ # the root app worktree (holds pubspec_overrides.yaml)
packages/<package-repo-folder>/ # one worktree per selected package (holds its own pubspec_overrides.yaml when it needs one)
<name>.code-workspace # optional, folders only
create is a two-phase flow: it first renders a full dry plan (repos, branches, paths, commands and output files), then asks for one final confirmation before any git worktree add or file and registry write. If the target branch already exists, it asks whether to reuse it. In interactive mode it also asks whether to sync local branches from origin first.
pubspec_overrides.yaml rules:
flutree createwrites onepubspec_overrides.yamlin the root worktree when at least one package is selected; root-only workspaces (--no-package) get no file.- It keeps every
dependency_overridesentry already declared in the rootpubspec.yaml(version,path,git,hosted), because apubspec_overrides.yamlreplaces those instead of merging with them. Relative paths that point outside the repository are rebased so they still resolve from the worktree; selected package worktrees win on conflict. - The whole dependency graph is resolved from the worktrees, so transitive path dependencies between selected packages point at their worktrees too.
- The file is ignored through
.git/info/exclude(never committed); the tracked.gitignoreis not modified.pubspec.yamlis not modified bycreateoradd-repo; only the opt-inlink-remoteedits it (andunlink-remoterestores it). - Each selected package worktree gets its own
pubspec_overrides.yamltoo, becauseflutree pubgetresolves inside every package and pub only reads the overrides of the package it resolves. It points the selected packages that package depends on (directly or through other selected packages, whatever the dependency spec:path,git, hosted or version) at their worktrees, and carries the package's owndependency_overrideswith the same rules as the root. Paths are relative to the package worktree. - A package that needs nothing gets no file. A package that uses Dart pub workspaces (
resolution: workspace) is skipped, and the--jsonresult lists it underpackage_overrideswith a note.add-reporegenerates the files of every package worktree; entries you edited by hand survive.
The VSCode workspace output is minimal and includes folders entries only (no settings, tasks or launch). Use --no-workspace or flutree config set workspace.generate false to skip it.
createrequires a final confirmation in interactive mode.create --yesonly auto-approves together with--non-interactive.create --non-interactivewithout--yesprints the plan, changes nothing and exits4(plan_only), and it also requires--root-repo.create --dry-runprints the same plan and exits0.create --non-interactiverequires--reuse-existing-branchwhen the target branch already exists.completerequires confirmation unless--yesis passed;complete --non-interactivewithout--yesprints the plan and exits4(plan_only).add-repo --non-interactivenever prompts and requires explicit--reposelectors; without--yesit prints the plan and exits4.- Every command that can ask or write (
create,add-repo,remove-repo,link-remote,unlink-remote,sync,push,complete,prune,doctor --fix) takes the same two flags:--non-interactive(never prompt) and--yes(accept the plan).--non-interactivewithout--yesprints the plan (text, or the plan document with--json), changes nothing and exits4.
With --json, commands print machine-readable results on stdout and errors as an envelope on stderr:
{"error": {"category": "input", "code": 2, "message": "...", "hint": "..."}}code equals the process exit code. Create and add-repo results include sdk_setup entries (with restored_files and warnings when a tracked file was touched), post_create_dirty when a new worktree is not clean and local_base_updates when a sync ran.
A remote that cannot be reached while syncing (network, authentication, unknown host, a path that is not a repository) is a git error (exit code 1, message ending in "fetch failed.") that names the repository and the remote and carries git's own output as the hint. It is never confused with "the branch does not exist on origin", which is a normal answer. A repository with no origin remote at all keeps its previous behavior (the sync fails with the base-sync git error).
0: success1: every failure that is not an input error:precondition(for exampleunlink-remoteon an edited block,remove-repoon dirty work,pushof the base branch),git,persistence,unexpected, a failedverify-remoteordoctor2: input error or user-cancelled flow (including unknown commands)3: onlysync, when a repository was skipped (dirty, detached, mid-merge, no base) and nothing else failed4: plan only, nothing done: a command that can write ran with--non-interactiveand without--yes, printed its plan and changed nothing (error envelopecategory: "plan_only",code: 4, the plan indetails.plan). Re-run the same command with--yesto apply it
The process exit code comes from the error category only: input is 2, plan_only is 4, any other category is 1. With --json the error envelope carries the category (for example precondition) and code equals the process exit code; scripts that need to tell a refusal from a failure read category, not the exit code. Only sync exits 3 (its dedicated partial-result path).
Global registry file: ~/Documents/worktrees/.worktrees_registry.json.
Each record stores the workspace name, branch, paths, status and, since v2, an optional base_branch per worktree (the base it was created from). workspace_status and flutree status use it to compute ahead/behind; records created before it was stored simply omit those numbers. Writes are atomic and schema-validated.
The test suite is end-to-end first: it builds the real flutree binary and drives it like a user would.
go test ./... # everything
./scripts/e2e.sh # build the binary and run the e2e suite (integration/)Enable the versioned pre-push hook once per clone; it runs scripts/e2e.sh before every git push and aborts the push when it fails:
git config core.hooksPath .githooksSkip it only in an emergency with git push --no-verify. Manual flow:
go build -o ./flutree ./cmd/flutree
./flutree list
./flutree create demo --scope . --root-repo <repo> --yes --non-interactive
./flutree complete demo --yes --forcecmd/flutree/
internal/
app/
domain/
infra/
runtime/
ui/
integration/
docs/
usage.md
architecture.md
mcp.md
More details:
- docs/usage.md
- docs/architecture.md
- docs/mcp.md
- docs/acceptance.md: which tests cover each acceptance case
- CHANGELOG.md for release history and breaking changes
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change. See CONTRIBUTING.md.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Bubble Tea for interactive UI
- Built on Cobra
- Inspired by the need to manage complex Flutter monorepo workflows
