Check status of running subagents including token usage and context limits
Monitors running subagents for token usage, context limits, and completion status.
/plugin marketplace add cowwoc/claude-code-cat/plugin install cat@claude-code-catThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Track the status of active subagents, monitor their token consumption, detect context limit approaches, and identify compaction events. Enables the parent agent to make informed decisions about intervention or result collection.
Use the optimized monitoring script for minimal context impact:
/workspace/cat/scripts/monitor-subagents.sh
Output format:
{
"subagents": [
{"id": "a1b2c3d4", "task": "1.2-parser", "status": "running", "tokens": 45000, "compactions": 0},
{"id": "b2c3d4e5", "task": "1.3-formatter", "status": "warning", "tokens": 85000, "compactions": 1}
],
"summary": {"total": 2, "running": 1, "complete": 0, "warning": 1}
}
Status values:
running - Active, tokens below thresholdwarning - Tokens >= 80K (40% of context), consider interventioncomplete - Completion marker (.completion.json) found in worktreeToken Metric Source:
The tokens field in monitor output comes from:
.completion.json if subagent has completed (preferred)For accurate token metrics on completed subagents, use /cat:token-report which extracts
totalTokens from Task tool completions. This metric matches the CLI "Done" display and
represents actual context processed, not cumulative API response tokens.
If status = "warning":
/cat:token-reportcollect-resultsIf status = "complete":
.completion.json in worktree for detailsIf compactions > 0:
# Single command returns all subagent status
/workspace/cat/scripts/monitor-subagents.sh
# Filter output with jq
/workspace/cat/scripts/monitor-subagents.sh | jq '.subagents[] | select(.id == "a1b2c3d4")'
# Get summary counts only
/workspace/cat/scripts/monitor-subagents.sh | jq '.summary'
# ❌ Running jq manually each poll (accumulates tool call overhead)
jq -s '[...] | add' "${SESSION_FILE}"
jq -s '[...] | length' "${SESSION_FILE}"
# ✅ Single script call returns all data
/workspace/cat/scripts/monitor-subagents.sh
# ❌ Checking every second
while true; do
/workspace/cat/scripts/monitor-subagents.sh
sleep 1
done
# ✅ Reasonable polling interval (30-60 seconds)
while true; do
/workspace/cat/scripts/monitor-subagents.sh
sleep 60
done
# ❌ Ignoring compaction
if [ "${COMPACTIONS}" -gt 0 ]; then
echo "Compaction detected, continuing anyway..."
fi
# ✅ Treat compaction as intervention signal
if [ "${COMPACTIONS}" -gt 0 ]; then
echo "Compaction detected - initiating result collection"
# Trigger collect-results
fi
# ❌ Assuming worktree = active subagent
ACTIVE_COUNT=$(git worktree list | grep -c "-sub-")
# ✅ Verify session activity
for worktree in $(get_subagent_worktrees); do
if is_session_active "${worktree}"; then
ACTIVE_COUNT=$((ACTIVE_COUNT + 1))
fi
done
cat:spawn-subagent - Launch new subagentscat:collect-results - Gather completed subagent workcat:token-report - Detailed token analysiscat:parallel-execute - Orchestrate multiple subagentsThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.