No way to list active background tasks programmatically
Problem
When Claude Code launches background tasks (via run_in_background), the task ID and output file path are returned at launch time. However, there is no tool or command available to list all currently running background tasks and their IDs.
This means:
- If a background task ID isn't captured at launch, it's lost
- There's no way to enumerate running tasks to clean them up
- Zombie processes from background tasks (e.g., long-running dev servers, scripts with open DB connections) can accumulate without a way to discover and stop them
Current behavior
Bashwithrun_in_background: true→ returns task ID + output file pathTaskOutput(task_id)→ reads output from a known task IDTaskStop(task_id)→ stops a known task ID- Missing: No
TaskListor equivalent to enumerate active background tasks
Expected behavior
A way to list all active background tasks, their IDs, status (running/completed/failed), and the commands that were run. Something like:
TaskListBackground() → [
{ id: "bb7e208", status: "running", command: "pnpm dev", started_at: "..." },
{ id: "b39f293", status: "failed", command: "tsx scripts/...", exit_code: 144 },
]
Workaround
Currently the only workaround is using ps aux | grep to find and kill stuck processes manually, which is fragile and loses the association with task IDs.
Context
This came up while building and testing tRPC-based scenario scripts that were launched in the background. Some processes hung due to open Prisma connections, and there was no way to discover them through the tool interface — they were only visible in the Claude Code UI's "Background tasks" section, but not accessible programmatically.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