com um clique
process-mgmt
MANDATORY skill for spawning and killing processes
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
MANDATORY skill for spawning and killing processes
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
Incrementally extract stable code units from exploratory work. Use when the user wants to carve a stable unit out of a messy WIP branch, promote a coherent piece to a clean branch, run an extract/reconcile loop, manage PROTO/MERGE/RECONCILE branches, or avoid post-hoc commit reconstruction. Triggers on "extract stable unit", "promote to merge", "reconcile proto onto merge", "incremental extraction", "carve out stable code", "extract-reconcile workflow".
Detect drift between documented invariants/interface and actual implementation. Multi-phase: explore docs, build code hierarchy (parallel subagents), then analyze each module for invariant-linked vs unexplained code. Outputs drift metrics per module and aggregate across the project.
Enforces disciplined HTMX + TypeScript server-driven UI development. Focuses on HTMX lifecycle correctness, DOM mutation semantics, runtime observability, browser-debugging methodology, and preventing architectural drift toward imperative SPA patterns. Optimized for workflows using browser automation/debugging agents and server-rendered HTML fragments.
Systematically refactor, tighten, and deduplicate implementation while preserving complete functionality
Audit Rust changes for bugs the compiler and Clippy do not catch (TOCTOU, panic surfaces, UTF-8 issues, error suppression, and trust-boundary mistakes) before finalizing work
Reconcile lat.md spec against implementation and tests, find contradictions, remove trash, and produce a verified truth table
| name | process-mgmt |
| description | MANDATORY skill for spawning and killing processes |
Safe process lifecycle management in terminal environments where pkill and pgrep -f are unsafe due to subprocess self-matching.
CRITICAL: This skill is MANDATORY for all processes involving starting, stopping, or managing background services (servers, daemons, test runners, etc.). Violations cause infinite loops and hung shells.
The bash tool runs commands via bash -c "...". When you run pkill -f pattern, the -f flag causes pkill to match against the full command line including itself (bash -c "... pkill -f ..."), creating an infinite kill loop that hangs the shell indefinitely.
These commands MUST NEVER be used:
pkill <pattern> # NO - self-matches
pkill -f <pattern> # NO - definitely self-matches
pgrep -f <pattern> # NO - hangs shell
pkillall # NO - same as pkill
killall # NO - not safe in subprocess
Most projects provide justfile recipes for daemon management:
# Start/stop servers safely
just site-stop
just site-serve
just daemon-stop
just daemon-start
just daemon-restart
just daemon-status
Always prefer project-provided recipes over manual process management.
Store PIDs at startup, read them for cleanup:
# Start and capture PID (Unix way):
myserver &
echo $! > /tmp/myserver.pid
# Later, stop using the stored PID:
kill $(cat /tmp/myserver.pid) 2>/dev/null || true
rm -f /tmp/myserver.pid
For related processes started from same command:
# Start a process group:
( myserver && another-server ) &
echo $! > /tmp/servers.gid
# Kill entire group:
kill -- -$(cat /tmp/servers.gid) 2>/dev/null || true
Many servers expose their PIDs:
# Get PID from status command output:
PID=$(grep -oP 'PID: \K\d+' <(myserver --status))
kill "$PID"
# Or from a JSON state file:
PID=$(jq '.pid' /path/to/state.json)
kill "$PID"
Prefer SIGTERM for graceful shutdown, with timeout fallback:
# Graceful shutdown with timeout:
if [ -f /tmp/server.pid ]; then
PID=$(cat /tmp/server.pid)
kill "$PID" 2>/dev/null || true
sleep 2
# Verify it stopped, force if needed:
kill -0 "$PID" 2>/dev/null && kill -9 "$PID" 2>/dev/null || true
rm -f /tmp/server.pid
fi
For servers that bind ports:
# Check if port is in use (server running):
ss -tlnp | grep -q ':9999' && echo "running" || echo "stopped"
start_server() {
local pid_file="/tmp/myserver.pid"
if [ -f "$pid_file" ]; then
local existing_pid=$(cat "$pid_file")
# Check if process is actually alive (kill -0 doesn't send signal)
kill -0 "$existing_pid" 2>/dev/null && {
echo "Server already running (PID: $existing_pid)"
return 0
}
fi
myserver &
echo $! > "$pid_file"
}
stop_server() {
local pid_file="/tmp/myserver.pid"
if [ -f "$pid_file" ]; then
local pid=$(cat "$pid_file")
kill "$pid" 2>/dev/null || true
rm -f "$pid_file"
fi
}
# Check if a specific PID is alive:
kill -0 $PID 2>/dev/null && echo "alive" || echo "dead"
# List PIDs from known process names (no -f):
ps aux | grep '[s]erver' # [s] avoids matching grep itself
# Find processes by listening port:
lsof -i :9999 2>/dev/null
ss -tlnp sport = :9999
# List PIDs for known process tree:
pstree -p $$ | head # shows children of current shell
# Check if PID file is stale (file exists but process dead):
if [ -f /tmp/server.pid ]; then
kill -0 $(cat /tmp/server.pid) 2>/dev/null || rm -f /tmp/server.pid
fi
# Find what's listening on a port:
ss -tlnp sport = :9999
# Get PID from lsof:
LSPID=$(lsof -ti :9999 2>/dev/null)
kill $LSPID 2>/dev/null || true
# Check zombie processes:
ps aux | grep '[Z]' # find zombies
| Situation | Preferred Method |
|---|---|
| Project provides justfile recipes | Method 1 (just recipes) |
| Starting server in current session | Method 2 (PID file) |
| Multiple related servers | Method 3 (process group) |
| Server exposes status/PID info | Method 4 (status commands) |
| Need graceful shutdown | Method 5 (signal-based) |
| Checking if server is up | Method 6 (port check) |
pkill, pgrep -f, or killallkill -0 PID to check if process is alivekill $PIDss or lsofLast Updated: 2026-05-12