Background Tasks - Claude Code
Run Bash commands with Ctrl+B and retrieve output by task ID.

Background tasks let long-running shell commands run alongside your session without blocking the prompt.
What it does
Press Ctrl+B or pass the background flag to a Bash tool call, and Claude starts the command asynchronously. You get a task ID back immediately. Claude can poll the task's stdout and stderr later, stream new output into context, or stop it via TaskStop. This is how dev servers, test watchers, and long builds stay alive across turns.
When to use it
- Running
npm run dev,pnpm test --watch, or similar long processes. - Kicking off a build while Claude keeps coding.
- Tailing logs or monitoring a process without blocking your chat.
- CI-style jobs where you want Claude to check back periodically.
Gotchas
- Background tasks don't persist across sessions. Restart claims a fresh process.
- Output buffers have limits - very chatty processes may get truncated. Pipe to a file for full logs.
- Forgetting to stop a background task leaves orphaned processes. Always call TaskStop or close the session cleanly.
Official docs: https://code.claude.com/docs/en/interactive-mode.md#background-bash-commands
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Was this helpful?
Related Guides
Related Tools
Claude Code
Anthropic's agentic coding CLI. Runs in your terminal, edits files autonomously, spawns sub-agents, and maintains memory...
View ToolClaude Agent SDK
Anthropic's SDK for building agents on the same tools, agent loop, and context management that power Claude Code. Python...
View ToolCodeburn
Interactive TUI dashboard that shows exactly where your Claude Code and Cursor tokens are going, in real time.
View ToolConductor
Mac app for running parallel Claude Code, Codex, and Cursor agents in isolated workspaces. Watch every agent work at onc...
View ToolRelated Videos

Generate Videos in Codex + Claude Code with This...
Check out HeyGen! https://heygen.1stcollab.com/developersdigest The video introduces HeyGen, an AI video generation platform with a rich API and a CLI that lets developers create, fetch, and manipula...

10x Design in Claude Code and Codex
Try Higgsfield: https://higgsfield.ai/s/higgsfield-general-campaign-developersdigest-juDMTi AI coding agents can build entire websites in minutes, but the default results often still look generic and...

Self Improving Applications with Claude Code & Codex
Build a Self‑Improving Next.js App: Supabase + Vercel Eve + GitHub Issues + Agent Loops Check out Supabase: https://supabase.plug.dev/1wWOTGS The video demonstrates how to build and deploy a self-im...
Related Posts

Claude for Startups Offer Paused: What Founders Do Now
Anthropic's free year of Claude Team and $1,000 in API credits hit capacity within days. What the program page says now,...

Claude Advisor Tool vs a Bigger Model: When the Pairing Pays
Anthropic's own runs: a Fable 5.1 advisor added 1.7 points to Opus 5.5 for 2.1x the cost. When the Claude advisor tool p...

Claude Code Retry Watchdog: Keep Unattended Runs Alive
CLAUDE_CODE_RETRY_WATCHDOG=1 makes Claude Code wait out 429 and 529 errors instead of failing after 10 retries. When to...

Claude Max API Credits: $100 a Month, What They Cover
Anthropic now gives Max and Team plans a monthly Claude API credit: $100 on Max 5x, $200 on Max 20x, up to $500 pooled o...

Opus 5.5 vs Sonnet 5.5 vs Haiku 5.5: Which Claude Model to Use
Sonnet 5.5 is the default, Opus 5.5 is for open-ended long-horizon work, and Haiku 5.5 is for bounded steps and subagent...

Claude Haiku 5.5: Pricing, Migration Changes, and When to Use It
Claude Haiku 5.5 (claude-haiku-5-5) costs $0.10 input and $0.50 output per million tokens under 100K, with a 1M window a...
