babysit
Run long-running tasks under babysit — supervised background runner with cgroup-enforced memory/CPU caps and observability-stall kill. Use BEFORE any…
от archibate★ 42 звезды на GitHub
Установить babysit в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
babysit — Supervised Background Task Runner
!command -v babysit || (mkdir -p "$HOME/.local/bin" && install -m755 "${CLAUDE_SKILL_DIR}/scripts/babysit.py" "$HOME/.local/bin/babysit" && echo "babysit installed to ~/.local/bin") || echo "babysit installation failed, consider use self-contained scripts/babysit.py" # auto-install CLI tool on skill load
!command -v babysit && (babysit ping 2>&1 || babysit daemon-start 2>&1 || echo "babysit daemon failed to start") # auto-start daemon on skill load
When to Use
- Non-interactive long-running tasks expected to run for >2 minutes
- Compute-intensive tasks: per-task cgroup caps (mem ≤40%, cpu ≤90%) prevent runaway resource use
- Long-running tasks that must survive the Claude session: daemon runs detached under user systemd
When NOT to Use
- Short tasks (<2 minutes): run in Bash directly
- Interactive commands: use
/tmuxinstead - IO-bound tasks (e.g. web servers, async loops): babysit's scheduler won't help
- Lightweight (low CPU + low memory) tasks fine to die with Claude: Bash
run_in_background: true
Hard Guardrail — Don't Bypass
/babysit is the cost guardrail for compute-intensive work on this host — not an optional tool. If a task is heavy (CPU-bound, memory-bound, multi-process), it MUST run under babysit so the cgroup caps and observability watchdog can stop runaway cost. Anti-patterns:
- Routing heavy work through built-in
run_in_background: trueto dodge the queue → no one monitors footprint; the host can thrash and lock the user out of SSH. - Inflating
--estimated_mem_bytes/--estimated_cpu_coresto pass the soft-deny gate while you don't actually need the headroom → starves other tasks and defeats fair-scheduling. - Auto-backgrounded long Bash commands (e.g. tools that fork into daemons): if they're heavy,
killand re-launch underbabysit run.
When your task hits the resource cap, the first reflex is NOT to raise the limit. It is to:
- Audit the script — profile, drop unused intermediates, rolling / partial read, subsampling, reduce space / time complexity, optimize nested loops, lower batch size /
n_jobs/ parallelism. - Re-run footprint-optimized; confirm the demand is genuinely unavoidable.
- Only then raise estimates and
babysit wait_for_capacityfor moderation.
Workflow
0. Smoke test
Before launching heavy work, smoke test on small scale for correctness and performance whenever appliable. Only proceed full-scale after the program is verified working and effcient in time and space.
1. Enqueue
babysit run \
--name="<unique-name>" \
--command="uv run python -u path/to/script.py" \
--estimated_time="10m" \
--estimated_mem_bytes="4G" \
--estimated_cpu_cores=4
Provide best-effort estimates for time, peak memory, and peak CPU cores — by extrapolation of smoke test (if linear complexity appliable) plus prior live experience (if any). Never over-estimate without clue (starves other tasks). You'll get a
runaway_risknotification when any actual exceeds its estimate. Pick estimation wisely.
The call is non-blocking: returns immediately with queued: <name>. The daemon dispatches as soon as system has capacity.
Required: --name (unique), --command (single shell string). Optional: --estimated_time (default 10m), --kill_timeout (default 2× estimated), --observability_interval (default 5m), --mem_pct_limit (default 40), --cpu_pct_limit (default 90), --estimated_mem_bytes (default 4G), --estimated_cpu_cores (default 4), --cwd (default current shell cwd).
Override the defaults to match your workload — under system memory/CPU pressure the daemon kills estimate-exceeders before within-estimate tasks, so accurate predictions protect long-running work. Hard kill fires at 2× sustained (daemon, graceful) or 3× instant via cgroup OOM. If the pressure is caused by an external (non-babysit) process — when the sum of all managed tasks' usage is smaller than the excess over threshold — the daemon logs and skips the kill rather than punishing its own tasks for someone else's load.
If capacity is tight,
babysit runmay soft-deny withcapacity_exceeded(exit 2, JSON on stderr) — run thebabysit wait_for_capacity --mem_bytes=… --cpu_cores=…(blocks until room exists) to wait for room, reduce estimates, or pass--forceto override.
2. Wait for completion (background)
babysit wait --name="<unique-name>"
Run with run_in_background: true and attach Monitor for runaway risk notifications. You get:
- a mid-flight
{"event":"runaway_risk","dim":"elapsed|mem|cpu", ...}JSON line on stderr the first time an actual exceeds its declared estimate (elapsed >estimated_time, mem >estimated_mem_bytes, or cpu_cores >estimated_cpu_cores) — inspect the log and decide whether to keep waiting orbabysit kill. Daemon hard-kills for mem/cpu at 2× sustained for the monitor tolerance window; elapsed hard-kills at--kill_timeout
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
Bash(babysit:*) - 02
Read
Вложенные файлы
- hooks/no-sleep-babysit.sh
- references/babysit.md
- scripts/babysit.py
FAQ
Что делает скилл babysit?
Run long-running tasks under babysit — supervised background runner with cgroup-enforced memory/CPU caps and observability-stall kill. Use BEFORE any long-running task (>2 min), compute-intensive jobs (e.g. builds/benchmarks/renders/training), background work, or when the user says "run in background", "use babysit". This skill defines guardrails and the mandatory workflow, not just a how-to.
Как установить скилл babysit?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл babysit запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
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…