Running Background Tasks

Starts a long-running process (dev server, watcher) or a slow one-shot job (big install/build) without blocking the turn, and checks on it later. Use whenever a shell command wouldn't finish quickly on its own.

aaravriyer193 Updated

File contents

Running background tasks

A foreground shell call is capped at 60s — anything slower needs background: true.

Servers/watchers (never finish on their own):

shell: npm run dev    (background: true)

This returns a task_id (e.g. bg_abc123). Immediately follow with open_port on the port it listens on — that's how the user actually sees it.

Slow one-shot jobs (installs, builds, long scripts):

shell: npm install    (background: true)

Then check on it instead of guessing how long it'll take:

wait_task: { "task_id": "bg_abc123" }

wait_task blocks (up to its own timeout, default 60s) and returns the exit code plus recent output once it's done. If it's still running, call wait_task again — don't poll with repeated plain shell commands against the log file, that's what this tool is for.

Don't background something that genuinely finishes in a few seconds — plain shell is simpler and the result comes back immediately.

aaravriyer193/skills/tree/main/running-background-tasks commit b86c706309

Frequently asked questions

npx skillmds@latest add aaravriyer193/running-background-tasks