一键导入
catmonitor-subagents
Check status of running subagents including token usage and context limits
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Check status of running subagents including token usage and context limits
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Guide for writing clear, descriptive commit messages
Merge task branch to base branch with linear history (works from task worktree)
MANDATORY: Use instead of `git rebase` - provides automatic backup and conflict recovery
MANDATORY: Use instead of `git rebase -i` for squashing - unified commit messages
Analyze mistakes with conversation length as potential cause (CAT-specific)
Run scheduled retrospective analysis, derive action items, and track effectiveness
| name | cat:monitor-subagents |
| description | Check status of running subagents including token usage and context limits |
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 subagents