background-task
Decide when to launch a long-running task in the background and how to refer to it later. Covers both the `task` tool (sub-agent background via…
by MiniMax-AI★ 30 GitHub stars
Install background-task in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Background Task
When a task (a sub-agent invocation or a shell command) is expected to take more than ~30 seconds, the agent has two choices:
- Block: wait for the task to finish, holding the conversation hostage.
- Background: launch it, get a handle, continue working, and check on it later.
This Skill is about knowing when to choose (2) and how to record the handle so the agent (or the user) can check on it later.
mcode 0.2.4 surface
There are two background-capable tools on mcode 0.2.4, and the right one depends on whether the background work is a sub-agent or a shell command.
Sub-agent background: task(run_in_background: true) + task_query / task_output / task_stop
The canonical task schema:
task(
description: string, // 3-5 word label, required
prompt: string, // the brief, required
agent_name: "explore" | "worker" | "verifier", // required
run_in_background?: boolean // optional; true = async, false = sync (default)
)
When run_in_background: true, mcode returns immediately with a task_id.
The companion tools (also canonical in cli.js):
| Tool | Purpose | Required fields |
|---|---|---|
task_query(task_id?, status?) |
List session tasks (omit task_id) or get one. |
task_id for single fetch; status filter optional. |
task_output(task_id, offset?) |
Read a task's output incrementally. | task_id (required); offset (optional, byte offset for long output). |
task_stop(task_id, reason?) |
Request a background task to stop. | task_id (required); reason (optional, human-readable). |
run_in_background: false (the default) blocks the calling turn until the
sub-agent finishes and returns its final result.
Shell background: bash(run_in_background: true)
The bash tool's canonical schema (from cli.js:xza):
bash(
command: string, // required
timeout?: number, // optional, seconds
run_in_background?: boolean // optional; true = async, false = sync (default)
)
When run_in_background: true, the bash call returns immediately with a
job handle. Conceptual pseudocode below. The exact shape of the returned
handle is NOT part of the public mcode 0.2.4 runtime contract; the host's
job-control API is the source of truth for the underlying process id. The
Skills below treat the handle as opaque and locate the process id by means
outside the mcode contract (the launch context, the host's job-control API,
or the calling agent's own bookkeeping). Windows: Stop-Process -Id <process-id>;
POSIX: kill <process-id>, both invoked through a foreground bash call
rather than any action="kill" field. The placeholder <process-id> is
whatever process id the host's job-control API identifies; the launching
agent must record it (or a way to resolve it) by its own means, separate
from this Skill. There is no task_name= and no action="kill"
field. The Codex-harness shape bash(task_name=..., run_in_background=true, action="kill") is not the mcode surface — mcode's bash validator
rejects any key outside command / timeout / run_in_background.
Killing a shell background job: invoke the host's job-control API in a
foreground bash call. Windows: Stop-Process -Id <process-id>. POSIX:
kill <process-id>. The Skills do not pretend bash(action="kill") exists
on mcode 0.2.4. The <process-id> value is host-internal (e.g. a Windows
PID resolved via Get-Process, or a POSIX pid resolved via ps -p); the
launching agent records it out-of-band from this Skill.
When to use
Activate when any of these is true:
- A sub-agent is expected to take > 1 minute (deep research, multi-file refactor, anything you cannot predict the duration of).
- A shell command is expected to take > 30 seconds (
cargo test,npm install,docker build, a long-running dev server, a large data download). - The user explicitly says "background" / "后台" / "non-blocking" / "in the background".
- You need a long-running process to coexist with ongoing work (a dev server, a watch script, a streaming pipeline).
- You would otherwise block the conversation on a result the user can come back to later.
When NOT to use
- The task / command finishes in <5 seconds.
- The user explicitly wants the output now (interactive REPL, vim, ssh, a build whose output the next step depends on).
- The command is interactive (it expects a TTY or human input).
Process
- Estimate the duration. If unsure, assume the worst case. The mcode
tasktool description (run_in_background) says "Set to true when the sub-task is open-ended or expected to take more than ~1 minute (deep research, multi-step investigation, large refactors, anything you cannot predict the duration of), so you can keep working and the result is reported back automatically when it completes. Leave false (the default) for short, well-scoped sub-task
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the background-task skill do?
Decide when to launch a long-running task in the background and how to refer to it later. Covers both the `task` tool (sub-agent background via `run_in_background: true`) and the `bash` tool (shell background via `run_in_background: true`). USE WHEN: a sub-agent is expected to take > 1 minute, a shell command is expected to take > 30 seconds, the user wants a long-running process to coexist with ongoing work, you are about to block the conversation for an unbounded time, user said "background it" / "后台" / "don't block" / "non-blocking" / "run in background". TRIGGER PHRASES: "background", "background it", "后台", "don't block", "non-blocking", "in the background", "run async", "long-running", "put it in the background". SKIP WHEN: the sub-agent / command finishes in <5 seconds, the user explicitly wants to wait for output, the command is interactive (REPL, vim, ssh).
How do I install the background-task skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the background-task skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…