Workflow Modes (@gadhs/pi-modes)
A mode is a working style you switch with one keystroke: how capable the model is, how much it may do without asking you, and how carefully its actions are checked. Four modes ship — auto for normal development, plan for read-only investigation, manual when you want to approve every command yourself, and yolo when you want no checks at all.
Everything on this page is configuration, not code. If you want different models, different rules, or your own mode, see the configuration cookbook — most changes are a few lines of JSON.
The reference is split by feature:
-
The judge, the pending queue and the safety valve — what happens to a call no rule decides.
-
Workflow guards — the deterministic checks on every tool call.
-
The commit review — the cold read every commit gets.
-
Asking the human: ask and plan mode —
ask, plan mode and its approval. -
Helpers — checked results, the delegation gate, worktrees.
-
Tools — images, counting, monitors, jobs.
-
The session — guidance, compaction, the terminal.
-
Observability and diagnostics — what a session shows and records.
Who decides what
The design rule behind everything here: simple checks are done by simple code, instantly. A fast, separate AI model (the "judge") is consulted only when a pattern cannot decide — and it answers exactly one question: is this action dangerous? Whether your code is good, in scope, or what was asked for is reviewed by people, not by a model watching over your shoulder.
| Layer | Decides | Cost |
|---|---|---|
Workflow guards (first, before anything else) |
Commit message format, |
~1 ms |
Mode rules |
Routine commands ( |
~1 ms |
|
Actions you name (pushes to main, merges, publishes…) — these always stop and ask you, no model involved. Empty until you configure it. |
~1 ms |
Workspace-write stage |
Any |
~1 ms |
Outside-write stage |
Any |
~1 ms |
Model judge |
Whatever the rules could not decide, every compound bash line the plain-line stage did not clear among it: is the action itself dangerous? |
~1–5 s |
You |
Anything the layers above passed upward. In auto and plan it waits in a queue while the agent carries on, and you answer by typing in the prompt box (Waiting on you); in manual it is a dialog |
interactive |
What becomes an ask
Every layer above sees only asks: tool calls
@gotgenes/pi-permission-system did not settle from its own policy.
Under the seeded policy (First-run bootstrap) that is almost every
call: everything resolves ask except a helper’s own harness tools, and
the two path surfaces are allowed, so the path rules that matter are the
modes' own. Upstream releases that tighten the permission system’s path
and bash gates therefore change little here; they change what a config of
yours with its own path or bash rules decides. Since version 40 (from 27):
-
a path named as a
for/selectoperand or acasesubject is gated (31); -
a redirect’s target is checked against path rules even when the file does not exist yet (34);
-
a computed argument that may spell an option withdraws `find’s, `fd’s and `sort’s claim to be only reading (36);
-
reads under
~/.pi/agentskip the outside-the-workspace gate only for pi’s own entries (agents/,extensions/,npm/,skills/and the like), neversessions/,auth.jsonor the permission logs (39); -
a bash rule written with an absolute path also matches that path’s relative spelling (40), and commands inside
time ( … )are gated on their own rules (40.1); -
the path surfaces have read and write halves (
path_read,path_write, and the same forexternal_directory). The seed’s bare keys stand for both; a directional key of yours outranks them, andpolicy-diffwarns when one is left anything butallow.
Configuration resolution
-
$GADHS_PI_MODES_CONFIG— explicit path (CI, tests) -
<agentDir>/gadhs-pi-modes.json— per-user overlay, merged over the package baseline (agentDir=$PI_CODING_AGENT_DIRor~/.pi/agent) -
modes.jsonbundled with the package — the org default
Your personal overlay merges with the shipped defaults:
-
Cosmetic fields (model, effort, labels) simply override. A mode’s
judgeblock, when you give one, replaces the mode’s whole judge. -
Permission rules combine strictest-wins per pattern: where you name the same pattern as a shipped rule, the stricter action stands, so agency policy cannot be loosened head-on.
-
A more specific pattern of yours is kept as written, and it can carve an exception into a broader shipped
denywhen it refines it: the deny’s pattern matches yours, so yours names a subset of what the deny covers (/.ssh/known_hostsinside/.ssh/*, the cookbook’s recipe). Such a carve-out is named in a warning at session start. An allow that merely overlaps a deny, longer but not a subset, does not outrank it (#222).
Every block with a fixed key set refuses an unknown key by name at load:
the top level, each mode, guidance, subagentPolicy, each profile under
subagentPolicy.profiles, and the nested judge, title, shortcuts,
unattended, compaction and monitor blocks. modelRoles accepts only the known role names, mode:<id> for a declared
mode, and helper:<name> (#1040). The two maps keyed by names you choose
(permission, subagentPolicy.profiles) accept any key. Keys beginning with // are comments at the top level and
in a mode (not inside nested blocks).
The agency rules live inside the package, so updating it updates them; there is no copy on your disk to go stale.
Top-level config (ModesConfig)
| Field | Type | Default | Meaning |
|---|---|---|---|
|
boolean |
|
Apply `cycle[0]’s model/tools on a fresh session. Persisted modes are re-applied regardless. Either way the current mode’s tools are set at every session start, so a resumed session gets back a tool it lost while its extension was not loaded (#613); only the model waits for this switch. |
|
string | null |
|
Keyboard shortcut for cycling modes. (Shift+Tab is reserved by pi.) |
|
string[] |
shipped: |
Order for |
|
boolean |
|
Print the active mode + shortcut hint at session start. |
|
boolean |
|
A prompt naming an image file on this box sends the image with it — see
Dropping a file onto the terminal. |
|
number |
|
A session’s spend cap in US dollars (#276): pi’s own sum over the
session’s entries, the footer’s cost. The judge’s calls and helpers' runs
are in it already, since their cost rides on tool results. A mode’s own
|
|
boolean | path |
|
First-run seeding of the permission-system config. |
|
string[] |
the shipped patterns |
Patterns that stay interactive in every mode that does not declare its own list (auto and plan; yolo declares an empty one) — see The safety valve. |
|
string[] |
the shipped list |
Tools allowed by rule in every mode that has rules (auto, plan, manual),
filled into each mode’s |
|
string |
unset |
Operator override for the packaged global guidance digest (replaces it wholesale). |
|
object |
shipped profiles |
The delegation gate’s declared tool profiles per agent — see
The delegation gate: |
|
object |
see The monitor |
The monitor’s limits: |
|
boolean |
|
Keep the model you chose when switching modes, instead of the mode’s own (tuning, "Keep your chosen model when switching modes"). |
|
boolean |
|
The turn recap card under a finished turn — see The turn recap (tuning). |
|
string[] |
unset |
Helper types that run in a git worktree of their own (tuning). |
|
|
|
`generate_image’s default model (tuning, "Generate an image"). |
|
object |
none |
Per role, a |
|
string[] |
none |
Model sources (pi provider ids) in the order preferred for the same model,
such as |
|
boolean |
|
The working line’s own text; |
|
object |
|
The pending queue’s approve and deny keys and the hub’s, each a key or
|
|
boolean |
|
Check an install’s packages against their registry — see the registry check. |
|
number |
|
The registry check’s one deadline for all of an install’s names. |
|
number |
|
Warn before a request is larger than this, in MiB (tuning, "Warn before a request is too big"). |
|
number |
|
Leave the oldest images out of a request whose images pass this, in MiB (tuning, "Leave old images out of a big request"). |
|
|
|
The prompt-cache tier asked of Anthropic: five minutes, or the hour that writes at 2x input (tuning). |
|
integer |
|
The context files' size before a notice; |
|
object |
|
How long an ask waits on a host with no terminal before it is refused (tuning). Unknown keys are refused. |
|
object |
|
The model that summarises when the session’s own cannot, or |
|
object |
|
The terminal title, its progress bar, and when it nudges (tuning). Unknown keys are refused. |
|
ModeDescriptor[] |
four shipped |
The modes themselves. |
Per-mode config (ModeDescriptor)
| Field | Type | Meaning |
|---|---|---|
|
string |
Stable id and UI label. Required. |
|
|
Main-agent model applied on switch (composed-provider path, so Vertex/ADC models work). Omit to leave the model alone. |
|
|
Thinking effort applied with the model. |
|
string |
Written per turn as the |
|
string[] |
UX filter of exposed tools. Not enforcement — that is the
permission system’s job. A mode without one starts a session with every
registered tool pi declares by its exposure that can run on this platform.
pi’s |
|
|
Deterministic rules,
evaluated most-specific-wins ( Every allow the gate gives on a rule’s or its own stages' say stands back in
three cases, and the judge decides (#901, #923). The allows are a rule
* the action is one the safety valve names (above);
* it carries a secret-shaped value in its command, path, URL or query.
The values are those pi-workflow redacts from tool output: a provider’s
key, a token, a JWT, a private key. So a web fetch whose URL holds a key
goes to the judge, though web research is otherwise allowed by rule.
This check reads pi-workflow’s redactor, and adds nothing when
pi-workflow is not loaded. A write’s content never reaches the gate, so
for a write it reads the path;
* a file tool ( Three allows are not held: the delegation gate’s, since a spawn names an
agent rather than an action; the plan draft’s in plan mode, one file the
harness names; and your own approval of a step with The shipped bash rules ask, so the judge decides, on A bash line that is one command (redirects allowed) is matched as it
stands, plus path/value for file surfaces. Any other line — several
commands joined by The rules do not match a heredoc’s body (#264): a script fed on stdin that
only names a protected path is not refused as if it touched it. The same
path as a command’s word or a redirect’s target is matched as always, and so
is any quoted string. A body can be code ( A heredoc does not make a line one command (#284). tree-sitter nests the
rest of a heredoc’s line inside its redirect, so |
sh` meets the pipe-to-shell deny whatever follows the terminator (#402: a line after it stayed attached to the header, and the deny missed). In plan mode, a rule |
b |
c'`, A redirect is a write (#415). In every mode, its destination (the
redirect’s first word, one pair of enclosing quotes off, a relative one
read as *A path rule reads the file, however the path is spelled (#765). The
shipped path rules are written *On Windows a stream suffix does not hide the file (#767). NTFS reads
The write tool’s own path is held to where it really lands too (#502). A
path rule matched its text, and a link changes no text: The engine asks about a line’s first command only; pi-modes reads the
whole line from the ask’s evidence with the engine’s own parser. Until that
parser is warm (once, at session start), every bash line reads as
compound: no rule allow, the judge decides, and the deny rules, the valve
and the |
|
|
|
|
|
|
|
|
Left to the judge: a credential-shaped basename ( Both stages read a path the way pi’s tools do before judging it. A In a remote session (pi over SSH, #498) the session’s
directory is a local anchor holding none of the project. Both stages, and the
rule for a redirect’s destination, then ask the remote where a path really
lands, following symlinks where they are. A relative path, or one under the
anchor, is read as the remote path it stands for before any rule sees it.
So On a Windows client the permission system hands the gate its own canonical
path: resolved against the local drive and lower-cased. That spelling names
nothing on a case-sensitive remote ( A helper’s asks are forwarded to the parent session and decided there, so
this stage answers a helper’s in-tree reads; a headless parent serves
nothing, and a forwarded ask there is a blocked tool call. Any tool-input
preview the permission payload carries ( |
|
|
A line is plain when it holds only commands joined by A command is cleared one of two ways. A command outside the roster below
is cleared only when this mode’s rules allow its text, as they would
allow it alone: so a standing approval’s command now also runs behind a
* A file is readable when, followed through every symlink, it is inside the
session’s directory or the temp root, and its name is not
credential-shaped (the workspace stages' list), from every directory a
Left to the judge: a line any rule matched, a helper’s ask, a remote
session’s, a line the safety valve names, one carrying a secret-shaped
value in its text or its preview (#923, #901), and every line that is not plain or has a command not
cleared. |
|
string[] |
Patterns that always wait for you (queued, or a
dialog; see |
|
|
What happens to an ask the gate
cannot settle alone: a judge defer or failure, a safety-valve cap, a
high-consequence match, the loop guard. |
|
string[] |
Subagents this mode may delegate to, by name, or
|
|
JudgePolicy |
The model judge for |
|
number |
This mode’s spend cap in US dollars, over the
top-level |
|
boolean |
This mode authors a plan draft: the one file it
may write or edit, the per-cwd draft under the agent dir’s |
The shipped modes
| Mode | Model / effort | Rules | Workspace writes | Judge | Character |
|---|---|---|---|---|---|
|
Opus 5.5 / medium |
yes |
allow |
Sonnet 5.5 |
Implement end-to-end. Rules absorb the routine; the judge sees only the
ambiguous; writes in-repo are free; writes outside the repo and temp are
refused deterministically ( |
|
Fable 5.2 / xhigh |
yes |
— |
Sonnet 5.5 |
Investigate and design, change nothing. |
|
Opus 5.5 / medium |
yes |
allow |
none |
The human approves every ask personally. Same rules as auto, no model in the loop. |
|
Opus 5.5 / medium |
no |
— |
|
Auto-approve everything. yolo means yolo: no rules and no judge model — only yolo’s own valve list (empty unless you add to it) and pi’s structural gates remain. The workflow guards still run. |
Switch with /mode (a picker), /mode <id>, /mode next, or just press
F2. The status line always shows the active mode and what it is doing (what
waits on you, what the gate did, the helpers working, the monitors running,
the jobs watched, the agent messages collected and not yet read, the spend; each segment only
while it has something to say); when
something is blocked, a line appears in the transcript saying who blocked
it (a fixed policy, the judge, or a workflow check) and why — expand it for
the full reasoning and what to do about it. /gadhs-reset lists every
local tuning file in force and, with --apply, moves them aside so the
package defaults apply again (tuning).
Model roles: whichever source you have
Every model the distribution names fills a role (#715): each mode’s model, the judge and its fallback, the commit reviewer, the reviewer floor, the plan’s second reviewer, the helpers, the image tool and the summarizer. Each role has ordered candidates, resolved at each session start against the models pi can reach for you (those whose provider has a key or login):
-
the role’s own configured model first: a mode’s
model, pi-workflow’s reviewer, a helper’s agent file; -
then the same model through each source: Vertex, then pi’s own
anthropiclogin (an API key or a Claude subscription) orgoogle(AI Studio), which carry the same model ids, so the battery’s evidence holds; -
then the other vendor’s nearest tier, a substitute: Explore on Claude Haiku when no Gemini is reachable, say. Substitutes are unmeasured until the battery runs them.
A Vertex box resolves exactly as before, since every role’s first
candidate is the model it named. When any role resolved to something else,
the session starts with one line saying what and through which source:
models: judge: claude-sonnet-5-5 via anthropic; summarizer:
claude-haiku-5-5 via anthropic (substitute, unmeasured). /mode models
lists every role at any time.
With nothing reachable, a role does what it did before. A mode keeps the
current model, said once a session. The judge defers every ask to you. The
image tool refuses a call that names no model, saying what it tried. The
summarizer leaves compaction to pi. The image role has Vertex candidates
only: pi’s google provider has no image model under that id.
The helpers resolve in pi-agents (#715). Each managed agent file is
re-rendered at session start to the model this user reaches, its override
from gadhs-pi-agents.json or its packaged model first. The answer is kept
in gadhs-pi-agents.resolved.json and rendered at the next load, so an
unchanged box writes nothing. A substitute is named at start: "agency
agents: Explore runs on anthropic/claude-haiku-5-5, a substitute
(unmeasured): … is not reachable". A file you own is never written, and
with nothing reachable the file keeps its packaged model and the existing
warning says where pi-subagents will run it. pi-modes reads the agent files
again after a re-render, so the model lock and the helpers' pricing see the
model pi-subagents will run.
modelRoles replaces a role’s list outright, in its own order.
sourceOrder reorders the same-model tier by provider. It never lifts a
substitute above the role’s own model.
Scratch root
<repo>/.pi/scratch/ is the one place the working agreements name for a
file that is not part of the tree but must outlive the turn: a commit
message for git commit -F, a helper’s brief, a draft, a list to come back
to (#738). It is inside the checkout, so it sits on the repository’s own
filesystem - not a root filesystem the box’s notes rule out, not a /tmp
a reboot clears - the commit guard reads a -F file there as it reads any
file in the workspace, and a reviewer can be pointed at it with
Review-Context. It is text; a build never lands in it, and nothing
measures or prunes it for you.
At session start pi-modes writes one anchored line, /.pi/scratch/, into
the repository’s .git/info/exclude - git reads it as a .gitignore it
never commits - once, under a comment, and says so that session. A
worktree’s session writes the common repository’s file, so every worktree
shares the line; where git already ignores the root - an exclude, a
.gitignore, the global excludes, asked with git check-ignore - nothing
is written; outside a repository nothing happens; a failure is logged and
never fails the session. A remote session writes the remote checkout’s
file through the same seam. Nothing is created under the root until
something writes there, and the directory is the agent’s to make
(mkdir -p; the write tool makes it on the way).
A write there is allowed by rule (#747). The shipped policy holds a
project’s .pi as an ask on the write and edit tools, because pi loads
settings, agents and extensions from it; that sent every scratch write to
the judge, which answered both ways for one directory. pi loads nothing
from the scratch root, so in a mode whose workspace writes are allowed
(auto, manual) a write or edit that lands under the session directory’s
.pi/scratch/ is allowed with no model call, traced as scratch-root.
It is decided on where the write really lands, not on the path’s text:
.pi/scratch/../settings.json, a link in scratch that points elsewhere,
a .pi/scratch/ nested in some other directory or under the home, and
the root itself are not it — in-workspace misses are judged as before, while
targets landing outside the workspace and temp are refused in auto
(outsideWrites). A deny rule is
never overridden, a credential-shaped name, a path the safety valve names
and one carrying a secret-shaped value stay the judge’s, and plan
mode allows no write here as anywhere. The judge’s rubric names the
exception too, for a bash redirect into the root.
What is not in scratch: builds, which go to the repository’s gitignored build directory where every tree shares one cache, and helper worktrees, which stay in the temp directory and opt-in (A helper in its own git worktree). The default is the primary checkout, one unit at a time, on branches.
First-run bootstrap
On first load the extension seeds a minimal permission-system config (only when absent — never overwriting, even an invalid one):
{
"permissionReviewLog": true,
"authorizerChain": ["gadhs-mode-judge"],
"permission": {
"*": "ask",
"yield": { "*": "allow" },
"ask_parent": { "*": "allow" },
"notify_parent": { "*": "allow" },
"path": { "*": "allow" },
"external_directory": { "*": "allow" }
}
}
yield, ask_parent and notify_parent are a helper’s own harness
tools, settled in the child before anything is forwarded. yield is its
result submission: it validates the child’s result, writes it beside the
child’s transcript and ends the run. ask_parent records a question for
the agent that delegated and ends the helper’s turn; notify_parent sends
that agent a one-way update. pi-subagents gives both to every helper,
whatever its tools list says. None of the three reaches anything the
child could not already reach. Left at ask, each call would be
forwarded to the parent session: a judge call every time, and a refusal
under a headless parent, so a helper could not hand in its result or ask
its question.
This file is deliberately tiny: it just routes every permission question to
the mode system, which is where all the real policy lives (and updates with
the package): agency rules ship in modes.json and are enforced by the
extension’s authorizer, precisely so that policy reaches every developer on
update — anything written to disk is seeded once and never migrates. The
seeded file must also stay strictly schema-valid: a // comment key
silently clamps the entire permission config, chain included. If you have edited yours and want to know how it differs from
the current default, node tools/task.mjs policy-diff will tell you, and
--write will repair it (it asks first, adds what a later seed added, and
raises what you left looser; it never removes or relaxes a rule of
yours). A config seeded before ask_parent and notify_parent were
added needs --write to get them.
The same load seeds one key of pi’s own settings (#726): cacheWarming:
"idle" in ~/.pi/agent/settings.json, when no value is there. Up to pi
1.5.0 pi warms a prompt cache between runs only when told to (1.5.1 does
by default), and the between-run pauses were two thirds of a week’s spend
on one session. The key is added under
the lock pi takes on that file, so a save pi makes at the same moment
loses nothing; a value you set is never touched; the session says what it
wrote, once, and the value applies from the next start or /reload
(tuning).