# The CLI

`fctl` does everything the web app does, for people and for scripts and
agents. Every command takes `--json` for machine-readable output and
`--server <url>` (or `FCTL_SERVER`) to pick an instance; `fctl <command> --help`
has the details.

## Signing in

```sh
fctl login app.fctl.sh       # opens the browser to approve this device
fctl login --no-browser      # prints the link and code instead (SSH, servers)
fctl whoami
fctl logout
```

You approve the device in the browser, signed in there, so two-factor
sign-in happens in the browser too. `fctl login` opens only a link on the
server it signs in to: a server that sends you to approve the sign-in on
another site could be relaying that site's code to get a token there, so
it stops and says which site to sign in to instead.

For scripts, CI and bots, create an access token, limited to what it is
for, and pass it as `FCTL_TOKEN`:

```sh
fctl token "PR reviews" --access run -p my-app --github comment --days 90
FCTL_TOKEN=fctl_pat_… fctl run -p my-app --github comment -d "Review pull request #12"
```

### Access tokens

`fctl token` prints a new token once. Without `--access`, `-p`, `-w` and
`--github` it does everything you can, as you do when signed in; with any,
it is limited, and reaches projects and sessions only: never your account,
your workspaces' people and settings, your Claude connections or your other
tokens.

```sh
fctl token "Dashboard" --access read -w acme   # reads every project of acme, those made later too
fctl token "Nightly" --access run -p my-app    # starts and steers sessions in my-app
fctl token "Admin script" --access full -p my-app   # everything you can do in my-app
fctl token "PR reviews" --access run -p my-app --github comment --days 90
fctl tokens                                    # your tokens and what each does, and where you are signed in
fctl tokens revoke "PR reviews"                # by name or id (tok_…), at once
```

