Agent Skillsascorbic/bgproc › bgproc

bgproc

GitHub

管理后台进程的工具,支持启动、重启、停止和查看状态。适用于开发服务器等长运行进程的生命周期管理,提供端口等待、日志查看及清理功能。

Trigger Scenarios

需要启动或重启本地开发服务器 检查后台进程是否运行及其端口状态 查看后台进程的实时日志 停止或强制终止正在运行的后台任务

Install

npx skills add ascorbic/bgproc --skill bgproc -g -y
More Options

Use without installing

npx skills use ascorbic/bgproc@bgproc

指定 Agent (Claude Code)

npx skills add ascorbic/bgproc --skill bgproc -a claude-code -g -y

安装 repo 全部 skill

npx skills add ascorbic/bgproc --all -g -y

预览 repo 内 skill

npx skills add ascorbic/bgproc --list

SKILL.md

Frontmatter
{
    "name": "bgproc",
    "description": "Manage background processes like dev servers. Use when you need to start, stop, or check status of long-running processes."
}

bgproc

A CLI for managing background processes. All commands output JSON to stdout.

When to Use

Use bgproc when you need to:

  • Start a dev server or other long-running process in the background
  • Restart a process with the same command and working directory
  • Check if a process is running and what port it's listening on
  • View logs from a background process
  • Stop a background process

Commands

# Start a process
bgproc start -n <name> -- <command...>
bgproc start -n devserver -- npm run dev
bgproc start -n devserver -t 300 -- npm run dev  # auto-kill after 5 min

# Start and wait for port (recommended for dev servers)
bgproc start -n devserver -w -- npm run dev      # wait for port, then exit
bgproc start -n devserver -w 30 -- npm run dev   # wait up to 30s for port

# Force restart (kill existing process first)
bgproc start -n devserver -f -w -- npm run dev

# Restart with same command and cwd (kills if running)
bgproc restart <name>
bgproc restart <name> -w      # wait for port after restart

# Check status (returns JSON with pid, running state, port)
bgproc status <name>

# View logs
bgproc logs <name>
bgproc logs <name> --tail 50
bgproc logs <name> --errors  # stderr only

# List all processes
bgproc list
bgproc list --cwd  # filter to current directory

# Stop a process
bgproc stop <name>
bgproc stop <name> --force  # SIGKILL

# Clean up dead processes
bgproc clean <name>
bgproc clean --all

Workflow

  1. Start a process and wait for port: bgproc start -n devserver -w -- npm run dev
    • Streams logs to stderr while starting
    • Prints JSON with port to stdout when ready
    • Use -f to force restart if already running
  2. Restart a process: bgproc restart devserver -w
    • Re-runs with the same command and cwd
    • Kills the process first if still running
  3. If something's wrong, check logs: bgproc logs devserver
  4. When done: bgproc stop devserver

Notes

  • All commands output JSON to stdout, errors to stderr
  • Port detection works via lsof and checks child processes (macOS/Linux only)
  • Use -w to wait for port detection before returning
  • Use -f to force restart (kills existing process with same name)
  • Starting a process with the same name as a dead one auto-cleans it
  • Logs are capped at 1MB per process

Version History

  • 97a2292 Current 2026-07-24 22:03

Metadata

Files
0
Version
97a2292
Hash
8d1da5ce
Indexed
2026-07-24 22:03

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-05 15:49
浙ICP备14020137号-1 $Carte des visiteurs$