/session-flow:continue-in-background [--unattended] [--cloud] [file|prompt] [topic] [purpose...]from session-flow
Delegates the current task to a fresh background Claude agent (--bg or --cloud) from a save-point. Only activates when the user explicitly requests background continuation.
Ships in session-flow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Arguments. [--unattended] [--cloud] [file|prompt] [topic] [purpose...]. e.g., /continue-in-background, /continue-in-background prompt, /continue-in-background file phase-3 finish the migration unattended, /continue-in-background --cloud prompt fix-flaky-test
Take session-id, branch, status, and recent-commits at -5. Probe commands, the
one-command-per-call and treat-failure-as-unknown rules, and the $-expansion rationale:
${CLAUDE_PLUGIN_ROOT}/reference/gather.md.
This block only colors the save-point; nothing here is the dirty-tree gate. That gate runs its
own commands at delivery step 1 and reads a git failure as a reason not to launch, never carry this
block's shrug, or its non--uall git status output, into it.
The user is stepping away but the work should keep moving. This skill produces the same save-point
the sibling /session-flow:handoff skill produces, then, instead of asking the user to
/clear-and-paste, launches a fresh background agent seeded with the resume prompt, so the task
continues now, detached from this session and from the user's presence.
Same save-point engine as handoff, different delivery: handoff delivers a manual
/clear-then-paste resume for later; this skill delivers a background continuation for now.
Launching a detached session is a side effect the user must have asked for. Launch only when the
user explicitly requested background delegation: they invoked this skill by name, or asked in words
("continue this in the background", "keep it moving while I'm away"). Never self-elected: the user
merely going AFK, context being heavy, or this skill being model-invoked on a description match is
not authorization. When invoked without that explicit request, produce the save-point, emit the
rails resume prompt with the standard /clear-then-paste instruction, state that no agent was
launched because background delegation was not explicitly requested, and stop. The user can ask
for the launch or run /session-flow:continue-in-background themselves.
$ARGUMENTS carries [--unattended] [--cloud] [file|prompt] [topic] [purpose...], all optional,
the non-flag tokens positional. --unattended, anywhere in the arguments, is the caller declaring
that nobody is present (it governs the offer under "Boundary") and is consumed first; the bare word
in a purpose is purpose text. A leading --cloud selects the cloud delivery below and is consumed before the rest parses. The
rest has the same semantics as handoff: method (file | prompt) recognized only as the first token,
otherwise auto-detect; topic is the kebab slug for the save-point filename, inferred when omitted;
everything after the topic token is optional natural-language purpose text ("what will the next
session be used for?"), no quoting, no new syntax, invocations without it parse exactly as
before, and its emphasis-only tailoring rules are owned by the engine doc ("The purpose argument
tailors emphasis only"). Parse purpose from $ARGUMENTS in place, never pre-compute. Before the
resolved topic is embedded anywhere (filename, --name flag), sanitize it to [a-z0-9-] only,
strip or replace every other character, so a crafted slug cannot smuggle quotes or extra flags
into the launch command. Purpose text is never embedded in the launch command at all. It shapes
the save-point's content, and the agent receives only the /goal payload.
The save-point machinery, destination resolution, locating the position, full-vs-prompt-only
choice, the mandatory redaction pass, the handoff-file write, and the rails resume prompt, lives
in the shared engine doc
${CLAUDE_PLUGIN_ROOT}/reference/save-point.md.
Walk it top to bottom; do not restate or improvise any of its steps. On the full path the file is
the shape new writes: save_point.py validate <file> must exit 0 before anything launches (an
unfinished skeleton, one still carrying <!-- FILL slots, fails there and cannot be launched
from).
When the request asks to carry what an earlier handoff in the handoffs directory says, read that
section by name with save_point.py read <file> --section "<name>", which follows a section moved
to the archive file, and put what it holds into the save-point.
When the request names a topic rather than a section, also read the Observations section that way, or open each - Moved: pointer's archive file with Read, before you report the handoff says nothing on that topic.
The launched session has its own session id, so hand it this session's worktree claims exactly as
the sibling handoff skill's "Hand worktree claims to the resuming session" does. On the full
path the payload ends at the Read @ directive, so the file carries the handover: the Environment
to re-establish entry and the first item of Remaining actions, in order. Confirm both by name
with save_point.py read <file> --section "<name>", never by position, so every handoff shape
reads alike (structure.md "How this document is
referenced elsewhere"). On prompt-only the first
remaining-work bullet carries it, in the resume region the payload includes. Either way the
successor runs the handover before check-enter. --cloud skips it: the cloud session has no
local worktree to re-lock.
No one is present to say the work is done, so the launched session starts only with a checkable
completion condition, armed as its /goal. Settle it while producing the save-point:
/goal is active in this session) → the save-point's goal region holds the condition the
launch arms. A checkable done condition the user states in this invocation ("done when …")
is a fresh-goal request: it lands here, with no draft and no confirmation round. When the goal is active here, the report tells the user to run /goal clear in
this session, which otherwise keeps starting turns after the stop. When the engine doc's
condition check ("Check the condition before emitting the region") warns that the condition
is conversation-bound, or omits the region because the goal is already met, that condition is
not launched: redraft it as case 2 drafts one and take case 2, or take
case 3 when no checkable condition is left. Either way the report still advises /goal clear
for the goal active here./planning:draft-goal-condition (if enabled) (otherwise draft inline a condition the transcript can
demonstrate, and say once that the planning plugin would pick the repetition lever and check
the draft against the documented condition limit) and write the save-point with it as a fresh
goal; its on-screen goal region is the display.
Then ask the user to confirm the launch, and launch only on a yes: the request made over that
condition is their approval to arm it. No answer this turn → no launch./goal, or the draft cannot pass
its counter) → write the save-point without a goal region and do not launch. Say that a
background run needs a completion condition and that the user can rerun
/session-flow:continue-in-background with the done condition named in the request. Fall
back to the /clear-then-paste instruction.The launch payload is /goal, a space, then text taken from the emitted prompt, never retyped:
Type /goal
instruction) of save_point.py emit <file>. It ends with the resume region's Read @
directive, so the agent reads the handoff file in the turn the goal arms./goal and its space stays within
the goal-region limit the engine doc states, counted with wc -m <prompt-file> less those 6
characters, never estimated; over it, do not launch, and fall back with the full path (file)
named as the fix.We rely on a background launch arming the whole multi-line payload as its goal, which our probe observed.
Output order: position panel, then the rails prompt, then the launch report. The panel (engine
doc, "Emit the position panel") leads; the operator is walking away while an agent keeps working,
so the one thing they should not have to reconstruct is where the work stood when they left. It is
screen output only: the launched agent receives exactly the /goal payload and never a line of
the panel, which keeps it identical to the goal-region paste a person would make.
The rails prompt from the engine doc is still emitted before the launch (transparency + manual fallback), then:
Dirty-tree gate. First establish there is a tree to inspect, with
git rev-parse --is-inside-work-tree in the consuming project. Exactly two results are
specified, and everything else falls through to a deliberate default:
true → there is a work tree; inspect it with the gate below.WorktreeCreate hook is
configured (https://code.claude.com/docs/en/hooks#worktreecreate) → there is
no uncommitted work to protect and no worktree isolation to lose, since we treat
background sessions there as editing the working directory in place
(https://code.claude.com/docs/en/agent-view#how-file-edits-are-isolated) →
launch, and state both in the launch report. That hook is the isolation path for non-Git source control, so a configured one,
or an absence you cannot establish, puts the launched session in a workspace this
checkout's local changes never reach: that is the default branch below, not this one.PATH), and also a successful
false. Inside a bare repository or inside a .git directory, where the command exits 0
and there is no work tree to inspect.Never route by exit status alone. A non-zero exit is not evidence of "no repository", and a zero exit is not evidence of a clean tree; both readings put dirty trees on the launch path, which is how a gate that exists to protect uncommitted work ends up failing open. Only the two identifications above may leave the default branch.
Inspect the tree with git status --porcelain -uall in the consuming project (-uall
lists files inside untracked directories individually; the default collapses a brand-new
handoff directory into one directory entry, which both defeats the exemption below and can
hide other dirt behind it) and ignore save-point files under the handoff location, the
just-written one and any prior sessions', with the shape-3 archive files under its archive/
subdirectory counted as save-point files (this skill never commits them; they are
session-chain artifacts, part of the launch rather than disqualifying dirty state; the
background session starts in this working directory, so it reads the handoff file before any
edit moves it into a worktree). Before judging other changes, read the effective
worktree.bgIsolation (below). Unless it is none, we treat a background session as editing
in an isolated worktree, a fresh checkout, so other uncommitted changes in this checkout would
not carry into the launched agent's edits (pointer, for when isolation applies and when it is
skipped: https://code.claude.com/docs/en/agent-view#how-file-edits-are-isolated). Any
such changes → do not launch: report why and fall back to the standard /clear-then-paste
instruction (same checkout, dirty state intact), noting the user can commit or stash and
re-run /session-flow:continue-in-background. Exception: launch anyway when the current session already
runs inside a linked git worktree, where isolation is skipped per the same page.
worktree.bgIsolation. Read it with jq from the settings files, first file that sets
it wins across tiers: managed settings (the managed settings file and its managed-settings.d
drop-in directory, where they exist on this machine), then the project's
.claude/settings.local.json and .claude/settings.json, then ~/.claude/settings.json.
Within the managed tier, do not assume first match: read the file-versus-drop-in and
drop-in-versus-drop-in order, and where each lives, from the managed settings pointers
below, and apply it. Managed settings delivered another way, or from a location this
read cannot find, are not covered: say so in the launch report. A --settings value cannot be
read from files either, so whenever a launch report is written, say the read covered the files
only. none is the value that turns isolation off; the pointer says what it does. When the value is none,
the "would not carry" refusal does not apply, since the launched session sees the uncommitted
changes: launch, and state in the launch report that the background session edits this
checkout in place, alongside the user, so both may touch the same files at once; this holds
inside a linked worktree too. Any other
result, including a file that does not parse, leaves the gate above unchanged. The --cloud
variant below ignores this setting. Pointers:
https://code.claude.com/docs/en/agent-view#how-file-edits-are-isolated.
Settings precedence (scope order): https://code.claude.com/docs/en/settings#settings-precedence.
Managed file locations:
https://code.claude.com/docs/en/managed-settings#where-each-mechanism-stores-the-policy.
Managed file and drop-in merging:
https://code.claude.com/docs/en/managed-settings#how-claude-code-combines-managed-sources
and https://code.claude.com/docs/en/managed-settings#split-a-file-based-policy-across-teams.
Launch from the consuming project's root, passing the /goal payload verbatim as one argument.
For Claude launch options, see the CLI reference.
First write it, as the completion condition gate defines it, to a temporary file with the
Write tool (never inline it in the command: prompt content is
untrusted session text, and any inline embedding, a heredoc, an escaped string, hands crafted
content a path out of the quoting and into the shell). <topic> = the resolved, sanitized
topic slug (argument or inferred); when none resolves, use resume:
cd "${CLAUDE_PROJECT_DIR}" && CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 claude --bg --name "continue-<topic>" --permission-mode auto "$(cat "<prompt-file>")" && rm -f "<prompt-file>"
Insert --effort "<level>" before the prompt argument when "What the launched session
inherits" below calls for it.
Plugin profile. Invoke
/plugin-profiles:profile launch --json (if enabled) via the Skill tool, naming the profile only when
the user named one (no name takes this session's own) and adding --unattended when this run
is unattended. Replace claude in the command above with its argv words (its command field
is them, shell-quoted), keeping every argument after it, and name the profile in the launch
report along with any prerequisitesMissing. A refusal is a launch failure (step 4). When the
skill is not available, launch the command above unchanged.
--permission-mode auto is always passed, following the marketplace's rule to launch
unattended local lanes with --permission-mode auto (loop-lane convention, "Permission
modes"). We rely on one denied
action not stopping the launched session, which our probe observed: the denial came back to
the model as a tool error, the session went on to its next step and ended its turn with no
prompt, and the denial was in its transcript and claude logs output, reaching the final
hand-off only because the task asked for a per-step report. Whether a detached session can
still stop on a prompt after auto mode falls back is unverified: the probe made one denial and
did not exercise the fallback.
The launch report says auto mode may deny an action, that the session keeps going past a
denial, and that a denial is in the session's transcript and claude logs <id>, reaching the
final hand-off only when the resumed task reports it; it never promises the final hand-off.
claude --bg starts the session as a background agent and returns immediately; the user
manages it with claude agents. This launch runs from a Bash-tool subprocess, so always set
CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1, which keeps the session in the claude agents list
(pointer: for how nested sessions are listed, the CLAUDE_CODE_CHILD_SESSION and
CLAUDE_CODE_FORCE_SESSION_PERSISTENCE rows of
https://code.claude.com/docs/en/env-vars#variables). Awareness note: the prompt
travels in the process argument list, so it is briefly visible to other local processes
(ps), inherent to claude --bg "<prompt>". The mandatory redaction pass has already
scrubbed the prompt by this point; this exposure is one more reason secrets never belong in
save-point output on any path.
Report the launch result: the command's output, the agent name, the claude agents
management hint, any launched-session behavior the resumed work depends on (next
section), and the denied-action statement step 2 defines, never a promise of the final
hand-off. Verify the agent actually appeared. A zero-exit launch can still be invisible if
the persistence override is ever unrecognized. Confirm with
claude agents --json --all, taking the entry whose id is the short id the launch printed,
and report its full sessionId; with no such entry, tell the user explicitly: "confirm it
appears in claude agents". The /clear-then-paste instruction is replaced by this report.
The user no longer needs to paste anything. claude --bg ignores --session-id and picks the
id itself, so this listing is the only source of the full id.
Launch failure → fall back, never block. Non-zero exit (e.g. the installed Claude Code
predates --bg) → report the error and fall back to the standard /clear-then-paste
instruction. The save-point already exists; nothing is lost.
Stop. The background agent is the continuation; this session terminates the task. Do not
monitor, poll, or babysit the launched agent, and do not start new work items. Invoked by
another skill through the Skill tool (step-away's fresh session), return the full sessionId
to it instead, or say none was found; that skill finishes its own steps this turn.
When this session has a tool that starts another session (the Claude desktop app's Code tab) and
--cloud was not given, read
${CLAUDE_PLUGIN_ROOT}/reference/sibling-session-delivery.md,
"Background continuation", and deliver there instead of steps 1 to 3 above: our decision is to
prefer the app's own session there. A start that is refused or fails takes steps 1 to 5 above.
Without such a tool, skip that file.
--cloudOnly when the user's own words asked for a cloud session and --cloud is given: read reference/cloud-delivery.md.
The launched agent is a new session, not a fork of this one. What it inherits is upstream behavior; the rules below are ours, built on it.
Our rules:
CLI configuration is not inherited. It carries none of the current session's CLI flags
(e.g. --mcp-config, --settings, --add-dir, --plugin-dir). Mirror onto the launch
command any such flags the resumed work depends on, and say so in the launch report. A plugin
profile's --settings comes from the launch step's "Plugin profile" paragraph; with a profile,
a mirrored --settings value goes to that launch as --with <value>, which merges both into one
file, never as a second flag.
Model and effort are not inherited from the current session's in-conversation choices.
They resolve from the launch command's own --model / --effort flags and, absent those,
from the settings of the directory it starts in (project/user settings, including env
values such as ANTHROPIC_MODEL). When the resumed work depends on a specific model or
effort, pass the flags explicitly and note them in the launch report.
For resumed verify work, and for any task the launched session runs unattended, pass an
explicit --effort so the work does not silently run at the default. At launch, read
model-config's
Choose an effort level
table, pick the level whose described use fits the resumed task, and pass that level as
--effort "<level>" in step 2's command, before the prompt argument. A task that changes code or
verifies it is never given a level below medium: that is our marketplace's own effort floor,
which keeps low for chat-like exchanges and read-only mechanical work ("Effort floor" in
docs/plugin-philosophy.md in this plugin's marketplace repository). Skip any row the table
says is not an effort level.
The value is one level name of lowercase letters only, never free text, for the same reason
the topic slug is sanitized. The launch report names the level and quotes the matched use.
When the page cannot be read, say so, pass no --effort, and state that the session will start
at its default level.
--effort flag, see
Set the effort level.Permission mode is set at launch, not inherited. Step 2's command always passes
--permission-mode auto, so a directory setting with another default mode does not set the
launched session's mode.
Directory settings are read normally. The session reads its settings from the directory
it runs in, the same as a fresh claude started there.
Tick each item in the response so the user can verify the exit shape (in addition to the engine
doc's save-point items, which the sibling handoff skill's checklists mirror):
/clear-then-paste exit, no launch, reason statedPurpose: line between the rails, never discarded (the launched agent receives exactly
the /goal payload); a goal-conflicting purpose flagged rather than obeyed; never embedded in the
launch command. No purpose given → nothing to tickcheck-enter (or none held)git rev-parse --is-inside-work-tree first, then
git status --porcelain -uall when it says true, ignoring save-point files under the handoff
location; effective worktree.bgIsolation read before judging other changes, and none → launch with the
edits-this-checkout-in-place warning in the report (--settings tier named as not covered);
otherwise other uncommitted changes without the linked-worktree exception → no launch, reason
reported, fallback to /clear-then-paste. Positively identified as not a git repository and no
WorktreeCreate hook configured → launch, that reading stated in the report; any other
rev-parse result, failing or false, and any hook whose absence is not established → state
unknown, no launch, same fallback/goal clear advised
in the report), or one drafted as case 2 says, shown as the goal region,
and launched only on the user's yes to it; a conversation-bound or already-met goal never
launched as it stands, only redrafted (case 2) or left unlaunched (case 3); none → no launch, the message saying how to supply
one, fallback to /clear-then-pasteclaude --bg --name … --permission-mode auto), the payload being
/goal, a space and the goal region's between-rails text from save_point.py emit <file> on
the full path (validated first, exit 0 quoted), or on prompt-only the goal region then the
resume region, counted within the limit; and the launch result reported (including any non-inherited flags mirrored or worth
flagging, and step 2's denied-action statement: auto mode may deny an action, the session keeps going past a denial, which
is in its transcript and claude logs, not promised in the final hand-off, and the full
sessionId from claude agents --json --all, handed back to a calling skill), or the non-zero
exit reported with fallback to
/clear-then-paste--effort passed with the model-config table's level
whose described use fits the task, the report naming the level and quoting that use; page unreadable → said so, no --effort, and the report states the session starts
at its default level--cloud only: clean tree, fetched branch matching its upstream, prompt-only payload,
--effort passed as for --bg (CLI rejects it → relaunched without, /effort advised); the
report names the session id, the teleport and follow-up commands, and the signed-in account,
and says goal arming there is unprobed; a no-terminal refusal → local delivery, reportedThree built-in commands also keep work moving off this terminal, so "continue in the background" can mean any of them.
/subtask, /fork, /background (built-in commands): three ways to move work off this
terminal. None writes a save-point, and this skill never runs them. What each launches, its
alias, its gate and whether the model can invoke it: the records table in
native-surfaces § verification record.claude --bg session seeded only with the save-point's /goal
payload, so the continuation carries no conversation history, survives on disk, and ends on a
checked condition.Native suggestions are on unless native_suggestions resolves off: the team docs/conventions/session-flow.yaml value wins over the per-user value ${user_config.native_suggestions} (a literal unexpanded token means unset); with none set they are on. A value other than on or off is named and that layer dropped: a valid higher layer still wins, otherwise on, never a lower layer's value. When off, skip the offers below and write nothing in their place, not even a note that it was skipped or why.
Routing. At the start of the run, offer them to the person, each instead of or alongside this
skill. If /background is available in your session (gate basis: gated, per Availability is
never assumed below; records in native-surfaces § verification record) and native suggestions are on (native_suggestions, Configuration), you can run it to detach this session as it is. If /fork is available in your session (gate basis: gated, per the same paragraph and records) and native suggestions are on (native_suggestions, Configuration), you can run it to copy this session into a background session. If /subtask is available in your session (gate basis: gated, per the same paragraph and records) and native suggestions are on (native_suggestions, Configuration), you can run it for a side task whose result should come back here. Prefer this skill
when the continuation should start clean from a durable save-point. When the caller passes
--unattended, the run makes no offer and writes Withheld suggestion (unattended): /background, Withheld suggestion (unattended): /fork and Withheld suggestion (unattended): /subtask in the output; without that flag it asks.
Mutation gate. This skill writes the save-point and launches one session, only on explicit request. It never runs a native command on the person's behalf.
Availability is never assumed. All three are gated, and their behavior depends on the session's setup; read the gates live from the records table in native-surfaces § verification record. This section states what to do when they resolve, never that they are present.
Failure patterns are documented inline at the step that owns them: the -uall untracked-directory
collapse, the non-repo-plus-no-WorktreeCreate-hook vs. unknown split with its deliberately wide
unknown default, and the ban on reusing the context block's git output (dirty-tree gate, step 1;
context block), the no-inline-prompt rule and the session-persistence env requirement (launch
command, step 2), slug sanitization ("Arguments"), and non-inheritance surprises. Model, effort,
CLI flags ("What the launched session inherits").
handoff skill's /clear-then-paste shapeclaude agentsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
background-agent, detached-session, save-point, handoff, async-work
npx claudepluginhub melodic-software/claude-code-plugins --plugin session-flow20 skills in this plugin
/audit-frictionAudit frictionAudit Claude Code sessions for permission and autonomy friction (denials, approval prompts, hook blocks, hand-offs), traced to cause in one decision brief. Use when the agent keeps asking or handing off, auto mode denies, or re-measuring after permission fixes./audit-sessionsAudit sessionsAudit every Claude Code session on this machine or behind a pull request for wasted time and tokens against a baseline, routing findings to fixes, plus score trends over time. Use when: 'audit my sessions', 'which sessions burned the most tokens', 'retro this PR', trends, or repeating corrections. Not for one session: /session-flow:retro./clean-stopClean stopClean stop before the machine goes away: sweep every repo and worktree touched for uncommitted, unpushed or PR-less work, push it, and give a free-and-clear verdict. Use when: 'clean stop', 'safe to shut down', or stopping for the day. Gates destructive cleanup./find-handoffFind handoffRecover a lost handoff save-point or resume prompt after /clear, from the handoffs folder then recent transcripts, confirming before resuming. Use when: 'find my handoff', 'I lost the resume prompt'. A session that ended mid-work: /session-flow:keep-going./go-with-recommendationsGo with recommendationsAccept the agent's latest recommendations after re-grounding each in code/sources, surfacing changed or unconfirmable items; supports exceptions./handoffWrite a mid-session save-point for /clear-and-resume: a copy-paste resume prompt, plus a durable handoff file when the work needs one. Use when: 'handoff', 'checkpoint this', the session is heavy, or responses drift or loop. Background continuation: /session-flow:continue-in-background.Other plugins' skills for the same job