Flotilla

Docs / Going further

Repo settings

Tell Flotilla how to get each new worktree of a repo ready: what to run, what to copy in, what the editor leaves out, and the tabs and buttons its agents get.

The two files

Each repo can have two settings files in a .flotilla folder at its top:

Both files apply; neither replaces the other. Commands from both run, the shared file's first. Lists from both are combined.

Each file is read from the worktree at hand when it has one, else from the repo's main checkout. So a branch that changes settings.json uses its own version in its worktree, and a settings.local.json in the main checkout covers every worktree.

To start one, open Edit Project in Flotilla, unfold Ready worktrees, sleeping agents, environment, repo settings, and click Create Settings File. Flotilla writes a starter settings.json in each of the project's repos that has none and opens it in the editor.

An example

{
        "$schema": "https://stellorum.com/flotilla/settings.schema.json",
        "worktree": {
          "setup": "npm install",
          "copy": [".env.local", "config/master.key"],
          "cleanup": "./scripts/cleanup-checkout.sh \"$FLOTILLA_CHECKOUT\""
        },
        "editor": { "exclude": ["node_modules", "/build"] },
        "commands": [
          { "name": "Tests", "icon": "checkmark.diamond", "key": "t", "run": "npm test" },
          { "name": "Push", "icon": "arrow.up.circle", "message": "Commit what is done and push it." }
        ]
      }

Every key is optional, and Flotilla ignores keys it does not know.

Keys

worktree.setup

A command to run in each new worktree before an agent works in it: installing dependencies, generating a project, preparing a database.

"setup": "bundle install && bin/rails db:prepare"

If the shared file's setup fails, or you choose not to run it, the local file's setup does not run either. A failure shows in Flotilla's status line, and the agent starts anyway.

worktree.copy

Files and folders to copy from the repo's main checkout into each new worktree. Use it for what git does not track but the code needs, such as secrets and local config.

"copy": [".env.local", "config/master.key", "certs/*.pem"]

worktree.cleanup

A command to run when a worktree or a session goes away, so whatever was made for it can go too: a simulator, a dev server's port, a database, a cache. Flotilla knows nothing of these; the command gets the variables below and decides what to do.

"cleanup": "./scripts/cleanup-checkout.sh \"$FLOTILLA_CHECKOUT\""

editor.exclude

Files and folders that Flotilla's editor leaves out of its file tree, Quick Open and Find in Files. They add to the list in Settings, under Editor.

"exclude": ["node_modules", "/build", "src/generated"]

commands

Tabs and buttons for the pane of every agent working on the repo, so everyone on the team gets them. Each one either runs a command in the agent's checkout or sends the agent a message. They come after the ones you set in Flotilla, in Settings › Commands, for every agent and for the project.

"commands": [
        { "name": "Tests", "icon": "checkmark.diamond", "key": "t", "run": "npm test" },
        { "name": "Lazygit", "kind": "popup", "run": "lazygit" },
        { "name": "Dev server", "kind": "background", "run": "npm run dev" },
        { "name": "Push", "icon": "arrow.up.circle", "message": "Commit what is done and push it." }
      ]

Commands come from the agent's first repo, as its worktree has them. See Your own tabs and buttons for what each kind does.

When commands run

CommandRunsIn
setupWhen Flotilla checks out a worktree: for a new agent, for a ready worktree Flotilla keeps waiting in the pool, or when it recreates a missing one. It runs after the copy and before an agent starts in the worktree. An agent on the repo's main checkout gets no new worktree, so no setup.The new worktree
cleanupWhen a worktree is deleted from disk (a ready worktree trimmed from the pool, or an agent's own worktree removed), and when an agent's session is deleted, even if its worktree is kept for the next agent. It runs in the background, so nothing waits on it.The repo's main checkout

Because ready worktrees are set up ahead of time, a slow setup does not hold up a new agent when Flotilla keeps worktrees ready for the project.

Commands run in bash, with the same environment as your agents: what your shell's startup files set, such as PATH from ~/.zshrc. A command can span several lines.

Variables

Setup and cleanup commands get these environment variables:

VariableHolds
FLOTILLA_EVENTWhat happened: worktree-created for setup; checkout-removed or session-deleted for cleanup.
FLOTILLA_PROJECTThe name of the Flotilla project the repo belongs to.
FLOTILLA_REPOThe path of the repo's main checkout.
FLOTILLA_WORKTREEThe path of the worktree. For checkout-removed it is already gone.
FLOTILLA_CHECKOUTA short, stable name for the worktree, like myapp-3, or the repo's name for its main checkout. Worktrees are reused by later agents, so key anything shared, such as a simulator, port or build folder, by this name.
FLOTILLA_SESSIONThe deleted session's id. Set for session-deleted only.

A cleanup script can branch on the event:

#!/bin/bash
      case "$FLOTILLA_EVENT" in
        checkout-removed) xcrun simctl delete "$FLOTILLA_CHECKOUT" 2>/dev/null ;;
        session-deleted)  rm -rf "/tmp/logs/$FLOTILLA_SESSION" ;;
      esac

Approving committed commands

Anyone who can commit to a repo can change its settings.json, so Flotilla does not run a command from it until you have seen it. The first time, it shows the command's exact text and asks whether to run it. Flotilla remembers your answer for that repo and that text, and asks again whenever the command changes. If you choose Don't Run, it is skipped and Flotilla asks again next time.

The same goes for the tabs and buttons under commands: the first time you press one from the committed file, Flotilla shows what it runs or sends and asks first.

Commands in settings.local.json are your own and run without asking.

Editor help with $schema

Put this line first in either file, and editors such as VS Code and Zed check the file as you type, complete its keys and explain each one on hover:

"$schema": "https://stellorum.com/flotilla/settings.schema.json"

The starter file Flotilla writes already has it.

If git status does not show a new .flotilla/settings.json, a global gitignore may be hiding the .flotilla folder. Add the file with git add -f .flotilla/settings.json.