Continue in background

From melodic-software/claude-code-plugins · View interactive version

Continue in background is an AI agent skill from the GitHub repository melodic-software/claude-code-plugins. Hand the task to a fresh detached background agent (claude --bg or --cloud) that continues it now from a save-point. Use when the user is going AFK and explicitly asks to 'continue in the background'. Launches only on that request, never self-elected.

How to use this skill

Skill file

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

Context. Gather first

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:

CODE0.

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.

Purpose

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.

Hard gate. Launch only on explicit user intent

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

$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.

Produce the save-point

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

CODE0.

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 (CODE0 "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.

Completion condition gate

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:

  1. A goal applies under the engine doc's goal-region rule (the user asked for a fresh goal, or

a /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.

  1. No goal applies → draft one from the remaining work with /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.

  1. No checkable condition (the lever check routes away from /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:

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.

so the remaining-work bullets travel too. The payload after /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.

section for non-interactive goals, <https://code.claude.com/docs/en/goal#run-non-interactively>.

Delivery: background-agent launch

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:

  1. 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:

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.

launch; fall back exactly as the dirty case does below, reporting what the command said.

"Anything else" is the default on purpose, and it is wide: a failure for some other reason

(dubious ownership, a damaged repository, git missing from 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>.

  1. 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:

```bash

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.

docs sections, Permission modes § When auto mode falls back

and agent view § Permission mode, model, and effort.

characters of each only

classifier denial, or either section starts saying what a background session does when an

action is denied or auto mode falls back.

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.

  1. 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.

  1. 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.

  1. 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.

Delivery variant: desktop session

When this session has a tool that starts another session (the Claude desktop app's Code tab) and

--cloud was not given, read

CODE0,

"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.

<https://code.claude.com/docs/en/desktop#work-across-sessions>.

Delivery variant: `--cloud`

Same hard gate, completion condition gate, save-point, /goal payload, prompt file, failure

fallback and stop, plus one more condition: the user's own words asked for a cloud session.

Whether a cloud session arms a /goal from its first prompt has not been probed, so the report

says so and tells the user to confirm ◎ /goal active when they open the session. A request for background work alone

does not cover it; without that, drop --cloud and take the local delivery. Steps 1 to 3

change, because this skill launches a cloud session only from a clean checkout whose branch

matches its remote:

  1. Only pushed work reaches it. Launch only when git status --porcelain -uall lists nothing

but save-point files (neither the linked-worktree exception nor worktree.bgIsolation: none applies), git fetch --quiet then

succeeds, and git rev-parse HEAD equals git rev-parse @{upstream}; the fetch keeps a stale

tracking ref from passing the check. No upstream, a failed command, or any other result → no

launch; fall back as the dirty case does and name commit-and-push as the fix. Upstream can

also bundle a repo in some cases (Pointer below). This skill does not take that path, so the

cloud session starts from pushed state; a user who wants a bundle starts claude --cloud

themselves. A

handoff file in the memory tier never reaches the VM, and the full path's Read @ names a

local path, so launch only on the prompt-only path. When the save-point takes the full path,

forced or by default, do not launch: tell the user to commit and push the handoff or plan,

then rerun as --cloud prompt <topic> <purpose naming its repo-relative path>. This skill

commits nothing.

  1. Launch from the project root with the prompt file:

claude --cloud "$(cat "<prompt-file>")" && rm -f "<prompt-file>", with --effort "<level>"

before the prompt argument when "What the launched session inherits" calls for one. If the CLI

rejects --effort with --cloud, relaunch without it and have the report name the level and

tell the user to send /effort <level> in the session. If it refuses --cloud because there is

no terminal, take the local delivery with the same prompt file instead of the failure

fallback, so the work keeps moving: local steps 3 and 4 then replace cloud step 3, and the

report adds that the cloud launch was refused and the run went local. Pointer: probe 3 in

reference/goal-probe.md. A cloud launch carries no settings file, so

when the plugin-profiles plugin is enabled the report says the cloud session

starts without this session's plugin profile.

  1. Report the session id and link it prints, plus the return paths: claude --teleport <id>

or /teleport to continue it in a terminal (its requirements: Pointer below), which needs the

same account; claude -p "<message>" --cloud <id> to queue a follow-up. Name

the account the CLI is signed in to now: the session's limits, teleport, follow-ups and plugin

loading all depend on that account (Pointer below).

<https://code.claude.com/docs/en/claude-code-on-the-web#send-local-repositories-without-github>,

<https://code.claude.com/docs/en/claude-code-on-the-web#manage-context> (/effort in a session),

<https://code.claude.com/docs/en/claude-code-on-the-web#continue-a-cloud-session-in-your-terminal>,

<https://code.claude.com/docs/en/claude-code-on-the-web#send-follow-ups-from-the-cli>; what the

session lacks: <https://code.claude.com/docs/en/cloud-environments#what-carries-over-from-your-setup>.

What the launched session inherits (and what it does not)

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.

and § Permission mode, model, and effort

Our rules:

(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.

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.

Set the effort level.

--permission-mode auto, so a directory setting with another default mode does not set the

launched session's mode.

it runs in, the same as a fresh claude started there.

Post-launch enforcement checklist

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):

save-point + /clear-then-paste exit, no launch, reason stated

prompt, or an explicit line saying the units would not resolve, and none of its text included in

the prompt handed to the launched agent

full path: brief lead, Suggested-skills selection, Remaining-actions order; prompt-only: the

inline Purpose: 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 tick

lock names this session carries the handover before check-enter (or none held)

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

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-paste

/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

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

checkout, auto chosen when the start offers a permission mode; the report names the session,

warns that it and the user may touch the same files, and says goal arming there is unprobed; a

refused or failed start → steps 1 to 5

--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, reported

Boundary, native Claude Code surfaces

Three built-in commands also keep work moving off this terminal, so "continue in the background"

can mean any of them.

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.

tree, and launches a fresh 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.

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),

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), 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), 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;

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.

Related

Gotchas

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").

What this skill does not do

the sibling handoff skill's /clear-then-paste shape

reports other uncommitted work rather than committing or stashing it

the continuation

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.