From token-optimizer
Check running Claude Code or Codex sessions, find zombies, offer to clean up safely
How this command is triggered — by the user, by Claude, or both
Slash command
/token-optimizer:healthThe summary Claude sees in its command listing — used to decide when to auto-load this command
# Session Health Check
Run a session health check and help the user manage running sessions safely.
## Steps
1. Resolve measure.py path:
2. Run:
- CodeBuddy Code plugin: `bash "${CODEBUDDY_PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh" $MEASURE_PY health`
- Claude Code plugin: `bash "$CLAUDE_PLUGIN_ROOT/hooks/python-launcher.sh" $MEASURE_PY health`
- Codex or standalone: `TOKEN_OPTIMIZER_RUNTIME=codex python3 "$MEASURE_PY" health`
3. Present results clearly. For each session show: PID, elapsed time, version, and flags (STALE >24h, ZOMBIE >48h, OUTDATED, HEADLESS,...Run a session health check and help the user manage running sessions safely.
RUNTIME="${TOKEN_OPTIMIZER_RUNTIME:-}"
if [ -z "$RUNTIME" ]; then
if [ -n "$CODEBUDDY_PLUGIN_ROOT" ] || [ -n "$CODEBUDDY_PLUGIN_DATA" ]; then
RUNTIME="codebuddy"
elif [ -n "$CLAUDE_PLUGIN_ROOT" ] || [ -n "$CLAUDE_PLUGIN_DATA" ]; then
RUNTIME="claude"
elif [ -n "$CODEX_HOME" ] || [ -d "$HOME/.codex" ]; then
RUNTIME="codex"
else
RUNTIME="claude"
fi
fi
MEASURE_PY=""
for f in "$HOME/.codex/plugins/cache"/*/token-optimizer/*/skills/token-optimizer/scripts/measure.py \
"$HOME/.codex/skills/token-optimizer/scripts/measure.py" \
"$HOME/.claude/plugins/cache"/*/token-optimizer/*/skills/token-optimizer/scripts/measure.py \
"$HOME/.claude/skills/token-optimizer/scripts/measure.py" \
"$HOME/.claude/token-optimizer/skills/token-optimizer/scripts/measure.py"; do
[ -f "$f" ] && MEASURE_PY="$f" && break
done
export TOKEN_OPTIMIZER_RUNTIME="$RUNTIME"
Run:
bash "${CODEBUDDY_PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh" $MEASURE_PY healthbash "$CLAUDE_PLUGIN_ROOT/hooks/python-launcher.sh" $MEASURE_PY healthTOKEN_OPTIMIZER_RUNTIME=codex python3 "$MEASURE_PY" healthPresent results clearly. For each session show: PID, elapsed time, version, and flags (STALE >24h, ZOMBIE >48h, OUTDATED, HEADLESS, TERMINAL).
If ANY sessions are flagged STALE or ZOMBIE, ask the user: "I found N session(s) that look stale. Want me to show details so you can decide which to terminate?"
CRITICAL SAFETY RULES — follow these exactly:
--dry-run.bash "${CODEBUDDY_PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh" $MEASURE_PY kill-stale --dry-runbash "$CLAUDE_PLUGIN_ROOT/hooks/python-launcher.sh" $MEASURE_PY kill-stale --dry-runTOKEN_OPTIMIZER_RUNTIME=codex python3 "$MEASURE_PY" kill-stale --dry-runIf no stale or zombie sessions found, say: "All sessions look healthy. Your oldest is Xh old."
npx claudepluginhub studyzy/token-optimizer/healthValidates .planning/ directory integrity and reports actionable issues. Also supports --context flag to check session context utilization.
/healthReports Repowise code-health scores (1–10 per file) with KPIs, lowest-scoring files, refactoring targets, and trends. Accepts file paths, module names, and coverage files as arguments.
/healthChecks active Claude Code, Codex, and OpenCode sessions, identifies stale or zombie processes, and offers to clean them up safely.
/healthRuns a health check on a production URL, reporting HTTP status, response time, SSL validity, redirect chain, and missing security headers.
/healthRuns diagnostics on Nemp Memory data integrity — validates JSON structure, key format, value length, timestamps, and sync with CLAUDE.md, producing a scored health report with issues.
/healthRuns the Self-Star Doctor health check across 7 junctions (delegation, fitness, autoevolve, steward, verifier-spine, security, kairn-link) and displays a green/yellow/red board.