`--access` says what it does: `read` reads projects, sessions, transcripts,
memory and retrospectives and changes nothing; `run` also starts sessions,
messages and interrupts their agents, stops and resumes the sessions it
started, and keeps projects' memory; `full` does all you can in its
projects. `-p` and `-w` (repeat them) keep it to some projects, or to every
project of some workspaces. `--github` is the most the agents of its
sessions may do on GitHub (below), for a token that runs sessions (it makes
one, without `--access`): sessions it starts get that unless they ask for
less, and it can't message or resume a session whose agent started able to
do more. A token that does everything can't take it, since it could change
the settings that steer its projects' agents. Sessions it starts don't notify you; follow the ones you want.
`fctl whoami` with a token says what it does. [Automation](https://fctl.sh/docs/automation.md)
runs review agents from GitHub Actions with one.

A program that starts sessions for a workspace's people, such as a portal
of yours, uses one of its [service accounts](https://fctl.sh/docs/cli.md#service-accounts) as
`FCTL_TOKEN`, and names the person each command acts for with
`--on-behalf-of` (or `FCTL_ON_BEHALF_OF`), by their address or id:

```sh
FCTL_TOKEN=fctl_svc_… fctl run -p my-app --on-behalf-of ada@example.com -d "Fix the login redirect"
```

Configuration lives in `~/.config/fctl/` (`config.toml`, and
`credentials.toml` with mode 0600). `FCTL_CONFIG_DIR` moves it.
`FCTL_SERVER` and `FCTL_TOKEN` take the place of the instance and token
`fctl login` saved there, and `--server` the place of both.

## Sessions

Sessions are named by their id (`ses_…`), their URL, or `project#number`,
which fctl finds however many sessions came after it (where the control
plane is older than the CLI, among the project's latest 200 only).

```sh
fctl run -p my-app "Add a dark mode toggle"   # start one and follow it
fctl run -p my-app -d -f task.md              # start from a file, don't follow
fctl run -p my-app -d --json "…" | jq -r .id  # the new session's id, for scripts
echo "Fix the flaky test" | fctl run -p my-app
fctl run --title "Fix the login loop" "…"     # its title (default: the task's first line)
fctl run --model opus --effort high "…"       # override the project's agent settings
fctl run --github comment "Review pull request #12"   # its agent reviews and comments, and pushes nothing
fctl run --github triage "Triage issue #41"          # its agent labels and comments on tickets, nothing else
fctl run --github read "Plan the move to Postgres"    # its agent only reads on GitHub
fctl run --github-issues "Move the open GitHub issues to Linear"   # its agent reaches GitHub's issues, whatever the tracker
fctl run --branch fix/login --base develop "…"
fctl run -p my-app -a screenshot.png "Make the header match this"   # attach files (repeat -a)

fctl sessions                    # recent sessions (only the default project's, once fctl projects use set one)
fctl sessions --active -p my-app
fctl sessions --since 1h         # at work in the last hour: those that haven't ended, and those that ended in it
fctl pulls                       # the open pull requests agents opened (drafts and merge queues too), each with its sessions: "(asks you)" where its agent waits for an answer, "(archived)" where someone archived it
fctl pulls -p my-app --state merged --mine --json
fctl sessions -w acme --limit 100   # a workspace's (30 unless --limit says)
fctl show my-app#12              # status, who started it (an autopilot, for whom) and from which schedule, its snapshot, branch, pull requests with their checks and review, model and effort, usage
fctl edit my-app#12 --title "Fix the flaky login test"
fctl edit my-app#12 --description "Retries the redirect and tests it."   # "" clears it
fctl edit my-app#12 --effort medium     # its agent works at medium effort from its next step
fctl edit my-app#12 --model sonnet      # …on Sonnet: its next step reads the conversation without the prompt cache
fctl logs my-app#12              # the transcript
fctl logs my-app#12 --last-turn  # only the last message to the agent, and what followed
fctl logs -f my-app#12           # …and keep following
fctl diff my-app#12              # what its branch changed, as git prints it (uncommitted work too)
fctl diff my-app#12 src/auth     # the files in a directory; --repo acme/docs for another repository
fctl diff my-app#12 | git apply  # the same changes, here
fctl search login redirect       # the sessions that say it, and where
fctl search -p my-app "flaky test" --limit 50

fctl attach my-app#12            # stream it and type messages (Ctrl-C detaches)
fctl attach --read-only my-app#12
fctl send my-app#12 "Use the existing Button component"   # a stopped session resumes for it, and it answers what its agent asks (fctl show prints the question)
fctl send my-app#12 -a ci.log "This is what CI printed"
fctl files list my-app#12        # the files sent in it (with messages or its task), oldest first
fctl files get my-app#12 model.3mf      # writes ./model.3mf (the newest of that name, or by id: att_…); --force to write over one there
fctl files get my-app#12 --all --dir in/   # every file, the newest of each name
fctl interrupt my-app#12         # stop the current turn
fctl stop my-app#12              # end the session (its sandbox is kept for resuming)
fctl resume my-app#12 "Now add tests"   # also a failed one, on your Claude subscription
fctl take-over my-app#12         # one that waits for someone else's limit (or rests) continues on your subscription
fctl follow my-app#12            # get its notifications (see Notifications)
fctl unfollow my-app#12
fctl share my-app#12 grace@example.com   # they view it and message its agent (--role viewer, editor or owner)
fctl share my-app#12             # who it is shared with
fctl unshare my-app#12 grace@example.com
fctl archive my-app#12           # out of the lists; its pull requests no longer bring its agent back
fctl unarchive my-app#12
fctl sessions --archived         # the archived ones too
fctl sessions --hidden           # and those of schedules that keep theirs off lists
fctl open my-app#12              # in the browser
fctl open my-app#12 --claude     # in the Claude app (Remote Control)
```

`fctl run` uses the project from `fctl projects use` when `-p` is missing.

`fctl run` follows the session as `fctl attach` does, until you press
Ctrl-C, also once the session has stopped; with `-d` it returns as soon as
the session is created, which is what scripts and agents want. `fctl
attach --read-only` and `fctl logs -f` return at once for a session that
had already stopped or failed when they connected, and otherwise keep
following, after it stops too. Without message text, `fctl run` and `fctl
send` read it from stdin, to its end, when stdin isn't a terminal: where
stdin stays open, they wait. [fctl for agents](https://fctl.sh/docs/agents.md) has the rest of
what matters when a program drives fctl, and how to wait for a session's
turn to end.

When the control plane fails in a way that may pass (an error on its
side, a lost connection, a timeout), commands that name a session look it
up again, and `fctl send` sends its message again: up to three more
times, after 1, 3 and 9 seconds, but none that would start more than a
minute after the first try. Over HTTP a request times out after 30
seconds, so a control plane that doesn't answer gets one more try. Each
message carries a `client_id` of its own, so a try whose answer was lost
doesn't deliver it twice. When `fctl send` gives up, its error says
whether the message wasn't sent (fctl refused it) or may have reached the
session all the same, with the key its tries went with: run the same
command again with `--key <that key>`, and the session gets the message
only if it didn't yet. A script that may send the same message twice can
give its own key from the start (`fctl send my-app#12 --key deploy-1234
"…"`): for a day, a message sent again with the same key reaches the
session at most once. The key goes with the message's text and its files,
so another message with the same key, or the same one with a file that
changed, is a message of its own.

`fctl search` looks in the titles and descriptions of the sessions you can
see, in every workspace unless `-w` or `-p` says which, and in what people
wrote to their agents and the agents replied; not in tool calls or what
they returned. It finds the words as you type them, whatever the case, the
accents and the spaces between them, and lists the sessions that have them
in their title first, then those that said them most recently, each with
up to three snippets of where (`--json` for scripts). A session is
searchable a few seconds after its messages come; ones from before search
existed, once the control plane's hourly job got to them.

A session's agent pushes, comments, triages or only reads on GitHub
(`--github`): one that pushes commits and pushes its branch, as agents
always did; one that comments reviews, comments and labels, with a token
that can't push; one that triages labels the project's tickets and
comments on them with `fctl ticket`, whatever they say, and writes
nothing else, with a token that only reads; one that reads writes
nothing. It gets as much as its project's settings and the token that
starts it allow unless it asks for less, and `fctl show` says what it
got. GitHub lets only tokens that can push resolve
review threads, so an agent that comments resolves them through fctl, in
its sandbox:

```sh
fctl resolve PRRT_kwDOABCD1234         # in a session's sandbox: resolve a review thread
fctl resolve --unresolve PRRT_kwDOABCD1234
```

`fctl attach` also says when the session's runner goes away or can't reach
the agent in its sandbox, and when it is back.

A session's project's people see it already; `fctl share` shares it with
someone else in its workspace, by the address they are in it as, and
`--role` says what they may do: `viewer` reads it, `editor` (the default)
also messages and interrupts its agent, and `owner` also stops, resumes,
archives and shares it. Only who started it, or an admin of its
workspace, shares ownership. Whoever can message a session's agent can
have it hand over what its sandbox holds: the project's secrets, its
GitHub tokens and the Claude token it runs on. `fctl archive` puts a
session away: lists leave it out (`fctl sessions --archived` keeps it in),
and nothing that happens to its pull requests reaches its agent any more,
though messages still do. Sharing and archiving are for the session's
owners.

A session's title starts as the first line of its task. Agents rename it to
what they work on, and say what the session is about, with the same
command: in a sandbox, `fctl edit --title … --description …` without a
session edits the one the sandbox runs, through fctl-agent and without a
sign-in. The sandbox's `~/AGENTS.md` asks them to do it once they
understand the task, and again when the work turns to something else.

`--attach` (`-a`) sends files with the task or message (`run`, `send`,
`resume`): up to 10, of at most 20 MB each. The agent finds them in
`~/attachments/` in its sandbox, and sees images that Claude accepts as
they are (PNG, JPEG, GIF, WebP up to 2000 px a side) in the message itself.
`fctl files` lists and downloads the files sent in a session, for anyone
who sees it. It writes no file over one already there unless you pass
`--force`: their names are those of whoever sent them.

### Screenshots in pull requests

GitHub takes uploads only from people, so in a sandbox `gh pr edit
--attach` fails with "unsupported authentication type": sessions have the
GitHub App's token. In projects that publish screenshots, agents publish
them on fctl instead and put the Markdown it prints in the pull request:

```sh
fctl publish before.png after.png     # in a sandbox: a link and Markdown for each
fctl publish --json after.png         # the links, sizes, expiry and Markdown
fctl unpublish https://app.fctl.sh/api/v1/published/…/after.png   # delete one sooner
```

Anyone who has a link can open it, until it expires: after 30 days, or
what the project chooses between 24 hours and 60 days. A link holds 256
random bits. Publishing is off until the instance's admins allow it (`fctl
admin set --publish-screenshots on`) and a project's maintainers turn it
on (`fctl projects set --publish-screenshots on`); turning either off
takes the screenshots offline. It takes PNG, JPEG, GIF and WebP images of
at most 5 MB, up to 100 per session. The transcript shows each one, and
people who manage the session can delete it there or with `fctl
unpublish`.

### Identity tokens

An agent proves to your own services and clouds that a request comes from
its session with an identity token: an OpenID Connect (OIDC) ID token that
your workspace's issuer signs, which says whom the session runs for and its
project, workspace and runner, for one audience, for 10 minutes. In a
session's sandbox:

```sh
fctl id-token -a https://api.acme.dev            # the token, to send as a bearer token
fctl id-token -a https://api.acme.dev --claims   # what it says, without it
fctl id-token -a https://api.acme.dev --json     # the token, when it expires and its claims
fctl id-token -a api://AzureADTokenExchange --subject project   # sub: project:prj_… alone
fctl id-token -a sts.amazonaws.com --aws-session-tags            # with AWS session tags
```

`--subject` chooses the parts of its subject (`workspace`, `project`,
`user`, `session`, `runner`, `github_access`; the project and the person
without it), and `--nonce` a value it repeats. Projects mint them unless
their maintainers turn them off (`fctl projects set --id-tokens off`), and
review agents never do. A project that reaches AWS, Google Cloud or Azure
(`--aws-role`, `--gcp-provider`, `--azure-client`) needs no `fctl
id-token` for them: fctl-agent keeps their tokens fresh in the sandbox,
and their CLIs and SDKs sign in on their own. `fctl projects identity`
prints what each cloud needs to trust the project's agents. How services
check tokens, and every claim: [Identity tokens](https://fctl.sh/docs/identity-tokens.md).

### Slack

A session that started in Slack, or whose workspace makes channels
readable, reaches Slack through fctl-agent, as `fctl ticket` reaches a
tracker: the agent holds no Slack token, and fctl keeps each call to what
the session may read ([Start agents from Slack](https://github.com/hyperstructure/fctl/blob/main/docs/slack.md#what-agents-read-and-never-read)).
In a session's sandbox:

```sh
fctl slack                                  # what this session reaches in Slack: its thread, the readable channels
fctl slack thread                           # what's new in the thread it started from since it last read it
fctl slack thread --all                     # every message of it
fctl slack read https://acme.slack.com/archives/C0123ABC/p1700000000000100   # a message and its thread (Copy link in Slack)
fctl slack history deploys --since 2d       # a readable channel's messages, oldest first (--limit, 50 by default, at most 200)
fctl slack search checkout 500 --channel incidents   # messages of the readable channels with all these words, newest first (--limit up to 50)
fctl slack reply "The deploy log is at https://…"    # posts in the session's own thread now, as fctl (or --file, or stdin)
```

Each message says who wrote it and when, and whether fctl passed it on to
the agent as its author's message; everything else there is information
from the people who wrote it. `fctl slack reply` posts in the session's
own thread alone, at most 3,000 characters, where the workspace lets
agents post; the turn's last message goes there by itself. In an hour, a
session's agent reads Slack at most 120 times, searches it at most 30
times and posts at most 20 times. Name channels without their `#`, or
quote them: the shell takes `#` at the start of a word for a comment.

## Workspaces

Projects, the runners that run their sessions and the GitHub accounts they
work in belong to workspaces. `fctl workspaces` (or `fctl workspace`) lists
yours and the invitations waiting for you; the commands below take the
workspace with `-w`, else the one from `fctl workspaces use`, else your only
one.

```sh
fctl workspaces                            # yours, and the invitations waiting for you
fctl workspaces create "Side project" --color pink
fctl workspaces create Acme --as ada.lovelace@acme.example   # join it as another of your addresses
fctl workspaces show -w side-project
fctl workspaces use side-project           # the default for the commands below
fctl workspaces order side-project acme    # yours in this order, in lists and the app's sidebar
fctl workspaces join side-project          # an invitation (or decline it)
fctl workspaces leave side-project         # your sessions there stop
fctl workspaces claude crd_01… -w acme     # your sessions there run on this Claude connection
fctl workspaces claude ada@acme.example -w acme   # …named by its account or label
fctl workspaces claude on-runners -w acme  # …on the token you keep on your runners
fctl workspaces claude default -w acme     # …or on your default one
fctl workspaces own-runners on -w acme     # your sessions there run only on runners you registered
fctl workspaces own-runners off -w acme    # …or on any of its runners for everyone's sessions too

fctl workspaces members                    # its people, and the invitations nobody answered
fctl workspaces members --claude           # admins: each member's Claude connection, plan, last answer and when it runs out
fctl workspaces members --claude --problems   # …only those whose sessions can't run, or whose token runs out within 30 days
fctl workspaces members --claude --expiring 7d --json   # …only tokens that run out within a week, as JSON
fctl workspaces invite grace@example.com --admin
fctl workspaces uninvite grace@example.com
fctl workspaces role grace@example.com member
fctl workspaces remove grace@example.com   # their sessions there stop
fctl workspaces transfer grace@example.com # the primary admin hands the role to an admin

fctl workspaces set --name "Side project" --avatar logo.png   # or --avatar none
fctl workspaces set --color '#2a9d8f'     # its avatar's color, of its own (quoted: the shell takes # for a comment), or yellow, pink, blue or ink
fctl workspaces set --slug side            # its address in URLs (create takes --slug too); old links stop working
fctl workspaces set --base-role editor     # every member starts sessions in every project
fctl workspaces set --require-two-factor on   # closed to members without a second factor
fctl workspaces set --require-google acme.com,acme.dev   # members there open it only signed in with Google as such an address (--google-passkeys: a passkey too; off to stop)
fctl workspaces set --skip-invites on      # a workspace for one: its setup stops asking for people
fctl workspaces set --snapshot-days 7      # keep each session's snapshot a week after it stops (30 by default)
fctl workspaces set --snapshots off        # sessions keep no snapshots: one that resumes elsewhere starts its conversation again
fctl workspaces set --claude-oversight readiness   # its admins see only whether members' sessions can run (details by default, off for nothing)
fctl workspaces set --claude-limit-pauses off      # …and not how often members' sessions paused on usage limits
fctl workspaces set --claude-admin-email each      # its admins get an email for each token that runs out or stops working (weekly by default, or off)
fctl workspaces snapshots                  # what its sessions' snapshots take now, with fctl and in each of its runners' buckets

fctl workspaces runners                    # the runners its sessions start on, with their ids
fctl workspaces add-runner studio-mac      # one of yours runs its sessions too (its name or id)
fctl workspaces add-runner                 # on a runner: this machine
fctl workspaces add-runner studio-mac --personal   # only your sessions there (a member's always)
fctl workspaces remove-runner studio-mac   # the ones running there stop and resume elsewhere

fctl workspaces github                     # the GitHub accounts it works in
fctl workspaces review-app                 # which app review agents post as on each, with links that install the review app (admins)
fctl workspaces connect                    # opens a GitHub sign-in; you choose what it works in under its Integrations → GitHub
fctl workspaces connect acme               # the same, for acme only
fctl workspaces connect acme --repo web --repo design   # only these repositories of it, without the choice
fctl workspaces connect --no-browser       # print the link to open where you are signed in (linear connect takes it too)
fctl workspaces disconnect acme

fctl workspaces linear                     # the Linear workspaces it works in, and which of your projects take their tickets
fctl workspaces linear connect             # opens Linear, where one of its admins installs fctl's app
fctl workspaces linear teams               # the teams fctl's app reaches there, for projects to choose (its admins and projects' maintainers)
fctl workspaces linear disconnect acme     # its projects take no more tickets from it

fctl workspaces slack                      # the Slack workspaces it works in: what agents read there, its choices, its channels
fctl workspaces slack connect              # opens Slack, where someone who may add apps there installs fctl's app (admins)
fctl workspaces slack set --direct-messages off --transcripts drop   # what people and agents may do there (admins)
fctl workspaces slack channels deploy      # its public channels whose names have these letters (admins)
fctl workspaces slack map web-team web     # mentions in #web-team start sessions in web (none: no project of its own)
fctl workspaces slack readable incidents deploys   # agents of projects that read Slack read these; fctl's app joins them (--off)
fctl workspaces slack disconnect acme      # nothing there reaches its sessions any more

fctl workspaces audit                      # what happened in it (admins)
fctl workspaces delete side-project        # with its projects and sessions; asks you to type its name
fctl workspaces delete side-project --confirm "Side project"   # …or takes it, without a terminal
```

Admins invite people by an address they sign in with, or one the allowlist
admits (they join when they sign up); any other address needs an instance
invitation first (`fctl admin invite`).
Everyone in a workspace works in its projects as their project role or its
base role says; its admins own every project. One person can be in at most
five workspaces, or as many as the instance's admins choose (`fctl admin
set --max-workspaces`), and the primary instance owner in any number
(`fctl workspaces --json` says the instance's `"limit"`, 0 for any number,
and `"unlimited": true` to whoever it doesn't hold). While the instance
requires two-factor sign-in (`fctl admin set --require-two-factor on`),
every workspace does, and `fctl workspaces set --require-two-factor off`
fails. `--require-google` holds the members who are in the workspace as
an address at its domains to Google sign-ins as such an address; save it
once you've signed in with Google as yours, as it would close the
workspace to you otherwise ([A workspace of your
organization's](https://fctl.sh/docs/organizations.md#a-workspace-of-your-organizations)).

`fctl workspaces members --claude` shows a workspace's admins what each
member's sessions there run on, as much of it as they see, never a token,
its account or the label its person gave it:

```
$ fctl workspaces members -w acme --claude
NAME          CLAUDE                     PLAN  ANSWERED  RUNS OUT       LIMIT PAUSES (7D)
Ada Lovelace  login                      Max   5m ago    -              0
Grace Hopper  token, set by admin token  Team  2h ago    ~Dec 14 (21d)  6
Linus Lee     none                       -     -         -              -
1 person has no Claude connection for Acme: their sessions here can't start.
1 person's token runs out within 30 days: their sessions here stop then, unless they connect a new one before.
They connect a new one in Settings → Claude: fctl tells them too.
1 person's sessions paused on usage limits 5 times or more this week: their plan's limits are short for this work, and a Max or Ultra seat has more.
```

`~` marks a date fctl counted from when the token was connected, as
nobody said when `claude setup-token` made it. With `--claude-oversight
readiness`, the table shows only whether each member's sessions can run,
when their token runs out and whether they wait for a usage limit to
reset; with `off`, nothing. The instance's admins choose the most any
workspace's admins see (`fctl admin set --claude-oversight`), and members
read what theirs see in `fctl workspaces show`.

`fctl workspaces slack` shows each Slack workspace the workspace works in:
whether fctl's app may still act there, what agents read, what it lets
people and agents do (`set`: `--channels`, `--direct-messages`,
`--search`, `--agent-replies`, `--notifications`, `--project-events`,
`--match-email`, each `on` or `off`, `--transcripts keep` or `drop`, and
how agents write what they post there, `--instructions` or
`--instructions-file`: `default` for fctl's guidance, `""` for none),
its mapped and readable channels, and how many members linked their
Slack account; `--team` names one where it works in several. `fctl
workspaces slack instructions` prints what agents are told about writing
there, to start your own from:

```sh
fctl workspaces slack instructions > slack.md
fctl workspaces slack set --instructions-file slack.md
fctl workspaces slack set --instructions default   # fctl's guidance again
```

Only public
channels are listed, mapped and made readable from here: a private
channel's members invite fctl's app, and an admin who mentions it there
can remember the project they choose for the channel
([Start agents from Slack](https://github.com/hyperstructure/fctl/blob/main/docs/slack.md#settings)).

A runner its admins add runs everyone's sessions there; one a member adds,
and one an admin adds with `--personal`, runs only its owner's. With
`own-runners on`, your sessions in the workspace run only on runners you
registered, not on its other people's, which see a session's code, secrets
and Claude token; turning it on stops the ones running elsewhere, and they
resume on yours.

## Projects

```sh
fctl projects list                     # all your workspaces' projects
fctl projects list -w side-project
fctl projects show my-app
fctl projects create "My app" --repo my-org/my-app -w acme   # a workspace's admins create its projects
fctl projects create "Docs" --repo my-org/docs --slug handbook --description "The handbook"   # its URL name, and a sentence for people
fctl projects create "New thing" --new-repo new-thing --owner my-org --public
fctl projects create "Site" --repo my-org/site --connectors   # claude.ai connectors in its sessions (off by default)
fctl projects set -p my-app --name "Web app" --description "The storefront"   # how people find it; its slug stays (--description "" clears it)
fctl projects set -p my-app --icon store --icon-color yellow --icon-style duotone   # its icon in the sidebar and on its page: an IconMCP glyph (--icon "" for the one that fits its name)
fctl projects set -p my-app --icon-color '#2a9d8f'   # a color of its own (quoted: the shell takes # for a comment), made lighter or darker where a theme needs it to read
fctl projects set -p my-app --default-branch develop   # sessions start from develop unless they ask for another (fctl run --base); the repository must have it
fctl projects set -p my-app --model opus --effort high   # its agents' model and effort ("default" for Claude's own)
fctl projects set -p my-app --compact-window 400k   # Claude compacts as its context nears 400K tokens, 100k to 1m ("default": near the model's whole window)
fctl projects set -p my-app --instructions-file agents.md   # what its agents are told in every session (--instructions "" for nothing)
fctl projects set -p my-app --auto-pull-request off   # agents open pull requests when someone asks, not when they finish
fctl projects set -p my-app --remote-control off  # its sessions stay out of the Claude apps
fctl projects set -p my-app --connectors on       # agents use the claude.ai connectors of whoever starts a session
fctl projects set -p my-app --credit-claude off   # no Claude trailer in its commits
fctl projects set -p my-app --credit-people off   # no trailers for the people who start sessions
fctl projects set -p my-app --idle-timeout 30     # idle sessions keep their sandbox 30 minutes (default 10)
fctl projects set -p my-app --publish-screenshots on --screenshot-days 7   # links work for a week
fctl projects set -p my-app --image ghcr.io/acme/agent:1   # sessions start from this image ("" for the runner's)
fctl projects set -p my-app --build .devcontainer/devcontainer.json   # or one built from the repository
fctl projects set -p my-app --build Dockerfile --build-context app    # a Dockerfile, built in app/
fctl projects set -p my-app --setup-script 'npm ci'   # or @setup.sh, or - to read it from stdin
fctl projects set -p my-app --package-caches on    # sessions on a runner share their downloads
fctl projects set -p my-app --env NODE_ENV=test --unset-env DEBUG
fctl projects set -p my-app --cpus 8 --memory 16g     # "default" for the runner's
fctl projects set -p my-app --project-memory off --retrospectives off   # agents keep neither
fctl projects set -p my-app --stale-note-days 7   # fctl deletes notes a week after they go stale (never: kept)
fctl projects set -p my-app --github comment      # its agents review and comment at most, and push nothing
fctl projects set -p my-app --github triage       # its agents label tickets and comment on them at most
fctl projects set -p my-app --pr-descriptions brief   # pull requests described in a few sentences (balanced by default, or full)
fctl projects show my-app --pr-instructions > prs.md   # what agents are told about pull requests and issues: fctl's rules unless the project has its own
fctl projects set -p my-app --pr-instructions-file prs.md   # the project's own instead (--pr-instructions default for fctl's, "" for none)
fctl projects set -p my-app --follow-ups comments,checks,conflicts   # agents come back for @fctl comments, failed checks and conflicts
fctl projects set -p my-app --tickets linear --linear-team ENG,DES   # its tickets are these Linear teams'
fctl projects set -p my-app --aws-role arn:aws:iam::123456789012:role/fctl-web --aws-region eu-north-1   # its agents assume this AWS role ("" for none)
fctl projects set -p my-app --gcp-provider projects/123456789/locations/global/workloadIdentityPools/fctl/providers/acme --gcp-service-account agents@acme.iam.gserviceaccount.com
fctl projects set -p my-app --azure-tenant 72f988bf-… --azure-client 6d1c1d3b-…   # an Entra application (--azure-client "" for none)
fctl projects set -p my-app --id-tokens off       # its agents mint no identity tokens, and reach no cloud
fctl projects identity -p my-app       # the issuer, the subject, and what each cloud needs to trust its agents
fctl projects use my-app
fctl projects order my-app site        # these first in their workspace, the others after them
fctl projects delete my-app            # with its sessions; asks you to type the slug
fctl projects delete my-app --confirm my-app   # …or takes it, without a terminal
```

`--env` sets variables that aren't secret: the project's people see them in
its settings and `fctl projects show`. Credentials go in its secrets, which
sessions get as environment variables too, and whose values nobody reads
back: `fctl projects secrets set` asks for the value without showing what
you type, or reads it from stdin, never from an argument, which shell
history would keep. Anything an agent runs can read both variables and
secrets.

```sh
fctl projects secrets -p my-app                  # their names, and who set each when
fctl projects secrets set STRIPE_KEY -p my-app   # asks for the value
printenv STRIPE_KEY | fctl projects secrets set STRIPE_KEY -p my-app
fctl projects secrets set DEPLOY_KEY -p my-app < deploy_key.pem
fctl projects secrets remove STRIPE_KEY -p my-app

fctl projects members -p my-app                  # its members and their roles
fctl projects members add grace@example.com -p my-app   # an editor (--role viewer, editor, maintainer or owner)
fctl projects members role grace@example.com maintainer -p my-app
fctl projects members remove grace@example.com -p my-app   # your own address leaves it
```

Maintainers set its settings and secrets and manage its members; only
owners make someone an owner or change an owner's role, and a project keeps
at least one owner. Its members are people of its workspace, added by the
address they are in it as, and besides them the workspace's admins own the
project and every member of the workspace has the workspace's base role in
it ([Workspaces](https://fctl.sh/docs/cli.md#workspaces)).

Agents start in the project's repository and can use more of the same GitHub
account. They clone them when they need them, into `~/repos/<owner>/<name>`;
in each one they change, they work on the session's branch, which fctl
pushes after every turn until its pull request is merged, and open a pull
request.

```sh
fctl projects repos list -p my-app
fctl projects repos add my-org/my-lib --write -p my-app   # agents may push and open pull requests
fctl projects repos add my-org/design -p my-app           # read only, like a private dependency
fctl projects repos add 'my-org/*' -p my-app              # read every repository the GitHub App reaches
fctl projects repos remove my-org/design -p my-app
```

Changes apply to sessions that start afterwards.

Follow-ups bring agents back to the pull requests they opened, in a
message from fctl that resumes the session on the Claude subscription it
ran on (`--follow-ups`, a list of `comments`, `checks`, `conflicts` and
`closed`, or `all` or `none`): a comment that mentions `@fctl` or
`@agent`, or starts with `fctl:` or `agent:`, from someone who can write
to the repository; a failed check of the newest commit, at most three
times in a row while nobody messages the agent; conflicts with the base
branch, which the agent resolves by merging the base branch in, as often;
a merge or a close, unless the agent made it itself as it worked. New
projects start with all four on;
`fctl projects show` says which
([Architecture](https://fctl.sh/docs/architecture.md#follow-ups)).

A project's image and its build run only on runners whose owners allow
them ([Sandbox images](https://fctl.sh/docs/sandbox-images.md#which-images-a-host-runs)); a
session that no runner allows stays queued and says why. `fctl projects
show` says where the project's sessions start from, their size, setup
script and variables.

With `--package-caches on`, the project's sessions on each runner share
what npm, pnpm, Yarn, Bun, Cargo, uv, pip and Go download, and
Playwright's browsers in images that come without them (the default image
comes with its own), so a setup script like `npm ci` or `cargo fetch` gets
only what is new. The runner keeps them for the project up to its owner's
limit, 10 GiB unless `host.toml` says otherwise, empties them past it, and
removes them two weeks after a session last used them ([Hosts](https://fctl.sh/docs/cli.md#hosts)).
Sessions get them on runners with the Docker, Apple container or
Firecracker driver (and the process driver), not Lima, and review agents
never do. A session in a sandbox made before the project turned them on
gets them in its next sandbox, but with Firecracker, whose VMs mount them
as they boot.

### Ticket trackers

A project's ticket tracker is where its agents read and write tickets,
and what they are told to use: GitHub Issues, Linear teams, or none.
Projects that never chose one have GitHub Issues of the repositories
their agents write to, as agents always worked:

```sh
fctl projects tickets -p my-app                # its tracker, how agents reach it, and what its tickets started lately
fctl projects set -p my-app --tickets github   # the issues of every repository its agents write to
fctl projects set -p my-app --tickets github --tickets-repo my-org/my-app   # one of them only
fctl projects set -p my-app --tickets none     # no tracker at all, GitHub's issues included
fctl workspaces linear teams                   # the Linear teams fctl's app reaches (maintainers and the workspace's admins)
fctl projects set -p my-app --tickets linear --linear-team ENG
fctl projects set -p my-app --linear-team ENG,DES   # two teams' tickets; agents file new ones in the first
fctl projects set -p my-app --linear-project "Mobile app"   # only that Linear project's issues of the team that has it ("all": every team's)
fctl projects set -p my-app --linear-project DES:Website --linear-project ENG:all   # each team's, by its key
fctl projects set -p my-app --linear-start off # tickets stay in their state as their sessions start
fctl projects set -p my-app --linear-review off --linear-done off   # leave In Review and Done to Linear's GitHub integration
fctl projects set -p my-app --explore-label plan   # the label that asks for a plan first ("" for none)
```

With the issues of every repository they write to, agents use `gh`, as
before. With one repository's, or Linear teams', they use `fctl ticket`,
which fctl answers for them: it holds the tracker's access and refuses
tickets outside the project's choice as tickets that don't exist.
With none, their GitHub tokens carry no issues permission and they are
told to leave every tracker alone; a public repository's issues stay
readable to anyone, though. A token covers all its repositories with one
set of permissions, so with one repository among several the session's
tokens get no issues permission either. A change reaches running
sessions' GitHub tokens with their next one, within the hour, and what
agents are told from their next session on.

A maintainer of the project can start a session that reaches GitHub's
issues whatever the tracker says, to move them into Linear, say: `fctl
run --github-issues`, or **GitHub issues too** in the start form's GitHub
menu. Its tokens carry the issues permission on the repositories it
writes to, as with GitHub Issues of all of them, for as long as it runs,
and its agent is told to use those issues only as its task asks. It
reaches the project's tracker as other sessions do.

Linear teams take a Linear workspace the project's workspace works in
([Workspaces](https://fctl.sh/docs/cli.md#workspaces): `fctl workspaces linear connect`). A project
takes the tickets of one team or several there (at most 20), each of all
its issues or of one of its Linear projects; agents file new tickets in
the first, or in another with `fctl ticket create --in DES`. There,
people assign an issue to fctl, which makes fctl its delegate, or mention
fctl in a comment, and fctl starts a session of the project that takes
the issue's team, on the subscription of whoever asked, once they have
linked their Linear account ([Your account](https://fctl.sh/docs/cli.md#your-account)) and only
while they may start sessions in the project. The session's branch
carries the ticket's key (`fctl/12-eng-123-fix-the-login-loop`) for
Linear's GitHub integration to link the pull request, and fctl posts the
agent's steps, its pull requests and each turn's last message to the
ticket's agent session in Linear. fctl moves the ticket through its
team's workflow, never back: to In Progress as a delegated ticket's
session starts, or once a mention's agent changes something; to In
Review when a turn ends with the session's pull request up; and to Done
once its pull requests merged, one that completes the ticket (`Fixes
ENG-123`, not `Part of ENG-123`) among them. `--linear-start`,
`--linear-review` and `--linear-done` turn each move off or on again, and
`fctl workspaces linear teams` names the states each team's tickets move
to. Replies there reach the agent as their writers'
messages, and stopping the agent session there interrupts it. An issue
with the explore label (`explore` unless a project names another) gets a
plan, and no changes until someone asks for them
([Architecture](https://fctl.sh/docs/architecture.md#linear)).

In a session's sandbox, `fctl ticket` is the agent's, through fctl-agent
and without a sign-in, as for `fctl edit`:

```sh
fctl ticket                                # the tracker, and the ticket this session works on
fctl ticket list --search login --label Bug   # open ones, most recently changed first (--closed, --all, --limit up to 50)
fctl ticket view ENG-123                   # its description, parent, sub-tickets and comments
fctl ticket create --title "Add a test for retries" --parent ENG-123 --description-file notes.md
fctl ticket create --title "…" --label Tests --state Todo --priority High   # state and priority: Linear
fctl ticket create --title "…" --in my-org/api   # which repository, for the GitHub issues of several
fctl ticket create --title "…" --in DES      # which team, for Linear teams of several (else the first, or a sub-ticket's parent's)
fctl ticket comment ENG-123 "The fix needs a migration first: should it run in the deploy?"
fctl ticket comment ENG-123 --reply-to 2f6c… --file answer.md   # answer a comment, where trackers thread them
fctl ticket update ENG-123 --state "In Review" --add-label Bug
fctl ticket update ENG-123 --remove-label Triage --parent none --priority Low
fctl ticket states                         # the states tickets can be in, in order (of several teams: each name once)
fctl ticket labels
```

In an hour, a session's agent comments at most 30 times, files at most 20
tickets, changes at most 60 and reads its tracker at most 300 times, and
after 60 writes that failed it writes nothing more until the hour is up.
Review agents reach no tracker.

### Memory and retrospectives

A project keeps a memory: notes its agents, and its people, write for the
agents of its later sessions, about what the repository doesn't say. Each
session's agent starts with the current notes, adds what a future agent
should know and marks the notes that turned out wrong stale; everyone in
the project reads them, and editors change and delete them:

```sh
fctl memory -p my-app                  # the current notes, newest first, with where each came from
fctl memory -p my-app --stale          # the stale ones too
fctl memory show mem_01JC3V…
fctl memory add -p my-app "Deploys happen on Fridays: merge migrations by Wednesday."
fctl memory add -p my-app "Deploys happen on Thursdays." --replaces mem_01JC3V…   # the old one goes stale
fctl memory add -p my-app "…what both say…" --replaces mem_01JC3V…,mem_01JC2Q…     # in place of both
fctl memory edit mem_01JC3V… "Deploys happen on Thursdays."
fctl memory stale mem_01JC3V… --reason "We deploy every day now"   # agents no longer start with it
fctl memory duplicate mem_01JC3V… --of mem_01JC2Q…   # stale, linked to the note it repeats
fctl memory restore mem_01JC3V…        # current again
fctl memory rm mem_01JC3V…             # for good
fctl memory rm --stale -p my-app       # every stale note at once, for good
```

As agents finish a piece of work, they record a retrospective of it: how
it ended, what they worked on, the approach they took, what got in the way
and what a future agent should know. One for each piece of work, not for
each turn: when a later turn carries on with it, the agent updates the one
it recorded. Session pages show them (in the transcript, a line for each
part that opens to all of it, an update marking what it changed), and the
project's Memory tab lists them all, under Retrospectives:

```sh
fctl retro list -p my-app              # newest first, with how many ended each way
fctl retro list -p my-app --outcome blocked --limit 50   # 20 unless --limit says
fctl retro list my-app#12              # one session's
fctl retro rm rtr_01JC3W…              # people who manage the session
```

In a session's sandbox, the same commands without `-p` are the agent's,
through fctl-agent and without a sign-in, as for `fctl edit`. `~/AGENTS.md`
lists the project's notes and says how to keep them, and when to record a
retrospective and when to update one:

```sh
fctl memory                            # the notes as they are now, other sessions' new ones too
fctl memory add "The e2e tests need Chromium: run npx playwright install chromium first."
fctl memory add "Run cargo xtask check before pushing." --replaces mem_01JC3V…   # the old one goes stale
fctl memory stale mem_01JC3V… --reason "The script moved to xtask"
fctl memory duplicate mem_01JC3V… --of mem_01JC2Q…   # it repeats a current note
fctl retro --outcome completed --worked-on "Retried failed uploads (#41)." \
  --approach "Used the existing backoff helper." --challenges "The tests need MinIO." \
  --insights "Start MinIO with docker compose up minio before the tests."
fctl retro list                        # this session's, with their ids
fctl retro update rtr_01JC3W… --outcome completed \
  --challenges "The tests need MinIO, which CI lacked until #42."   # the parts left out stay
```

Agents can't change or delete notes, only mark them stale with a reason,
or as duplicates of current notes. They update only their own session's
retrospectives, and delete none. A note replaces at most 20 others.
Both are on in new projects and projects from before them; `fctl projects
set --project-memory off` and `--retrospectives off` turn them off, and the
notes and retrospectives stay for people to read. A project keeps at most
1,000 notes of 2,000 characters, stale ones included, and a session at most
50 retrospectives. `fctl projects set --stale-note-days 7` has fctl delete
notes once they have been stale a week (1 to 365 days; `never`, as new
projects start, keeps them until someone deletes them), within the hour,
and the workspace's audit log says how many went. Once the memory holds
900, a project's [autopilot](https://fctl.sh/docs/cli.md#autopilots) hears so in its brief, and
deletes the notes stale for over a day itself (`fctl memory delete
--stale`), without asking: people have that day to make a note marked
stale by mistake current again.

### Review agents

Where a project's review agents are on, each new commit of a pull request
in the repositories its agents may write to gets a review: an agent reads
it, on the Claude subscription of the owner who turned them on, and fctl
posts what it found on the pull request, with a check on the commit.
The owners skip repositories that another project's review agents review
already, so that their pull requests get one review: a skipped
repository's pull requests get none in the project, not even when someone
asks, and repositories linked later are reviewed until the owners skip
them.
A pull request from someone who can't write to the repository gets one
only when someone asks for it (`fctl review start`), since what it says
reaches an agent with the owner's Claude token. So does an app's, unless
it is one of the GitHub Apps the project's owners chose, Dependabot until
they choose: their pull requests from the repository's branches get one
by themselves, from an agent that installs and runs nothing of them.
When an fctl agent opened the pull request, its session gets the findings
in a message from fctl, with the earlier reviews' findings still open
(those alone when a review finds nothing new, unless the agent heard of
each as it stands), decides what to do about
them and answers in their threads: those of up to five reviews in a row
while nobody messages the agent, or as many as the project's owners
chose, from one to ten
(`--rounds`). fctl holds the next ones back, and the session's page says
so under the pull request, with a button that continues for as many
rounds again: the agent gets the held findings, then those of the reviews
after them, up to that many in a row with these. A message to the agent
ends the pause too. Findings
that went to no session, since none listed the pull request yet when the
review posted, wait for one: the session that opened it gets them once it
lists it, and `fctl review` says so meanwhile. Where the
owners turn it on, the review agent first sums the pull request up at the
end of its description (how risky it looks, what it does and what
deserves a closer look), in place of an earlier review's summary, and
fctl leaves the rest of the description as it is. The project's owners
turn them on (on their own subscription), take them over and say how
they review, which runs them on the subscription of whoever changes
them; the person they run for may turn them off:

```sh
fctl review settings -p my-app                 # on or off, on whose subscription, how
fctl review settings -p my-app --on --model opus --effort high
fctl review settings -p my-app --instructions-file review.md   # what they're told besides fctl's own
fctl review settings -p my-app --bots dependabot,renovate      # the apps whose pull requests start reviews (or none)
fctl review settings -p my-app --skip-repos acme/shared-lib    # repositories whose pull requests get no review here (or none)
fctl review settings -p my-app --drafts off                    # drafts wait until they're marked ready for review
fctl review settings -p my-app --description-summary on        # sum each pull request up in its description first
fctl review settings -p my-app --rounds 3                      # findings of 3 reviews in a row reach the agent, then fctl pauses (1 to 10, 5 by default)
fctl review bots -p my-app                     # the apps that opened the newest pull requests, and which start reviews
fctl review bots -p my-app my-app-bot          # an app as GitHub shows it: its name and who makes it
fctl review settings -p my-app --mine          # run them on your subscription from now on
fctl review settings -p my-app --model default # the project's model again
fctl review settings -p my-app --off           # reviews under way finish
fctl review -p my-app                          # the reviews, newest first, with what came of each
fctl review start -p my-app 12                 # review a pull request's head now (or acme/api#7, or its link)
fctl review list -p my-app --limit 50          # more of them (20 unless --limit says)
fctl review pass-on my-app#12                  # pass on the findings fctl held back from a session's agent, or sent to no session
```

Review sessions take no messages: `fctl show my-app#12` says which pull
request one reviews and what came of it. In a review agent's sandbox,
`fctl review` is the agent's, through fctl-agent:

```sh
fctl review threads                    # fctl's earlier findings on the pull request, with the answers: PRRT_… on their lines, IC_…#1 in a summary
fctl review summarize summary.json     # sum it up at the end of its description first, where the project asks: --help shows the file
fctl review submit review.json         # post the review, once: --help shows the file
```

### Schedules

A schedule starts a session for a task on its own: once at a set time,
again and again on a cron expression in a time zone, or each time
something happens on GitHub in the project's repositories. Each run is a
session of its own, on the Claude subscription of the person the schedule
runs for, who follows it as they follow the sessions they start. A run is
skipped while the schedule's last session still works on its task (for
one on events, the last on the same issue, pull request or branch), and
while that person's plan is at its limit; one that runs once waits for the
limit to reset instead. People who start sessions in the project set up
schedules, on their own subscription, and run any of them now, on theirs;
a schedule's owner and the project's maintainers and owners change, pause
and delete it, and a change by anyone else runs it on theirs from then on:

```sh
fctl schedules -p my-app                       # its schedules, when each runs next and what its last run did
fctl schedules add "Weekly dependencies" -p my-app --cron "0 9 * * 1" --tz Europe/Stockholm \
  -m "Update the dependencies that have new patch or minor releases, and open a pull request."
fctl schedules add -p my-app --cron "0 8 * * 1-5" --task-file triage.md --github triage   # labels and comments, nothing else
fctl schedules add -p my-app --at 2h -m "Check whether the deploy went out, and say so."
fctl schedules add -p my-app --at 2026-10-30T16:00+01:00 -m "Draft the release notes."
fctl schedules add "Triage new issues" -p my-app --on issue-opened --github triage \
  -m "Triage the issue: label it, and ask for what is missing to act on it."
fctl schedules add "Work on labeled issues" -p my-app --on issue-labeled --label fctl -m "Do what the issue asks, and open a pull request."
fctl schedules add "Learn from merges" -p my-app --on pr-merged --by agents --hide-sessions --task-file learn.md
fctl schedules add "Fix main" -p my-app --on checks-failed -m "Find what broke the default branch, and open a fix."
fctl schedules add "Try the release" -p my-app --on release --repo acme/cli -m "Install the release and try what changed."
fctl schedules add "Triage an issue" -p my-app --when-asked -m "Triage the issue that comes with this."
fctl schedules add "Release notes" -p my-app --at 1d --paused -m "…"   # set up paused: it runs once resumed
fctl schedules show "Weekly dependencies" -p my-app   # by name or id: its task, settings and latest runs
fctl schedules edit "Weekly dependencies" -p my-app --cron "0 7 * * 1" --effort high
fctl schedules edit sch_01JC… --mine           # run it on your subscription from now on
fctl schedules edit sch_01JC… --name "Monday dependencies"
fctl schedules edit "Triage new issues" -p my-app --hide-sessions   # its sessions stay off session lists (--show-sessions)
fctl schedules edit "Triage new issues" -p my-app --label bug       # bug reports alone: the rest of what it waits for stays
fctl schedules edit "Triage new issues" -p my-app --max-per-day 20  # its events start at most 20 sessions a day
fctl schedules pause sch_01JC…                 # it starts nothing until it's resumed
fctl schedules resume sch_01JC…
fctl schedules run sch_01JC…                   # its task now, in a session on your subscription
fctl schedules run sch_01JC… --context "Issue #41 was just opened: the login page hangs"
fctl schedules runs sch_01JC… --limit 50       # the sessions it started, and why it started none
fctl schedules rm sch_01JC…                    # the sessions it started stay
```

`--cron` takes five fields (the minute, the hour, the day of the month,
the month and the day of the week, like `0 9 * * 1-5`) or `@hourly`,
`@daily`, `@weekly`, `@monthly` and `@yearly`, and runs at most every 15
minutes; `--tz` defaults to this machine's time zone. `--at` takes how far
ahead (`2h`, `30m`, `1d`) or a time with its UTC offset. `--on` sets up
one that runs each time something happens on GitHub: `issue-opened`,
`issue-labeled` (with `--label`), `pr-opened` (a draft once it's ready
for review), `pr-merged`, `release` (published) or `checks-failed` (all
the checks of a branch's newest commit ended, one or more failed). Its
agent gets what GitHub said of it after the task, as information, not
instructions. `--repo` keeps it to some of the project's repositories
(default: those its agents write to), `--label` to issues and pull
requests with one of the labels, `--branch` to pull requests into one of
the branches, or the branches whose checks it watches (default: the
default branch), and `--by` to what `anyone`, `writers` (people who may
write to the repository, and fctl's agents) or `agents` (fctl's) opened
(default: anyone, but writers for `pr-opened`); with `fctl schedules
edit`, they change what it waits for and keep the rest. One that anyone
on GitHub can start, issues opened or pull requests opened by `anyone`,
triages unless `--github` says more: what an outsider wrote reaches an
agent that pushes only where you ask for that. A schedule's
events start at most 3 sessions an hour (the last 60 minutes) and 10 a
day (the last 24 hours) unless `--max-per-hour` (up to 100) and
`--max-per-day` (up to 1,000) say otherwise; past either they start none,
and its runs say why. Events need the instance's GitHub App
subscribed to the event ([Self-hosting](https://fctl.sh/docs/self-hosting.md#1-create-the-app)):
`fctl schedules` says when it isn't. `--when-asked`
sets up one without a time, which runs only when someone runs it, or
another tool does, each run on the subscription of whoever runs it; a
paused schedule starts nothing, not even then. `--model`,
`--effort`, `--github` and `--base` say what its sessions start with,
`default` for the project's (for `--github` on an event anyone on GitHub
can start, triage). What `--context` says comes after the task;
from an access token, its agent takes it as information, not instructions
([Automation](https://fctl.sh/docs/automation.md#start-agents-from-other-tools)). A project
keeps at most 50 schedules.

### Autopilots

An autopilot (experimental) runs a project, or its whole workspace, on its
own: from a direction, it plans the work, starts sessions to do it, and
sets up what they need, as far as its powers go, on the Claude
subscription of whoever puts it on. Its workspace's admins let projects
have one; its maintainers and owners put it on and steer it
([Architecture](https://fctl.sh/docs/architecture.md#autopilots)):

```sh
fctl workspaces set -w acme --autopilots on    # admins: projects may have an autopilot
fctl autopilot on -p crm --direction "Build a CRM for small agencies: contacts, deals and a pipeline board."
fctl autopilot on -p crm --direction-file direction.md --check-in 30m --sessions 4 --powers settings,schedules
fctl autopilot on -p ops --workspace --direction-file ops.md   # admins: the whole workspace, from ops
fctl autopilot -p crm                          # where it stands: what it asks, notes, sessions, plan
fctl autopilot steer -p crm "Focus on the pipeline board this week."
fctl autopilot asks --all                      # what autopilots ask you, across your workspaces
fctl autopilot answer -p crm apa_01JC… "Stripe"
fctl autopilot answer -p crm apa_01JC… --attach logo.svg "The dark one"   # files go to the session it asks about
fctl autopilot secret -p crm apa_01JC…         # the value it asked for, without showing it (or from stdin)
fctl autopilot decline -p crm apa_01JC… --reason "Not yet: after launch"
fctl autopilot log -p crm --limit 100
fctl autopilot files -p crm                    # the files it keeps for its next sessions, marking those its plan doesn't name; get NAME prints one
fctl autopilot set -p crm --check-in 2h --direction-file direction.md   # how it works, or its direction
fctl autopilot set -p crm --handoff-at 250k    # a fresh session takes over once its own holds 250K tokens of context (never: only after 12 hours)
fctl autopilot set -p crm --powers merge,settings,others   # it manages the sessions people start in crm too
fctl autopilot wake -p crm                     # now, with what's new
fctl autopilot wake -p crm --fresh             # in a fresh session, which starts from its plan and log (once its turn ends, while it works)
fctl autopilot pause -p crm --reason "Launch week"
fctl autopilot resume -p crm                   # on your subscription, if it ran on someone else's (unless they keep it)
fctl autopilot set -p crm --keep-owner on      # its owner: others' changes and resumes run on your plan too
fctl autopilot set -p crm --mine               # run it on your subscription from now on
fctl autopilot off -p crm --stop-sessions      # its direction, notes, plan, files, log and asks stay
```

`--check-in` is how long it goes without waking, at most: 15m, 30m, 1h,
2h, 4h, 8h, 12h or 1d; it wakes sooner when one of its sessions ends a
turn, asks something or fails, and when people steer or answer it.
`--sessions` is how many of its sessions work at once (1 to 8).
`--powers` lists what it may do besides starting and steering sessions:
`merge` (its sessions merge their own pull requests once checks pass and
the work is done, as far as the repository's rules let them),
`settings`, `secrets` (those it makes itself, never those people set),
`repos`, `schedules`, for a workspace's autopilot `projects`, and
`others`: it manages the sessions people start in its places as its own
(fctl wakes it as one ends a turn, asks something or fails, and it
messages them and resumes one that failed, to see their work merged and
shipped, but never interrupts or stops one, nor writes to one its people
stopped; they run on their people's
Claude subscriptions, and what their people ask of them wins); `all`
(every power its scope has but `others`, which people name) or `none`.
Changing how much it works, giving it `others`,
resuming it or `--mine` runs it on your subscription from then on, unless
its owner keeps it on theirs with `--keep-owner on`: then only `--mine`
does, or a change once they can no longer run it. Keep it only in a
project whose people you all trust: everyone who steers it (its
maintainers and owners, or a workspace's admins) then runs it on your
Claude plan, as you.

In its own session's sandbox, the autopilot's `fctl` reaches the API as
the person it acts for, without signing in (`FCTL_AUTOPILOT` names its
project, the default for `-p`): `fctl run`, `fctl sessions`, `fctl show`,
`fctl logs`, `fctl send`, `fctl files`, `fctl stop`, `fctl projects set`,
`fctl projects secrets`, `fctl projects repos`, `fctl schedules` and `fctl
projects create`, as far as its powers go. It attaches files to the
sessions it starts and those it steers (`fctl run --attach`, `fctl send
--attach`): one people sent it, one it made, or one sent in another of its
sessions, which `fctl files get` downloads. `fctl run` returns at once
there; fctl wakes it when its sessions move on (a turn that ends, a
question, a failure, a pull request of one that rests merging or
closing, or the checks on the base branch ending after one merged), with
the start of what
each said as its turn ended (or why it said nothing, where fctl knows)
and what people wrote to it meanwhile
(people's messages don't wake it themselves). `fctl logs <ref>
--last-turn` prints a session's last turn whole. With as many of its
sessions at work as its people allow, `fctl run` and `fctl resume` fail,
but `fctl send` to one that rests doesn't: fctl holds the message
(`aph_…`) and sends it as soon as one of its sessions ends its turn,
stops or fails, those held in the order it sent them, while it is on
(taking it off autopilot drops them). `fctl autopilot held` lists them,
for people too, and takes one back. Its files are for what its next
session needs: it removes a draft once it sent it, as fctl keeps the text
with the session, message or ask. Its brief and `fctl autopilot files`
mark the files its plan doesn't name, and a fresh session of its own
hears to go through those as it takes over, as it does while it keeps
more than 25 files, which `fctl autopilot files put` says too as it adds
one. It keeps the project's memory as its sessions do (`fctl memory add`,
`stale`, `duplicate`), and once a memory of its projects holds 900 of the
1,000 notes a project keeps, its brief says so: it deletes the notes stale
for over a day itself (`fctl memory delete --stale`), without asking, and
has a session tidy the current ones when they crowd it alone. It deletes
no single note, and no note stale for a day or less.

```sh
fctl autopilot brief                           # where things stand, as it wakes
fctl autopilot brief --only sessions,people,asks   # some parts: direction, notes, asks, sessions, people, plan, files, log
fctl autopilot plan > plan.md                  # its plan as fctl has it
fctl autopilot plan --file plan.md             # its plan, whole (Markdown; - for stdin)
fctl autopilot plan --section "In flight" --file part.md   # one section, to the next heading of its level
fctl autopilot files put watch-deploy.sh       # a file its next sessions get back (text: 256 KB each, 4 MB in all)
fctl autopilot files put - --name reply.md < draft.md
fctl autopilot files get --all                 # all of them, into the current directory (--dir DIR); scripts executable
fctl autopilot files get watch-deploy.sh       # one, printed (-o FILE to write it)
fctl autopilot files rm ask-logo.md            # a draft it sent: the ask keeps its text
fctl autopilot log "Started crm#12 for the board; imports wait for the CSV format."
fctl autopilot ask "Which layout should the board use?" --detail-file options.md -o Compact -o Roomy
fctl autopilot ask --secret CLOUDFLARE_API_TOKEN "To deploy previews from CI"
fctl autopilot ask --session crm#12 "Could you send crm#12 the logo files?" -o Sent   # people's files go to crm#12
fctl autopilot withdraw apa_01JC…              # found out itself
fctl autopilot held                            # its messages that wait for room, in the order they go
fctl autopilot held --take-back aph_01JC…      # before it goes
fctl memory delete --stale                     # the notes stale for over a day, once its brief says they crowd the memory
fctl autopilot wake --in 45m                   # when to wake next, 5m to 1d
fctl autopilot pause --reason "The direction is done: all four features shipped."
```

## Webhooks

A webhook posts what happens to an address of yours as it happens, signed
with its secret: sessions starting, finishing a turn, asking something,
with their pull requests ready for review, failing; agents' pull
requests; reviews; schedules' runs that start nothing
([Automation](https://fctl.sh/docs/automation.md#webhooks)). A workspace's admins add webhooks
for all its projects, or some (`-w`, the default workspace without it);
a project's owners and maintainers add its own (`-p`):

```sh
fctl webhooks -w acme                          # the workspace's webhooks and its projects', how each stands
fctl webhooks -p web                           # web's own, and the workspace's that send its events
fctl webhooks add https://hooks.example.com/fctl -p web --name "Deploy bot" \
  --events session.question,session.ready_for_review,session.failed     # once the address answers fctl's challenge; prints its secret, once
fctl webhooks add https://example.com/reviews -w acme --events "review.*" --projects web,api
fctl webhooks add https://example.com/nightly -w acme --events session.started,session.stopped --started-by schedules
fctl webhooks show "Deploy bot" -p web         # by name, host or id: what it posts, how it stands, its newest deliveries
fctl webhooks edit "Deploy bot" -p web --events all
fctl webhooks edit whk_01KC… --url https://hooks.example.com/v2   # an id needs no -w or -p
fctl webhooks edit "Deploy bot" -p web --off   # it gets nothing until --on, which also turns on one fctl turned off
fctl webhooks test "Deploy bot" -p web --event session.ready_for_review   # a made-up event, now; exits 1 when it fails
fctl webhooks deliveries "Deploy bot" -p web --failed --limit 50
fctl webhooks delivery "Deploy bot" -p web whd_01KC…   # the request as fctl posted it, every attempt, the answer
fctl webhooks resend "Deploy bot" -p web whd_01KC…     # again, now: five times at most
fctl webhooks resend "Deploy bot" -p web --failed --since 6h   # all that failed since then, in their turn
fctl webhooks secret "Deploy bot" -p web       # its secret, on stdout
fctl webhooks secret "Deploy bot" -p web --rotate   # a new one; the old one signs too for a day
fctl webhooks rm "Deploy bot" -p web
fctl webhooks events                           # every event, with what it means
fctl webhooks verify --secret whsec_… --id evt_01KC… --timestamp 1763400000 --signature "v1,…" body.json
fctl webhooks verify --any-age --secret whsec_… --id evt_01KC… --timestamp 1763400000 --signature "v1,…" saved.json
```

`--events` takes events by name (`session.finished`), groups
(`session.*`, `pull_request.*`, `review.*`, `schedule.*`) or `all` (the
default); `--projects`, a workspace's projects by slug or id, or `all`;
`--started-by`, whose sessions' events (`people`, `schedules`,
`autopilot`, `tickets`, `service-accounts`), or `all`. Addresses are `https://` on the public
internet, unless a self-hosted instance lets webhooks reach its own network
or post over `http://`, which `fctl webhooks events` says
([Self-hosting](https://fctl.sh/docs/self-hosting.md#webhooks-to-your-own-network)). Adding a webhook, pointing one elsewhere, and reading or
rotating its secret are sensitive actions, which take confirming it's you where the instance
asks for that. `fctl webhooks verify` checks a request as a receiver
does, with the secret in `--secret` or `FCTL_WEBHOOK_SECRET`: whether the
secret signed it, and whether its timestamp is within 5 minutes of the
machine's clock; it exits 1 when either fails, and says whether the
secret signed one that's too old. `--any-age` checks a request saved
earlier by its signature alone. A workspace has at most 20 webhooks.

## Service accounts

A workspace's service accounts are credentials for programs of its own,
such as a portal where its people start agents: each request names the
person it acts for (`--on-behalf-of`), and the session it starts is
theirs, on their Claude subscription
([Automation](https://fctl.sh/docs/automation.md#service-accounts)). Its admins make and
manage them; each member answers whether one may start sessions for
them, which it needs where the instance asks people:

```sh
fctl service-accounts -w acme                  # its service accounts, with your answer to each
fctl service-accounts create "Acme portal" --description "Our agent portal at portal.acme.dev"   # prints its secret, once
fctl service-accounts show "Acme portal"       # who keeps its secret, how its people answered, what it did
fctl service-accounts people "Acme portal"     # whom it may act for, and why not
fctl service-accounts set "Acme portal" --name "Portal" --description ""
fctl service-accounts secret "Acme portal"     # a new secret; the old one stops at once, and you keep the new one
fctl service-accounts rm "Acme portal"         # its sessions stay their people's
fctl service-accounts allow "Acme portal"      # let it start sessions for you
fctl service-accounts deny "Acme portal"       # or not, or no longer
```

`fctl workspaces` and `fctl workspaces join` say which service accounts
wait for your answer, and an invitation names the workspace's service
accounts before you join.

With a service account's token, `fctl whoami` says what it is and whom it
acts for, `fctl service-accounts people` whom it may act for, and the
other commands act for the person `--on-behalf-of` names (`fctl run`,
`fctl send`, `fctl stop`, `fctl schedules run`), or read the workspace
without one (`fctl sessions --mine`, the sessions it started; `fctl
show`, `fctl logs`, `fctl projects`, `fctl schedules`). `fctl run` with
one doesn't follow the session live, as service accounts open no live
connections: `fctl logs` reads what its agent did. A schedule it runs
without `--on-behalf-of` runs for the person the schedule runs for.

## Notifications

A session you follow notifies you when it waits for your reply, pauses on a
usage limit or fails, in every browser where you turned notifications on
(Settings → Notifications in the web app; on iPhone and iPad, fctl added to
the Home Screen). You follow the sessions you start and resume. An
autopilot's own session, and those it starts while it is on, notify you only
when they ask you something, or when its own sessions failed four times in
a row, and each day they go on failing: it looks after the rest itself, and
fctl goes on trying every hour.

```sh
fctl notifications status                   # what notifies you, and the browsers that get it
fctl notifications set --waiting off        # on or off: --waiting, --paused, --failed
fctl notifications set --follow-started off # follow only the sessions you choose
fctl notifications set --slack on           # and in your messages with fctl's app in Slack, where you linked your account
fctl notifications test                     # a test notification to your browsers
fctl notifications remove psh_01…           # stop notifying a browser
```

Several that arrive close together come as one, and at most one a minute.
People who are looking at a session (in the web app with its tab visible,
or with `fctl attach`) aren't notified about it.

With `--slack on` ("Tell me in Slack"), fctl's Slack app sends them too,
in your messages with it in the Slack workspace each session's workspace
works in, where you linked your account and its admins let notifications
go there: a question comes with a button for each answer, and a reply in
a notification's thread reaches the session as your message. `fctl
notifications status` lists where they go
([Notifications in Slack](https://github.com/hyperstructure/fctl/blob/main/docs/slack.md#notifications-in-slack)).

## Claude

```sh
fctl claude connect              # paste a token from `claude setup-token`: it lasts a year (recommended)
fctl claude connect --token sk-ant-oat01-…
fctl claude connect --login      # full sign-in, on one of your runners (Remote Control), until Claude ends it
fctl claude connect --on-runners # run on the token your runners keep, which you never give to fctl
fctl claude connect --made-at 2026-01-14   # …a token `claude setup-token` made that day: it runs out a year on
fctl claude status               # your connections, their ids, when Claude last answered each, when a token runs out, how much of each plan is used, and which runners keep your token
```

A long-lived token runs out a year after `claude setup-token` made it.
fctl can't read that day from the token: without `--made-at` it counts the
year from when you connect it, and says the token runs out *around* then.
It tells you 30 and 7 days before (by email, where the instance sends
it), and as soon as Claude refuses the token in sessions.

To keep your token on your runners instead of in fctl, run these on each
runner, then `fctl claude connect --on-runners` anywhere. Your sessions on
that connection run only on your runners that keep the token, in every
workspace, and wait while none of them is online:

```sh
claude setup-token               # makes a token that lasts a year (here, or on any machine with Claude Code)
fctl host claude set-token       # keeps it in ~/.config/fctl/claude-token, mode 0600 (asked for, or read from stdin)
fctl host claude status          # whether this runner keeps one, and whether fctl knows
fctl host claude remove-token    # sessions running here keep it until they stop
```

`claude_token_file` in `host.toml` keeps it somewhere else, such as a file
your secrets manager writes.

To keep your token out of sandboxes, so that agents can neither read it nor
send it anywhere (experimental, for the sessions that start after you change
it):

```sh
fctl claude set --stand-in on    # Claude gets a stand-in; the runner puts your token in on its requests to the Anthropic API
fctl claude set --stand-in off   # sandboxes get your token again (may ask you to confirm it's you)
```

Remote Control and claude.ai connectors may not work while it's on.

## Hosts

`fctl host` turns the machine you run it on into a [runner](https://fctl.sh/docs/cli.md#runners),
which runs sessions, and looks after it there. `fctl host install`
registers the runner and starts the host service, which connects to the
control plane, takes the runner's sessions and runs each in a sandbox of
its own; the other commands check, drain, update and remove that service.
They act on this machine alone: to see or manage runners from anywhere, by
name or id, use [`fctl runners`](https://fctl.sh/docs/cli.md#runners). One machine runs one host
service and is one runner.

```sh
fctl host install                # register this machine as a runner and start the host service
fctl host install --driver lima --capacity 2 --build-image
fctl host install --driver firecracker   # Linux with KVM: each session in a microVM of its own
fctl host install --driver lambda --workspace acme   # each session in an AWS Lambda microVM, in Acme's AWS account
fctl host install --cpus 4 --memory 8g --max-cpus 8 --max-memory 12g   # sandbox sizes
fctl host install --name studio-mac --image ghcr.io/acme/agent:1   # its name (default: the hostname), and the image for projects that choose none
fctl host install --allow-image 'ghcr.io/acme/*' --allow-build 'acme/*'   # what projects may run and build
fctl host install --workspace acme   # for a workspace you are in (default: the one you administer, or your only one)
fctl host install --workspace acme --personal   # only your sessions there (a member's always)
fctl host install --token fctl_rt_…   # with a runner token from a workspace's Runners tab (or FCTL_RUNNER_TOKEN)
fctl host install --enroll fctl_et_…  # without signing in, as one of a workspace's runners, or a member's own (or FCTL_ENROLL_TOKEN)
fctl host install --no-service   # write the config only (run it yourself)
fctl host install --auto-update off   # update fctl yourself (new hosts update themselves)
fctl host install --snapshot-bucket s3://acme-fctl/sessions   # keep sessions' snapshots in your bucket, not the control plane
fctl host install --agent-as-root off # run fctl-agent as the sandbox's user, not root
fctl host install --enroll fctl_et_… --retire-when-idle 20m --retire-command 'systemctl poweroff'   # a machine that goes once idle
fctl host run                    # run in the foreground (what the service runs)
fctl host status                 # with the runner's id and sessions, whether it drains, and the autopilots that wake here
fctl host doctor                 # check the configuration, tokens, connection, driver, sandboxes, images, disk and service
fctl host logs -n 200            # the last 200 lines of its log (on Linux, from the journal)
fctl host image pull             # pull the sandbox image again now (the host does every 6 hours)
fctl host image build            # build it here instead (with Lima: the base VM)
fctl host image build --source ~/src/sandbox   # from a checkout of hyperstructure/sandbox
fctl host image build --tag acme/sandbox:dev    # under another name (default: the host's image)
fctl host claude set-token       # keep your Claude token here, not in fctl (see Claude above)
fctl host auto-update            # whether it updates fctl by itself to the control plane's version
fctl host auto-update off        # or on; restarts the host service (sessions keep running)
fctl host restart                # sessions keep running
fctl host drain                  # take no new sessions; the ones here carry on
fctl host drain --wait           # …and wait until none runs here
fctl host drain --timeout 60s    # …for a minute at most, then stop what still runs (on Spot's two-minute notice)
fctl host undrain                # take new sessions again
fctl host uninstall              # sandboxes are kept; asks first when sessions run
fctl host uninstall --wait       # drain, and uninstall once none runs
fctl host uninstall --force      # stop the sessions here now, then uninstall
```

Drain a runner before maintenance: no new session starts on it, and the
sessions it has carry on there. Those that wait for a message stop once
they have waited a minute, and a message resumes each of them on this
runner, where its sandbox has Claude's conversation. So the runner is empty
whenever no turn runs, and `--wait` returns then. Admins can drain a runner
too, from the runners list or with `fctl admin drain`; whoever drained it,
either can stop the drain.

`--timeout` (`60s`, `10m`, `1h`, up to `48h`; it implies `--wait`) is for a machine
that a cloud takes away on a deadline: a Spot notice, an autoscaling
group's lifecycle hook, a pod's `preStop`. The turns under way get that
long to end; then the sessions that still run stop as `fctl host
uninstall --force` stops them, their agents push their work, and a
message resumes each on another runner. Stopping takes up to a minute
more, so give it a minute less than the cloud gives the machine.

A machine of a pool that grows and shrinks retires itself once its runner
has run nothing for a while: `fctl host install --retire-when-idle 20m
--retire-command '…'` (`retire_idle_minutes` and `retire_command` in
`host.toml`). It drains, checks that nothing came meanwhile, runs the
command, which takes the machine away (`aws autoscaling
terminate-instance-in-auto-scaling-group --instance-id … --should-decrement-desired-capacity`,
`gcloud compute instance-groups managed delete-instances …`, `systemctl
poweroff`), and once that worked, leaves: an enrolled runner is removed,
and the host service is uninstalled. Sessions the control plane still
sends it meanwhile start elsewhere.
A command that fails (an autoscaling group at its minimum size, say)
leaves the machine a runner, which takes sessions again and tries once
more after another idle while. `fctl host status` says how it retires.
With every machine protected from scale-in, the autoscaler only ever adds
machines, and never picks a busy one
([Machines that retire](https://fctl.sh/docs/architecture.md#machines-that-retire)).

An autopilot's own session wakes again by itself, on the runner that has
its sandbox: `fctl host status` lists the autopilots whose next wake
resumes their session here, with when each wakes. Draining the runner
moves each off once its turn has ended: its next wake starts a fresh
session on another runner, which takes over from its plan, log and
files, and the session here stops. So while the runner drains, the list
keeps only one paused here mid-turn on a usage limit, which `--wait`
waits for as for any session here, and once `--wait` returns, no
autopilot comes back to the runner. Shutting the machine down cuts off
one at work, which fctl stops ten minutes later; while the machine is
away, the next wake of each starts a fresh session on another runner
too, where another would run it, rather than resume it there without its
conversation. An autopilot whose next wake starts a fresh session anyway
(its shift is over, or its context is full) isn't listed.

`fctl host uninstall` stops the service, so it never leaves sessions to
agents nobody sees: when sessions run on the machine, it lists them and asks
before it stops them, or, without a terminal, needs `--wait` or `--force`.
Stopped this way, their agents stop and push their work, and a message
resumes each on another runner, in a new sandbox: with its conversation
and uncommitted work, from the snapshot its agent saved as it stopped,
where its workspace keeps them
([Session snapshots](https://fctl.sh/docs/architecture.md#session-snapshots)).
The runner keeps draining until `fctl host undrain`. A runner that enrolled
with an enrollment token is removed instead, with its token file: the
machine enrolls again with `fctl host install --enroll`.

`fctl host install` on Linux installs a systemd user unit, so it checks
first that your user's systemd manager answers, before it registers
anything. Where nobody logs in, as in a boot script, run `loginctl
enable-linger $USER` first (as root): fctl then finds the manager by itself.
Or pass `--no-service` and run `fctl host run` from a unit of your own.

The host service is a launchd agent on macOS and a systemd user unit on
Linux. On macOS, launchd writes its log to `~/Library/Logs/fctl/host.log`;
on Linux, systemd keeps it in the journal, where
`journalctl --user-unit=fctl-host.service -f` follows it. `fctl host logs`
prints the end of it on both.

`fctl host install` checks the driver before it registers anything: if the
driver can't run sessions (Apple's `container` or Lima isn't installed, a
service isn't running), it says what to fix and stops. `--driver auto` (the
default) picks the first ready one of apple, docker and lima, never
firecracker, which a host's owner chooses, or the process driver. When none
is ready, it says what each lacks, and on Linux what Firecracker lacks or
that it is ready for `--driver firecracker`. The driver it checked goes
into the host's settings in `~/.config/fctl/host.toml`:

```toml
server = "https://app.fctl.sh"
name = "studio-mac"
driver = "apple"         # apple | lima | docker | firecracker | lambda | process | auto (picks at every start)
capacity = 4             # concurrent sessions
# image = "ghcr.io/acme/agent:1"   # unset: the published image of the host's version
cpus = 4                 # per sandbox, when the project sets none
memory_mb = 8192         # per sandbox, when the project sets none
max_cpus = 8             # the most one sandbox may have (unset: all there is)
max_memory_mb = 12288
keep_stopped_hours = 72  # then remove a stopped session's sandbox (0 keeps them)
min_free_disk_gb = 20    # disk to keep free for sandboxes (0 keeps none)
max_cache_gb = 10        # package caches per project that shares them (0 keeps none)
keep_caches_days = 14    # then remove the caches of a project with no session here (0 keeps them)
# allowed_images = ["ghcr.io/acme/*"]   # images projects may choose (unset: any)
# allowed_builds = ["acme/*"]           # repositories it builds images from (unset: none)
build_timeout_minutes = 60
max_build_mb = 20480     # the largest image a build may make
auto_update = true       # update fctl to the version the control plane runs (false: `fctl self update`)
agent_as_root = true     # fctl-agent as root in sandboxes, out of the agent's reach (false: as the sandbox's user)
allow_cloud_metadata = false  # true: sandboxes reach the cloud's instance metadata service (169.254.169.254)
retire_idle_minutes = 0  # once the runner has run nothing this long, drain, run retire_command and leave (0: never)
# retire_command = "systemctl poweroff"   # what takes the machine away, with sh -c (unset: the host leaves and stops)

[kubernetes]             # with the host in a Kubernetes pod
pod_deletion_cost = true # keep the pod's deletion cost at its number of sessions, so that scaling down takes idle pods first

[snapshots]              # sessions' snapshots in a bucket of your own, not the control plane
# url = "s3://acme-fctl/sessions"   # unset: the control plane keeps them
# endpoint = "https://<account>.r2.cloudflarestorage.com"   # an S3-compatible service (unset: AWS S3)
# region = "eu-north-1"  # unset: AWS_REGION, the machine's own on EC2, else us-east-1
# access_key_id = "…"    # with secret_access_key_file (unset: the machine's role or AWS_* variables)
# max_mb = 2048          # the largest snapshot it keeps there

[firecracker]            # with the firecracker driver
# firecracker = "/usr/local/bin/firecracker"   # unset: the release fctl pins, which the host downloads
# kernel = "/var/lib/fctl/vmlinux"             # a file, or an image whose /vmlinux it is (unset: the published one)
disk_gb = 64             # each sandbox's own disk, which takes only what its session writes
snapshots = true         # a stopped sandbox keeps its VM's memory, and resumes as it was
# jailer = true          # on a host that runs as root: each VM as a user of its own, in a chroot and a cgroup

[lambda]                 # with the lambda driver: AWS Lambda microVMs, whose settings come from the control plane
# region = "us-east-1"   # unset: the settings' image's, AWS_REGION, the machine's own on EC2, else us-east-1
# role_arn = "arn:aws:iam::123456789012:role/fctl-microvms"   # a role it assumes (unset: the machine's role or AWS_* variables)
# external_id = "…"      # what that role's trust policy asks for
```

With Docker on Linux, the daemon's socket lets in only root and the
members of the `docker` group, and a process keeps the groups it started
with: your shell until you log in again, and the systemd user manager that
starts the host service until the machine restarts. So when you are in the
group but they started before you joined it, `fctl host install`, `run`,
`status` and `doctor` take it themselves, starting again through `sg
docker`. When you aren't in it, `fctl host install` offers to add you
(`sudo usermod -aG docker $USER`, once you say yes; without a terminal it
says the command and stops), and after it starts the service it checks
that the service has the group. A host that still can't reach Docker says
why, with the command that fixes it, in its log, `fctl host status`,
`fctl host doctor`, `fctl runners` and the Runners tab. Where `sg` can't
give the service the group, `sudo systemctl restart user@$(id -u).service`,
or restarting the machine, does.

While the driver a host uses isn't ready, whatever the driver (Docker
isn't running, Apple's `container` service stopped, Lima has no base VM),
no session starts on its runner, not even a resume into a sandbox it has.
A session that another runner can take starts there; one that has
nowhere else to go stays queued and says why ("Waiting for studio, whose
docker driver isn't ready: …"). The host probes its driver every 30
seconds meanwhile and tells the control plane as soon as it answers, and
the sessions that wait start. While it is ready, the host probes it every
minute, so a runner shows a stopped Docker within about a minute, in
`fctl runners` and the Runners tab. When Docker stops between two probes, a
session the host can't make a sandbox for goes back to the queue instead
of failing. Hosts of an older fctl still get sessions, which fail until
the driver is ready; `fctl runners` says which happens on each runner.

Apple's `container` service stops when the Mac restarts. A host whose
driver is apple starts it again (`container system start`, never
installing a kernel): when the host starts, and within about a minute
and a half of the service stopping. With `auto`, or
another driver, the host leaves it, and Docker's daemon, to their owner.

With Apple's `container`, one sandbox whose VM stops answering, as one
whose memory runs out may, holds up every other: the service starts
sandboxes, and commands in them, one at a time, and waits for that VM
for ever, so nothing starts on the runner while `container list` and
`container system status` answer as ever
([apple/container#1916](https://github.com/apple/container/issues/1916)).
When a `container` command runs out of time, or a sandbox takes more
than three minutes to start, the host asks each running sandbox for its
stats, and stops each of its own that doesn't answer within two minutes
by killing the `container-runtime-linux` process that runs its VM. The
rest go on. A session in that sandbox fails, saying so, and resuming it
starts the sandbox again with its files; what ran in it is gone. A
container that isn't fctl's, the host leaves to you: until it answers
or stops, the apple driver isn't ready, and `fctl host status`, `fctl
runners` and the Runners tab say which container it is and the command
that stops it. `fctl host doctor` names every running container whose
VM doesn't answer within 10 seconds, with that command.

Apple's sandboxes can also lose the network, all at once, while the Mac's
own works on: lookups in them run out of time (`Could not resolve host:
github.com`), or their connections go nowhere, after the Mac's network
changed or a VPN came or went, until Apple's `container` restarts. Before
fctl-agent starts in a sandbox, and every minute while sessions run, the
host asks the sandbox whether it reaches github.com. When it doesn't, and
a fresh sandbox doesn't either while the Mac does, the host restarts
Apple's `container` itself (`container system stop`, `container system
start`) and starts again the containers that ran, its sandboxes and any
other of yours. What ran in them is gone: a session at work has its turn
cut off, and its agent carries on. It restarts it at most once every 30
minutes: while sandboxes still don't reach the network, the apple driver
isn't ready, saying why, and sessions wait rather than fail. A VPN, or a
program that holds port 53 (`sudo lsof -i :53` names it), can keep them
so; restarting the Mac brings them back. `fctl host doctor` starts a
fresh sandbox to say whether sandboxes reach github.com.

If `container` commands still wait, restart Apple's `container`. This
stops every sandbox; their sessions fail, and resuming each starts its
sandbox again:

```sh
killall -9 container-apiserver   # `container system stop` waits for a VM that doesn't answer otherwise
container system stop            # stops every sandbox's VM
container system start           # or leave it to the host, within about a minute and a half
```

On Linux, `--driver firecracker` runs each session in a
[Firecracker](https://firecracker-microvm.github.io) microVM with a kernel
of its own, from the same images as Docker, with nothing running as root.
It needs KVM that your user may use, and two packages:

```sh
sudo usermod -aG kvm $USER   # then log in again; `ls -l /dev/kvm` shows the group
sudo apt install passt e2fsprogs   # or dnf, pacman: passt gives the VMs their network
fctl host install --driver firecracker
```

The host downloads Firecracker and the VMs' kernel itself, and pulls
images without Docker: a short-lived VM unpacks each image's layers as
they download. A host whose service root installed runs each VM through
Firecracker's jailer, as a user of its own in a chroot, unless
`jailer = false` in `host.toml`'s `[firecracker]`; that needs cgroup v2
and a data directory on a filesystem that allows device files, and
`fctl host doctor` says when either is missing. Its sandboxes mount their
project's package caches from the host over their vsock, and it builds
projects' images with BuildKit in a VM of each project's own; projects'
own images run as with Docker.
[Architecture](https://fctl.sh/docs/architecture.md#firecracker) has the details.

`--driver lambda` runs each session in an
[AWS Lambda microVM](https://docs.aws.amazon.com/lambda/latest/dg/microvms.html)
of its own, in your AWS account, from a host on any machine that may
manage its microVMs: an EC2 instance or ECS task with a role, or a
machine with AWS keys. The host runs no sandbox itself, and its microVMs'
settings come from the control plane: until the runner has them (`fctl
runners microvms set`, or its card on the Runners tab), it runs no
sessions. `fctl host install` checks that the machine may list the
account's microVMs. A session's microVM suspends while the session waits
with nothing running, resumes for the next message, and goes after a while
suspended, its session carrying on in a new one from its snapshot:
[Runners of microVMs](https://fctl.sh/docs/cli.md#runners-of-microvms) and
[Runners in your cloud](https://fctl.sh/docs/runners-in-your-cloud.md#aws-lambda-microvms).

```sh
fctl host install --driver lambda --workspace acme
fctl host microvm-image --arch x86_64 --memory 4g   # what Lambda builds an image of your own from, and the commands that build it
```

Sessions start from their project's image or, without one, the host's:
unless `image` sets another, the published image of the host's own version,
`ghcr.io/hyperstructure/sandbox:<version>`, which the host pulls when it
starts. A project's own image runs only if `allowed_images` allows it, or
is unset, and an image built from its repository only if `allowed_builds`
lists the repository. `--allow-image` and `--allow-build` replace the lists
(`--allow-image '*'` for any image, `--allow-build ""` for no builds), and
`fctl host status` shows them. [Sandbox images](https://fctl.sh/docs/sandbox-images.md) has the
details.

In container and VM sandboxes the host runs fctl-agent, the supervisor
that relays what the agent does, as root, and the agent as the image's
user, so that an agent's `kill` or `pkill` that matches fctl-agent by
accident fails rather than cut its turn short ([Sandbox
images](https://fctl.sh/docs/sandbox-images.md#what-fctl-writes-into-a-sandbox)). A host whose
owner wants no long-lived root process in its sandboxes runs it as the
image's user instead: `agent_as_root = false`, or `fctl host install
--agent-as-root off`, then `fctl host restart`. The agent's commands can
stop fctl-agent then: the host starts it again, and the agent carries on
with the turn that was cut off, but what it did meanwhile isn't in the
transcript. With it off, the host runs nothing as root in Docker, Apple
container and Lima sandboxes: the sandbox's user puts fctl-agent in its
own `~/.fctl/bin`, and the package caches stay the image's user's (with
Docker, a new cache volume takes the owner of the image's
`/var/cache/fctl`, which the default image gives `agent`). Firecracker's
VMs boot with fctl-agent as their init, as root, either way. New
sandboxes follow the setting; one where fctl-agent already ran as root
keeps it so, rather than start a second one beside it. `fctl host status`
says which it runs as.

On a cloud machine, sandboxes don't reach the cloud's instance metadata
service (`169.254.169.254`, and the addresses of ECS, EKS Pod Identity,
Alibaba and Tencent), which hands out the machine's own credentials and
its user data, where boot scripts keep secrets such as an enrollment
token. Docker sandboxes get routes that make those addresses unreachable,
which a helper container with nothing but `NET_ADMIN` adds in their
network, and run without `NET_RAW`, so that not even their root takes the
routes out or sends around them; `ping` still works. Firecracker VMs'
frames to them are dropped on the host before `passt` carries them, but for
DNS, which Google Cloud's metadata server answers as the machine's
nameserver; a connection there fails at once with "No route to host".
Apple container and Lima VMs, whose root could change anything the host
set inside them, and the process driver aren't kept off them. A runner
whose sessions should use the machine's own cloud role sets
`allow_cloud_metadata = true`; agents reach clouds without one through
[identity tokens](https://fctl.sh/docs/identity-tokens.md) instead. A run whose sandbox can't
be kept off them doesn't start, and says why. A Docker sandbox made
before, with raw sockets, is replaced as its session next starts, which
starts a new conversation on its branch.

A project's Settings → Sandbox can ask for more CPUs or memory than the
host's default. Sessions only start on a runner whose maximum covers that;
when none does, they stay queued and say so ("No runner can give this
session 32 GiB of memory (the most is 15.6 GiB)"). Without `max_cpus` and
`max_memory_mb`, the maximum is what the machine has, or with Docker the
Docker daemon's: on macOS that is the VM of OrbStack, Docker Desktop or
Colima, which is usually smaller than the Mac. A default above the maximum
is lowered to it. `fctl host status` shows the sizes the host gives. The
host measures them when it starts and every five minutes, and the control
plane learns them when the host connects, so run `fctl host restart` after
changing `host.toml` or resizing the Docker VM.

Agents are told their sandbox's size in their instructions and in
`FCTL_SANDBOX_CPUS` and `FCTL_SANDBOX_MEMORY_MB`: with Docker, `nproc` and
`free` show the whole VM rather than the sandbox's share, and with Apple's
`container`, `nproc` counts one CPU more than the sandbox may use.

A stopped session's sandbox takes disk on the host until it has been
stopped for `keep_stopped_hours`, or until the disk runs low, and so does
a Firecracker host's image builder, with its project's build cache,
counted from its last build. With Firecracker a session's sandbox also
keeps its VM's state, the memory the VM used, so that a message resumes
the session with Claude running where it was rather than starting it
again; the host lets those states go first when the disk runs low, and
`snapshots = false` keeps none: turned off, it lets those kept before go
at its next sweep or the sandbox's next start, rather than resume them. A
sandbox whose state was kept before `jailer` was turned on or off starts
again from its disk. With Apple's `container`, a sandbox's disk image
keeps the space of the files its session deleted (a build of fctl leaves
about 5.5 GB) until the host stops the sandbox: then the host gives that
space back to the Mac with `container clean`. That needs Apple's
`container` 1.4 or later. With an older one, a stopped sandbox keeps the
most its session ever stored, and `fctl host logs` says so each time a
sandbox stops. `df` in the sandbox shows its 512 GiB disk image rather
than what the Mac has free.

The host keeps `min_free_disk_gb` free (20 GiB unless `host.toml` says
otherwise) on the disk where its sandboxes are: Apple's `container` app
root, Lima's `~/.lima`, Docker's root directory or, with Docker on macOS,
the disk inside its VM, and the data directory with Firecracker and the
process driver. It
measures every 30 seconds (inside Docker's VM every five minutes, since
that starts a container). With less free than that:

- It removes stopped sandboxes before `keep_stopped_hours`, those stopped
  longest first, one at a time, until there is enough free again. A
  message to one of those sessions resumes it in a new sandbox on its
  branch, with what the agent pushed, and Claude starts a new conversation.
- It takes no new sessions meanwhile, only resumes of the sessions whose
  sandboxes it still has. A session that has nowhere else to go stays
  queued and says "Waiting for a runner: the ones online are low on disk".
- `fctl host status`, `fctl host doctor`, `fctl admin runners` and the
  runners list say how much is free.
- It measures every 5 seconds rather than 30 (not inside Docker's VM).
- Its running sessions hear of it: their transcripts get a
  `runner_low_on_disk` notice, and their pages and `fctl attach` say how
  much is free until there is room again. Below 2 GiB free (or below
  `min_free_disk_gb`, if that is lower), writes are about to fail: they
  get `runner_out_of_disk`, the runners list says "out of disk" in red,
  and with the Firecracker driver the host pauses their sandboxes, whose
  VMs keep what they hold in memory rather than lose it on a full disk. It
  resumes them once twice that is free, or when the session stops. Once
  the runner has had room for ten minutes, its sessions get
  `runner_disk_ok`.

Sessions that run carry on, and nothing stops them for disk. When no
stopped sandbox is left to remove, the host takes sessions again once
running ones stop and the host removes their sandboxes, or once something
else frees space. Set `min_free_disk_gb = 0` to remove sandboxes by age
only, or lower `keep_stopped_hours` to remove them sooner whatever the disk
has, and run `fctl host restart` after changing either.

For projects that share package caches (`fctl projects set
--package-caches on`), the host keeps what their sessions' package
managers download: with Docker in a volume per project,
`fctl-cache-<project id>`, and with Apple's `container` and Firecracker in
a directory of its data directory, `caches/<project id>`, that its
sandboxes mount at `/var/cache/fctl` (Firecracker's over 9P on their
vsock). The sweep that removes stopped sandboxes, when the host
starts and every hour, looks after them too:

- It measures the caches that a session used since they were last
  measured, and empties those that take more than `max_cache_gb` (10 GiB
  unless `host.toml` says otherwise). With Docker, measuring and emptying
  a volume run in a short-lived container of the host's image.
- It removes the caches of a project that no session has started with for
  `keep_caches_days` (14 unless `host.toml` says otherwise). Those that a
  stopped sandbox here mounts stay, emptied, until the sandbox goes.
- Below `min_free_disk_gb`, it empties caches, those used least recently
  first, before it removes stopped sandboxes: an empty cache costs the
  next session downloads, a removed sandbox its resume the time to
  restore its snapshot, or, without one, Claude's conversation.

It leaves alone the caches of a project with a session running here, and
a session that starts while the host measures or empties its project's
caches waits for that. `max_cache_gb = 0` keeps no caches: the next sweep
removes them, and sessions download what they need. `fctl host status`
shows what the caches took when last measured.

The host updates fctl by itself to the version the control plane runs,
whenever that is newer than its own, and with it the agent it puts in
sandboxes and its default image: on app.fctl.sh, every release. It
downloads the release from `download_base` (`https://fctl.sh/releases`
unless `host.toml` says otherwise), checks it as `fctl self update` does,
and restarts on it once no session is being started or stopped there;
sessions keep running. The control plane may run a release before its
archives are published: the host tries again every minute meanwhile, for an
hour, then every half hour. `fctl host logs` says what it does, and why it
doesn't when it doesn't. `auto_update = false` turns this off (`fctl host
auto-update off` sets it and restarts the host service; `--auto-update off`
when you install). Where Homebrew installed fctl, `brew upgrade fctl` updates
it, and a host that can't write to fctl's directory doesn't update itself
either: `fctl host status` and `fctl host doctor` say so
([Host updates](https://fctl.sh/docs/architecture.md#host-updates)).

## Runners

A runner is a machine that runs sessions, with the host service on it
([Hosts](https://fctl.sh/docs/cli.md#hosts)). `fctl runners` sees runners from any machine, by their
name or id: the ones you registered, your workspaces', and, as an instance
admin, every one. A workspace's **Runners** tab shows the same.

```sh
fctl runners                     # the runners you see: yours, your workspaces' (every one for instance admins)
fctl runners -w acme             # one workspace's
fctl runners --pending           # the ones that wait for your approval
fctl runners approve build-7     # its name or id: it runs the workspace's sessions, or yours, from now on
fctl runners reject build-7      # it is removed, and its token stops working
fctl runners rename build-7 build-07
fctl runners drain build-7       # no new sessions start on it (undrain: they do again)
fctl runners disable build-7     # it disconnects until enabled (enable)
fctl runners remove build-7      # asks first in a terminal (--yes without asking)
fctl runners token build-7       # replace its token, which it prints once
```

These take a runner you may manage: one you registered or enrolled, one
that belongs to a workspace you are an admin of, and, as an instance admin,
any.

### Enrollment tokens

Machines that autoscaling creates, or that you set up without signing in
on them, enroll themselves as a workspace's runners with one of its
enrollment tokens, which its admins make, or as yours with one you make for
your own sessions:

```sh
fctl runners enrollment-tokens -w acme       # what each does, its runners, when it expires (members: their own)
fctl runners enrollment-tokens create "Build fleet" -w acme --max-runners 20 --remove-offline-after 5m
fctl runners enrollment-tokens create "Laptops" -w acme --approval --expires 7d
fctl runners enrollment-tokens create "My cluster" -w acme --personal --remove-offline-after 5m
fctl runners enrollment-tokens revoke "Build fleet" -w acme   # it enrolls no more; its runners stay
```

Its runners are a pool, with labels and a placement: [Runner pools](https://fctl.sh/docs/cli.md#runner-pools).

`create` prints the token once, on stdout. Without `--expires` it expires
in 90 days (`1h` to `1y`, or `never`); without `--max-runners`, it enrolls
any number of runners, and with it, that many at once: removed and
rejected ones free their place. On each machine, signed in or not:

```sh
curl -fsSL https://fctl.sh/install | sh
FCTL_SERVER=https://app.fctl.sh FCTL_ENROLL_TOKEN=fctl_et_… fctl host install
```

The runner belongs to the workspace, not to you or the token's maker: it
runs everyone's sessions there and no other workspace's, and its admins
manage it. With `--approval`, it waits until one of them runs `fctl
runners approve` (or approves it on the Runners tab) and takes sessions as
soon as they do, without a restart; meanwhile `fctl host status` on it
says it waits, with its id. One nobody approves within 7 days is removed.

With `--personal`, the token is for your own sessions: a member's always
is, and an admin's is for everyone's without it. The runners it enrolls
are yours, run only your sessions in that workspace and no other's, and
count as your runners for **Only on my runners** and the Claude token you
keep on your runners (`fctl host claude set-token < /run/secrets/claude-token`
on each, from your secret store). With `--approval`, they wait for you.
The workspace's admins see your tokens and runners there, and revoke or
take them out; taking one out removes it.
`fctl host install --enroll` again keeps the runner the machine has in that
workspace, so a boot script can run it every time, and `fctl host
uninstall` removes it. With `--remove-offline-after`, runners that stay
offline that long (`1m` to `30d`) go too, as machines that autoscaling
destroys do without uninstalling. Only time the control plane is up counts,
so a deploy or an outage of its own removes none, but a runner that loses
its network for longer is gone, and enrolls again: give a fleet whose
machines stay up `15m` or more.

### Runner pools

The runners a token enrolls are a pool: they carry its labels, which
projects choose them by, and take sessions as its placement says
([Runner pools](https://fctl.sh/docs/architecture.md#runner-pools)):

```sh
fctl runners enrollment-tokens create "AWS large" -w acme --labels aws,large --max-runners 20 --remove-offline-after 5m
fctl runners enrollment-tokens set "AWS large" -w acme --placement spread   # or packed; its runners follow at once
fctl runners enrollment-tokens set "AWS large" -w acme --labels aws,xl --max-runners none
fctl projects set -p ml --runners aws,large              # its sessions wait for a runner with both
fctl projects set -p ml --runner-fallback 15m            # or run on any runner after 15 minutes (never: wait)
fctl runners pools -w acme                               # each pool, with what it needs now
fctl runners demand -w acme --pool "AWS large"           # in detail; --watch keeps it live
fctl runners demand -w acme --pool "AWS large" --json    # what KEDA's metrics-api scaler reads (valueLocation: wanted)
FCTL_SERVER=https://app.fctl.sh FCTL_ENROLL_TOKEN=fctl_et_… fctl runners demand --cloudwatch   # the token's pool, without signing in
```

`--placement packed` (the default for a token with
`--remove-offline-after`) gives a session to the busiest runner that
still has room, so that the others empty out and an autoscaler can take
them away; `spread` gives it to the least busy. `--labels ""` takes a
pool's labels away, and `fctl projects set --runners ""` a project's. A
project's sessions run only on runners with all its labels: a pool's, or
ones a host sets in its `host.toml` (`labels = ["gpu"]`, lowercase). One
that waits says which pool it waits for and why.

`fctl runners demand` shows each pool's runners (online, busy, starting,
draining, waiting for approval, offline), its slots, the sessions that
wait that it could run, by reason, and how many runners would run them
all (`wanted`): never fewer than its runners that run a session, nor more
than its `--max-runners`. With no runner online, it counts with what its
runners said last, so that an autoscaler starts a pool from none.
`--cloudwatch` puts `WaitingSessions`, `BusySlots` and `WantedRunners`
into CloudWatch with the AWS CLI (`--namespace`, `fctl` by default), with
the pool's name as the `Pool` dimension (its id where the name isn't
ASCII, which CloudWatch takes only): once, or every minute with
`--watch` (`--every`). Admins see every pool of the workspace, members
their own; a service account reads them too.

### Runners of microVMs

A runner whose host has the lambda driver runs sessions in AWS Lambda
microVMs ([Hosts](https://fctl.sh/docs/cli.md#hosts)), with settings its managers choose: the image,
each microVM's size, roles, network, when a session's microVM suspends and
when it goes, and how many wait warm. Its host gets them within seconds:
new microVMs start with them, and those that run keep theirs until they go.

```sh
fctl runners microvms show microvms   # its image, each microVM and its session, and its settings (--json)
fctl runners microvms set microvms --artifacts s3://acme-fctl/microvms \
  --build-role arn:aws:iam::123456789012:role/fctl-microvm-build   # fctl builds the image, and keeps it current
fctl runners microvms set microvms \
  --image arn:aws:lambda:us-east-1:123456789012:microvm-image:agents   # or one of yours
fctl runners microvms set microvms --memory 4g --arch x86_64 --warm 4 --max 50
fctl runners microvms set microvms --suspend-after 2m --terminate-after 3h
fctl runners microvms set microvms --execution-role none --egress none --log-group /aws/lambda-microvms/fctl
fctl runners microvms set microvms --first   # sessions start here before the workspace's other runners
```

`set` changes what it names and keeps the rest; a runner with no settings
yet needs its image. Without the others, a session's microVM is 2 GiB
(1 vCPU, bursting to 8 GiB and 4 vCPUs), suspends once the session has
waited 90 seconds with nothing running (no turn, no background task),
and goes after an hour suspended; 2 microVMs wait warm, of 20 at most,
warm and suspended ones included. A message to a session whose microVM
is suspended resumes it as it was, in a second or two; one after it went
carries the session on in a new microVM from its snapshot, where the
workspace keeps them. Only the runner's owner and its workspace's admins
see and change its settings, and they confirm it's them as they do;
everyone who sees the runner sees its microVMs.

## Admin

Instance admins manage people and invitations, the GitHub App's
installations, every runner and the instance's settings, and see what each
workspace is and who runs it, but not inside the ones they aren't members
of.

```sh
fctl admin users                           # with their other addresses, how many workspaces, when last active
fctl admin invite ada@private.example      # an invitation link (and an email, when set up)
fctl admin invite grace@example.com -w side-project -w acme:admin   # and to your workspaces
fctl admin invite grace@example.com --admin   # where you allowed her as a member by hand, after fctl admin disallow grace@example.com
fctl admin role grace@example.com admin    # an instance admin, or member again (the primary instance owner)
fctl admin transfer grace@example.com      # the primary instance owner hands the role to an admin
fctl admin disable grace@example.com       # can't sign in; their tokens stop working (or enable)
fctl admin delete-user grace@example.com   # asks you to type their address (--confirm ADDRESS without a terminal)
fctl admin workspaces                      # and which need a primary admin
fctl admin set-primary side-project grace@example.com   # when its primary admin's account is disabled
fctl admin delete-workspace side-project   # asks you to type its name (--confirm NAME without a terminal)
fctl admin github list                     # the app's installations, and the workspaces that use each
fctl admin github remove acme side-project               # take acme from the workspace (its admins reconnect it)
fctl admin slack                           # the instance's Slack app: its variables, Socket Mode, the Slack workspaces it's in
fctl admin slack --manifest yaml > slack-manifest.yaml   # the manifest that creates it, with this instance's addresses (or json)
fctl admin slack --match-email on          # workspaces may know people by their verified address in Slack (off by default)
fctl admin early-access                    # who asked for early access, where the instance takes requests
fctl admin early-access remove spam@example.com   # asking again adds them back
fctl admin allowlist
fctl admin allow ada@example.com           # also creates an invite link
fctl admin allow '*@example.com'           # a whole domain
fctl admin allow grace@example.com --admin
fctl admin disallow '*@example.com'        # its addresses lose access (and accounts with no other)
fctl admin reserved                        # the slugs held for later, which no new workspace or project takes
fctl admin reserve home me                 # a name that makes one gets a random ending instead: home-829d34
fctl admin unreserve home                  # new workspaces and projects take it again
fctl admin runners                         # with their ids and images; draining ones say who drained them
fctl admin drain studio-mac                # no new sessions start on it (name or id)
fctl admin undrain studio-mac
fctl admin audit                           # what happened on the instance, newest first
fctl admin settings                        # what the instance allows and requires
fctl admin set --publish-screenshots on    # projects may publish screenshots
fctl admin set --require-two-factor on     # everyone who signs in with a password needs it
fctl admin set --two-factor-google on      # Google sign-ins ask for codes too
fctl admin set --verify-sensitive-actions on   # sensitive actions take a passkey or a code (the primary instance owner)
fctl admin set --gravatar off              # nobody's Gravatar: fctl removes the copies and looks nothing up
fctl admin set --export-interval 1d        # people export their data once a day (once a week by default; off: at any time)
fctl admin set --service-account-consent off   # service accounts act for anyone in their workspace, without asking (on by default)
fctl admin set --members-create-workspaces off # only instance admins create workspaces (on by default: everyone)
fctl admin set --max-workspaces 50         # each person can be in 50 workspaces (5 by default; any: any number)
fctl admin set --max-snapshot-mb 500       # sessions' snapshots up to 500 MiB each (200 by default, 2048 at most)
fctl admin set --snapshots off             # no workspace keeps sessions' snapshots; those kept go within the hour
fctl admin set --claude-oversight readiness   # the most workspace admins see of members' Claude connections (details by default, or off)
fctl admin set --claude-limit-pauses off   # workspace admins don't see how often members' sessions paused on usage limits
fctl admin set --claude-instance-view on   # instance admins see everyone's Claude connection (off by default)
fctl admin set --claude-refusals 1         # mark a long-lived token ended the first time Claude refuses it (2 sessions by default, at most 5)
fctl admin claude                          # everyone's Claude connection, with their address, where --claude-instance-view is on
fctl admin claude --problems               # …only those whose sessions can't run, or whose token runs out within 30 days (--expiring 14d, --json)
fctl admin set --self-sign-up off          # signing in makes no account: only invitations, allowed addresses and admin tokens do
fctl admin sign-in                         # the providers, the domains that require one and whom each covers
fctl admin sign-in require acme.com acme.dev   # their people sign in with Google alone: says whom it concerns, then asks
fctl admin sign-in require acme.com --passkeys --yes   # passkeys alone sign them in too; without asking
fctl admin sign-in unrequire acme.dev      # its people sign in as they like again
fctl admin sign-in policies                # how long sign-ins last, and who makes access tokens
fctl admin sign-in policies --browser-max 12h --browser-idle 1h   # browsers sign in again after 12 hours, and out after an hour unused
fctl admin sign-in policies --cli-max 30d --token-max 90d --member-tokens off --yes   # says what it ends at once; without asking
fctl admin sign-in policies --networks 203.0.113.0/24,2001:db8::/32   # sign-ins and requests only from these ranges (`any` for anywhere)
fctl admin unlink grace@example.com        # her Google account was recreated: signs her out, and her next Google sign-in links the new one
fctl admin reset-two-factor grace@example.com   # they lost their phone and recovery codes
fctl admin reset-link grace@example.com    # a link that sets their password (emailed to them where the instance sends email)
fctl admin tokens                          # admin tokens, where the instance takes them
fctl admin tokens create "Okta provisioning" --days 365   # prints it once
fctl admin tokens revoke "Okta provisioning"
```

`fctl admin sign-in require` prints what the change does before it
asks, on stderr, so that `--json` leaves stdout to how people sign in
once it's saved: whose passwords and passkeys stop working, who signs in
with the provider already, and who keeps a way in while it is down (the
primary instance owner). It saves nothing that would sign you out: sign
in with the provider first (`fctl login`, then continue with Google as
your address there). A CLI whose sign-in a domain's rule doesn't meet
says so, and signs in again with `fctl login`
([Requiring Google for your domains](https://fctl.sh/docs/self-hosting.md#requiring-google-for-your-domains)).

`fctl admin sign-in policies` takes durations as `12h`, `30d` or `none`
(no limit): whole hours for browsers' `--browser-max`, whole days for
`--cli-max` and `--token-max`, and 5 minutes to 30 days for
`--browser-idle`. Like `require`, it prints what saving ends at once
before it asks ("Saving signs out 14 browsers and 3 CLIs at once…"), and
`--json` prints the policy once it's saved
([How long people stay signed in](https://fctl.sh/docs/self-hosting.md#how-long-people-stay-signed-in)).
A CLI signed in longer than the policy lets one says so, and signs in
again with `fctl login`. `--networks` takes CIDR ranges separated by
commas, or `any`; it says whether your own address is in them before it
asks ([Signing in only from your
networks](https://fctl.sh/docs/self-hosting.md#signing-in-only-from-your-networks)).

### Provisioning people with an admin token

Where a self-hosted instance's deployment turns them on
(`FCTL_ADMIN_TOKENS=1`, [Self-hosting](https://fctl.sh/docs/self-hosting.md#provision-people-with-admin-tokens);
never on app.fctl.sh), an instance admin makes admin tokens, and a script
or your identity provider creates people's accounts with one, sets their
names, address, commit email, picture and Claude token, and adds them to
any workspace and project. With the token as `FCTL_TOKEN`:

```sh
export FCTL_TOKEN=fctl_adm_…
fctl admin users create ada@acme.dev --given-name Ada --family-name Lovelace
echo "$PASSWORD" | fctl admin users create grace@acme.dev --given-name Grace --family-name Hopper --password-stdin
fctl admin users show ada@acme.dev         # their workspaces, projects and Claude token (never the token itself)
fctl admin users set ada@acme.dev --email ada.lovelace@acme.dev   # their primary address; the old one stops signing in
fctl admin users set ada@acme.dev --family-name Byron --preferred-name Ada --commit-email 1234+ada@users.noreply.github.com
fctl admin users set ada@acme.dev --avatar ada.png   # or --avatar none
echo "$SETUP_TOKEN" | fctl admin users set ada@acme.dev --claude-token - --claude-label "Acme seat"   # or --claude-token none
echo "$SETUP_TOKEN" | fctl admin users set ada@acme.dev --claude-token - --claude-made-at today   # the day claude setup-token made it: it runs out a year on
fctl admin users add ada@acme.dev -w acme -w platform:admin -p web:editor -p api:maintainer
fctl admin users remove ada@acme.dev -p api -w platform
fctl admin disable ada@acme.dev            # stops their sessions; then
fctl admin delete-user ada@acme.dev --confirm ada@acme.dev
```

The token acts as the admin who made it, on the people endpoints of the
admin API alone, until it expires, someone revokes it, or they stop being
an active admin. It changes no roles, nor the primary instance owner's
account, and only the primary instance owner's tokens change admins'.
`--claude-token -` reads the token from stdin, so that it stays out of
your shell's history. Setting the same token again keeps the day it runs
out; without `--claude-made-at`, a new one runs out around a year after
it was set. A new account has no password until someone sets
one: `--password-stdin`, or the link `fctl admin reset-link` makes, which
works for an hour. Where the instance has Google sign-in and Google hosts
the address (Google Workspace or Gmail), the person's first Google
sign-in links Google to the account instead.

A new workspace or project takes the slug its name makes, and when
another has it or it is reserved, that slug with a random ending of six
hex digits (`home-829d34`). fctl reserves the slugs its own pages use
(`new`, `admin`, `settings`…), and `fctl admin reserve` holds more for
later; a new instance holds none. Nobody chooses a reserved slug with
`--slug`, and the workspaces and projects that have one already keep it.

`fctl admin users` says when each person was last active: when they last
signed in in a browser or started a session themselves, on the web, with
the CLI or by handing fctl a Linear ticket (the sessions review agents,
schedules and limited access tokens start don't count).

It also says who has two-factor sign-in. With it required, the command
that requires it lists who hasn't set it up yet: until they do, they can
only set it up, in the browser or with `fctl account two-factor enable`,
and their other requests fail.

Where the instance takes requests for early access (as app.fctl.sh does),
`fctl admin early-access` lists the people who asked on the sign-in page
and have no account yet, those waiting longest first, then those invited
and whether their link still works. `fctl admin invite` with their address
answers one: it prints their link, and the request shows as invited.

`fctl admin audit` and `fctl workspaces audit` show 100 entries at a time;
`--before` with the time after "Older:" (`next_before` in `--json`) shows
the ones before them.

## Your account

```sh
fctl account emails                        # your addresses, their commit emails and workspaces
fctl account set --avatar me.png           # your picture (PNG, JPEG, GIF or WebP; --avatar none for your initials)
fctl account set --gravatar off            # your initials, not your Gravatar, while you have no picture (on by default)
fctl account set --avatar none --gravatar on   # your Gravatar instead of your picture
fctl account set --preferred-name "Carl Oscar"   # what agents call you ("" for your first names)
fctl account set --commit-email 1234+ada@users.noreply.github.com      # your primary address's
fctl account set --for ada.lovelace@acme.example --commit-email ada.lovelace@acme.example
fctl account set --commit-email ""         # commits stop crediting you
fctl account primary ada.lovelace@acme.example   # where fctl writes to you
fctl account disconnect ada@private.example      # it stops signing in; you leave its workspaces
fctl account export                        # your data as JSON: fctl-export-<date>.json (once a week)
fctl account export -o - | jq .sessions    # or print it
fctl account delete                        # shows what goes, asks for your email address (--confirm EMAIL without a terminal)
fctl account linear                        # who fctl knows you as in Linear workspaces
fctl account linear connect                # opens Linear's sign-in; what you delegate there runs as you (--no-browser prints the link)
fctl account linear disconnect acme
fctl account slack                         # who fctl knows you as in Slack workspaces
fctl account slack link                    # opens Sign in with Slack; what you ask fctl's app there runs as you (--no-browser prints the link)
fctl account slack dm-project web          # your messages with fctl start sessions in web (--ask: choose each time)
fctl account slack unlink acme             # what you ask fctl's app there starts nothing
```

Linking a Linear account reads who you are there and revokes the sign-in
at once: fctl keeps your Linear id, name, address and avatar, not a
token. Each Linear account links to one fctl account, and an fctl account
to one Linear account in each Linear workspace.

Linking a Slack account is a Sign in with Slack: fctl reads who you are
there, keeps your Slack id, name, address and avatar, and revokes the
sign-in at once. Each Slack account links to one fctl account, and an fctl
account to one Slack account in each Slack workspace; `fctl account slack
link acme` signs in to that one. Both linking accounts take confirming
it's you where the instance asks for that. Where an instance and a
workspace let fctl know people by their address in Slack, `fctl account
slack` says which of your accounts it matched that way.

Two-factor sign-in takes a code from an authenticator app after your
password, and after Google if you choose:

```sh
fctl account two-factor status             # what you have, and what the instance requires
fctl account two-factor enable             # prints a QR code, asks for the app's code, shows recovery codes
fctl account two-factor enable --code 123456   # replace your app: a code from it, or a recovery code
fctl account two-factor recovery-codes     # ten new ones; the old ones stop working
fctl account two-factor rename 1Password   # name the app after the one that keeps it ("" goes back to Authenticator app)
fctl account two-factor google on          # Google sign-ins ask you for a code too (off asks to confirm it's you, and emails you)
fctl account two-factor disable            # asks for a code (not while the instance requires it)
```

`2fa` is short for `two-factor`. Without a terminal, `enable --json` prints
the setup (the key, the `otpauth://` link and the QR code's rows), and
`fctl account two-factor confirm --setup … --code …` finishes it.

Where the primary instance owner turns it on, sensitive actions (inviting
and promoting admins, turning two-factor sign-in or codes on Google
sign-in off, adding or
registering a runner for a workspace (`fctl host install` too), new access
tokens, connecting a Claude subscription, exporting your data, and deleting accounts,
projects and workspaces) ask you to confirm it's you first. In a terminal
fctl asks by itself, and then does what you asked: for a code from your
authenticator app, or, with a passkey, to approve a code in the browser,
as `fctl login` does. The CLI is then confirmed for 15 minutes. Without a
terminal, confirm first:

```sh
fctl account verify                        # asks for a code, or opens the browser for your passkey
fctl account verify --code 123456          # a code from your authenticator app, or a recovery code
```

Passkeys sign you in with your fingerprint, face or screen lock. Your
browser makes them, in Settings → Security; the CLI lists and manages them:

```sh
fctl account passkeys list
fctl account passkeys rename "Chrome on macOS" "Studio laptop"   # by name or id
fctl account passkeys remove pky_01…
```

Agents call you by your first names, all of them, unless you choose
another name for them to use, in Settings → Profile or with
`--preferred-name`. The agents of the sessions you start are told it, and
so is an agent each time you write to a session someone else started;
fctl's replies to you in Linear and the Agent Floor's greeting use it too.
A session you started takes a new name when it next starts or resumes;
`fctl whoami` shows the one agents use.

Each address is invited to the instance on its own; open an invitation
while signed in to connect its address to your account (the web app asks).
Every address signs in, and each has its own commit email: the commits in a
workspace's sessions credit the one of the address you joined it as.

With a commit email, the commits in the sessions you start end with a
`Co-authored-by` trailer that has your name and that address, for everyone
who can read the repository. Use an address your GitHub account has, such
as its noreply address (GitHub → Settings → Emails), so GitHub links the
commits to you. A project's maintainers can turn this off for its sessions
(`fctl projects set --credit-people off`). Sessions take a change when they
next start or resume; `fctl whoami` shows the address.

The export holds your account, sign-in methods and two-factor sign-in
(without the authenticator app's secret or the recovery codes), passkeys,
devices and tokens, Claude connections (without their secrets, with
their plan usage, when Claude last answered each and when it runs out,
and 30 days of limit pauses and refusals), notification settings and browsers, addresses, workspaces, and from the
workspaces open to you the projects you are a member of, the sessions you
started with their transcripts and the sessions you follow, and your
activity log. An export reads all of it, so the instance allows one a
week, unless its admins chose another wait (`fctl admin set
--export-interval`); `fctl whoami` and Settings say when you can export
again, and one that fails on the instance's side doesn't count. Deleting
your account deletes all of that and the workspaces only you are in;
sessions you started in shared workspaces stay there, credited to a
deleted user, and the workspaces you are the primary admin of pass to
their longest-standing admin. Settings in the web app has both, the
deletion in its danger zone.

## Updating

```sh
fctl self update             # to the latest release
fctl self update --check     # is there one?
fctl self update --version 0.1.2
```

It downloads the release for this machine, checks its SHA-256, replaces
`fctl` (and the Linux agent next to it), restarts a host service on the new
version (sessions keep running) and refreshes installed completions.
`FCTL_DOWNLOAD` points it at another release server.

Installed with Homebrew (`brew install hyperstructure/tap/fctl`)? Update with
`brew upgrade fctl` instead; Homebrew owns those files.

A runner's host updates itself to the version the control plane runs, unless
its `host.toml` turns that off ([Hosts](https://fctl.sh/docs/cli.md#hosts)). The web app's Agent Floor
says when a runner of yours is online with an older fctl than the control
plane and doesn't update itself, and shows this command.

## Shell completions

The installer sets up tab completion for your shell. To do it yourself:

```sh
fctl completions --install           # zsh, bash or fish, from $SHELL
fctl completions zsh > ~/.zfunc/_fctl  # or print them: bash, zsh, fish, elvish, powershell
```

`--install` writes the script under `~/.local/share/fctl/completions` (fish:
`~/.config/fish/completions`) and adds a marked block once to the end of
`~/.zshrc` or `~/.bashrc`. Bash on macOS starts as a login shell, which reads
only the first of `~/.bash_profile`, `~/.bash_login` and `~/.profile` that
exists, so the block goes in that file (a new `~/.profile` if there is none).
Delete the script and the block to undo it.

## Exit codes and output

Commands exit with 0 when they succeed, 1 when they fail (the API refused,
the network failed, there was nothing to do) and 2 when the command line is
wrong (an unknown flag, a missing argument). Errors go to stderr as text,
`error: …`, with `--json` too. With `--json`, results go to stdout as one
JSON document, in the shapes of [the HTTP API](https://fctl.sh/docs/api.md); `fctl logs --json`
prints one event per line instead, with `-f` or without.

What waits for you, which matters in scripts and agents' tool calls
([fctl for agents](https://fctl.sh/docs/agents.md)):

- `fctl run` without `-d`, and `fctl attach`, follow the session until you
  press Ctrl-C, also once it has stopped. `fctl attach --read-only` and
  `fctl logs -f` return at once only for a session that had already stopped
  or failed when they connected.
- `fctl run`, `fctl send` and `fctl schedules add` without their text read
  it from stdin, to its end, when stdin isn't a terminal.
- Deleting a project, a workspace or an account asks you to type its slug,
  name or address; without a terminal, `--confirm` takes it. `fctl host
  uninstall` asks before it stops running sessions; without a terminal, it
  needs `--wait` or `--force`.
- Where the instance asks for it, sensitive actions ask you to confirm it's
  you; without a terminal, they fail until `fctl account verify` has.

Environment variables: `FCTL_SERVER` and `FCTL_TOKEN` (in place of the
instance and token `fctl login` saved), `FCTL_CONFIG_DIR` (in place of
`~/.config/fctl`), `FCTL_RUNNER_TOKEN` (`fctl host install --token`),
`FCTL_DOWNLOAD` (the release server `fctl self update` downloads from),
`FCTL_LOG` (what it logs to stderr, such as `debug`) and `NO_COLOR`.
