Comprehensive guide to monitoring, debugging, and optimizing Claude Code and oh-my-claudecode performance.
- Overview
- Built-in Monitoring
- HUD Integration
- Debugging Techniques
- External Resources
- Best Practices
- Troubleshooting
oh-my-claudecode provides comprehensive monitoring capabilities for tracking agent performance, token usage, costs, and identifying bottlenecks in multi-agent workflows. This guide covers both built-in tools and external resources for monitoring Claude's performance.
| Metric | Tool | Granularity |
|---|---|---|
| Agent lifecycle | Agent Observatory | Per-agent |
| Tool timing | Session Replay | Per-tool call |
| Session-end summary | Session-end hook | Per-session |
| File ownership | Subagent Tracker | Per-file |
| Parallel efficiency | Observatory | Real-time |
The Agent Observatory provides real-time visibility into all running agents, their performance metrics, and potential issues.
The observatory is automatically displayed in the HUD when agents are running. You can also query it programmatically:
import { getAgentObservatory } from 'oh-my-claudecode/hooks/subagent-tracker';
const obs = getAgentObservatory(process.cwd());
console.log(obs.header); // "Agent Observatory (3 active, 85% efficiency)"
obs.lines.forEach(line => console.log(line));Agent Observatory (3 active, 85% efficiency)
🟢 [a1b2c3d] executor 45s tools:12 tokens:8k $0.15 files:3
🟢 [e4f5g6h] document-specialist 30s tools:5 tokens:3k $0.08
🟡 [i7j8k9l] architect 120s tools:8 tokens:15k $0.42
└─ bottleneck: Grep (2.3s avg)
⚠ architect: Cost $0.42 exceeds threshold
| Icon | Meaning |
|---|---|
| 🟢 | Healthy - agent running normally |
| 🟡 | Warning - intervention suggested |
| 🔴 | Critical - stale agent (>5 min) |
| Metric | Description |
|---|---|
tools:N |
Number of tool calls made |
tokens:Nk |
Approximate token usage (thousands) |
$X.XX |
Estimated cost in USD |
files:N |
Files being modified |
bottleneck |
Slowest repeated tool operation |
The legacy analytics workflow described in older docs (omc-analytics, omc cost, omc backfill, and the analytics HUD preset) is no longer part of current dev.
The supported monitoring surfaces on current builds are:
- Agent Observatory in the HUD / API
- Session Replay logs in
.omc/state/agent-replay-*.jsonl - Session-end summaries in
.omc/sessions/<sessionId>.json - Session-end notifications emitted through configured callbacks
omc hud
tail -20 .omc/state/agent-replay-*.jsonl
ls .omc/sessions/*.jsonUse a supported preset such as focused or full for agent and context visibility:
{
"omcHud": {
"preset": "focused"
}
}This shows:
- Active agents and their status
- Todos / PRD progress
- Context and rate-limit state
- Background tasks
Session replay records agent lifecycle events as JSONL for post-session analysis and timeline visualization.
| Event | Description |
|---|---|
agent_start |
Agent spawned with task info |
agent_stop |
Agent completed/failed with duration |
tool_start |
Tool invocation begins |
tool_end |
Tool completes with timing |
file_touch |
File modified by agent |
intervention |
System intervention triggered |
Replay data is stored at: .omc/state/agent-replay-{sessionId}.jsonl
Each line is a JSON event:
{"t":0.0,"agent":"a1b2c3d","agent_type":"executor","event":"agent_start","task":"Implement feature","parent_mode":"team"}
{"t":5.2,"agent":"a1b2c3d","event":"tool_start","tool":"Read"}
{"t":5.4,"agent":"a1b2c3d","event":"tool_end","tool":"Read","duration_ms":200,"success":true}import { getReplaySummary } from 'oh-my-claudecode/hooks/subagent-tracker/session-replay';
const summary = getReplaySummary(process.cwd(), sessionId);
console.log(`Duration: ${summary.duration_seconds}s`);
console.log(`Agents: ${summary.agents_spawned} spawned, ${summary.agents_completed} completed`);
console.log(`Bottlenecks:`, summary.bottlenecks);
console.log(`Files touched:`, summary.files_touched);The replay system automatically identifies bottlenecks:
- Tools averaging >1s with 2+ calls
- Per-agent tool timing analysis
- Sorted by impact (highest avg time first)
| Preset | Focus | Elements |
|---|---|---|
minimal |
Clean status | Context bar only |
focused |
Task progress | Todos, agents, modes |
full |
Everything | All elements enabled |
analytics |
Cost tracking | Tokens, costs, efficiency |
dense |
Compact all | Compressed format |
Edit ~/.claude/settings.json:
{
"omcHud": {
"preset": "focused",
"elements": {
"agents": true,
"todos": true,
"contextBar": true,
"analytics": true
}
}
}| Element | Description |
|---|---|
agents |
Active agent count and status |
todos |
Todo progress (completed/total) |
ralph |
Ralph loop iteration count |
autopilot |
Autopilot phase indicator |
contextBar |
Context window usage % |
analytics |
Token/cost summary |
- Check the Observatory for agents running >2 minutes
- Look for bottleneck indicators (tool averaging >1s)
- Review tool_usage in agent state
import { getAgentPerformance } from 'oh-my-claudecode/hooks/subagent-tracker';
const perf = getAgentPerformance(process.cwd(), agentId);
console.log('Tool timings:', perf.tool_timings);
console.log('Bottleneck:', perf.bottleneck);When multiple agents modify the same file:
import { detectFileConflicts } from 'oh-my-claudecode/hooks/subagent-tracker';
const conflicts = detectFileConflicts(process.cwd());
conflicts.forEach(c => {
console.log(`File ${c.file} touched by: ${c.agents.join(', ')}`);
});OMC automatically detects problematic agents:
| Intervention | Trigger | Action |
|---|---|---|
timeout |
Agent running >5 min | Kill suggested |
excessive_cost |
Cost >$1.00 | Warning |
file_conflict |
Multiple agents on file | Warning |
import { suggestInterventions } from 'oh-my-claudecode/hooks/subagent-tracker';
const interventions = suggestInterventions(process.cwd());
interventions.forEach(i => {
console.log(`${i.type}: ${i.reason} → ${i.suggested_action}`);
});Track how well your parallel agents are performing:
import { calculateParallelEfficiency } from 'oh-my-claudecode/hooks/subagent-tracker';
const eff = calculateParallelEfficiency(process.cwd());
console.log(`Efficiency: ${eff.score}%`);
console.log(`Active: ${eff.active}, Stale: ${eff.stale}, Total: ${eff.total}`);- 100%: All agents actively working
- <80%: Some agents stale or waiting
- <50%: Significant parallelization issues
This score is a live activity/health signal. It is not a benchmark of model quality, token cost, latency, or harness overhead.
The TypeScript agent benchmarks under benchmarks/ report these dimensions separately:
- Run completion: whether each agent/fixture run completed or failed.
- Scorer quality: ground-truth-based benchmark scores for completed paired runs.
- Token cost proxy: API-reported input, output, and combined tokens, shown as paired totals and per-fixture means; missing usage is
insufficient/unavailable, never zero. - API latency: the retry-inclusive API-call span. It is not pure model compute time.
- Harness overhead: measured non-API processing after the API response, including parsing, ground-truth loading, scoring, matching, and result construction.
Comparison deltas use matching (domain, fixtureId) observations for each dimension. Unpaired fixtures, failed runs, or missing telemetry make the diagnostic INCONCLUSIVE; they are not treated as improvements or regressions. The report deliberately does not collapse these dimensions into one efficiency score.
Prompt, fixture, and ground-truth I/O failures fail closed instead of silently changing the compared inputs. An absent per-fixture label is reported as a recoverable failed run, while a missing label root or malformed/invalid label is fatal configuration evidence. Recoverable per-fixture failures remain visible in the report, and the shared benchmark CLI exits nonzero after writing the diagnostic when any run failed.
A diagnostic report alone cannot prove that a particular model, including Opus, regressed. A model claim requires controlled paired runs with the same fixtures, prompts, model identity, configuration, and complete measurements. Even then, the timing fields do not attribute differences to model compute, network conditions, provider queues, retries, or harness internals beyond their documented boundaries.
Clean up agents that exceed the timeout threshold:
import { cleanupStaleAgents } from 'oh-my-claudecode/hooks/subagent-tracker';
const cleaned = cleanupStaleAgents(process.cwd());
console.log(`Cleaned ${cleaned} stale agents`);MarginLab.ai provides external performance tracking for Claude models:
- SWE-Bench-Pro daily tracking: Monitor Claude's performance on software engineering benchmarks
- Statistical significance testing: Detect performance degradation with confidence intervals
- Historical trends: Track Claude's capabilities over time
- Model comparison: Compare performance across Claude model versions
Visit the platform to:
- View current Claude model benchmark scores
- Check historical performance trends
- Set up alerts for significant performance changes
- Compare across model versions (Opus, Sonnet, Haiku)
| Resource | Description | Link |
|---|---|---|
| Claude Code Discord | Community support and tips | discord.gg/anthropic |
| OMC GitHub Issues | Bug reports and feature requests | GitHub Issues |
| Anthropic Documentation | Official Claude documentation | docs.anthropic.com |
Track Claude's performance across standard benchmarks:
| Benchmark | What It Measures | Where to Track |
|---|---|---|
| SWE-Bench | Software engineering tasks | MarginLab.ai |
| HumanEval | Code generation accuracy | Public leaderboards |
| MMLU | General knowledge | Anthropic blog |
# Set up budget warnings in HUD
/oh-my-claudecode:hud
# Select "focused" or "full"| Task Type | Recommended Model | Cost Impact |
|---|---|---|
| File lookup | Haiku | Lowest |
| Feature implementation | Sonnet | Medium |
| Architecture decisions | Opus | Highest |
Session replay is automatically enabled. Review replays after complex workflows:
# Find replay files
ls .omc/state/agent-replay-*.jsonl
# View recent events
tail -20 .omc/state/agent-replay-*.jsonlThe default cost limit per agent is $1.00 USD. Agents exceeding this trigger warnings.
After completing complex tasks, check the replay summary:
const summary = getReplaySummary(cwd, sessionId);
if (summary.bottlenecks.length > 0) {
console.log('Consider optimizing:', summary.bottlenecks[0]);
}Periodically clean up old replay files and stale agent state:
import { cleanupReplayFiles } from 'oh-my-claudecode/hooks/subagent-tracker/session-replay';
cleanupReplayFiles(process.cwd()); // Keeps last 10 sessionsSymptoms: Costs higher than expected, context window filling quickly
Solutions:
- Use
ecomode for token-efficient execution:eco fix all errors - Check for unnecessary file reads in agent prompts
- Review the Agent Observatory in HUD (or replay logs) for agent-level breakdown
- Enable cache - check cache efficiency in analytics
Symptoms: Agents running >5 minutes, low parallel efficiency
Solutions:
- Check Observatory for bottleneck indicators
- Review tool_usage for slow operations
- Consider splitting large tasks into smaller agents
- Use
architect-lowinstead ofarchitectfor simple verifications
Symptoms: Merge conflicts, unexpected file changes
Solutions:
- Use
team N:executormode for automatic file ownership - Check
detectFileConflicts()before parallel execution - Review file_ownership in agent state
- Use
team N:executormode with explicit task isolation
Symptoms: No .omc/sessions/*.json files after a session finishes
Solutions:
- End the session normally so the
session-endhook runs - Verify HUD / hooks are installed:
/oh-my-claudecode:hud setup - Check the current workspace
.omc/sessions/directory - Review
.omc/state/agent-replay-*.jsonlif you need timing/activity evidence instead
Symptoms: Observatory showing agents that aren't running
Solutions:
- Run
cleanupStaleAgents(cwd)programmatically - Delete
.omc/state/subagent-tracking.jsonto reset - Check for orphaned lock files:
.omc/state/subagent-tracker.lock
| File | Purpose | Format |
|---|---|---|
.omc/state/subagent-tracking.json |
Current agent states | JSON |
.omc/state/agent-replay-{id}.jsonl |
Session event timeline | JSONL |
.omc/state/token-tracking.jsonl |
Token usage log | JSONL |
.omc/state/analytics-summary-{id}.json |
Cached session summaries | JSON |
.omc/state/subagent-tracker.lock |
Concurrent access lock | Text |
// Core tracking
getActiveAgentCount(directory: string): number
getRunningAgents(directory: string): SubagentInfo[]
getTrackingStats(directory: string): { running, completed, failed, total }
// Performance
getAgentPerformance(directory: string, agentId: string): AgentPerformance
getAllAgentPerformance(directory: string): AgentPerformance[]
calculateParallelEfficiency(directory: string): { score, active, stale, total }
// File ownership
recordFileOwnership(directory: string, agentId: string, filePath: string): void
detectFileConflicts(directory: string): Array<{ file, agents }>
getFileOwnershipMap(directory: string): Map<string, string>
// Interventions
suggestInterventions(directory: string): AgentIntervention[]
cleanupStaleAgents(directory: string): number
// Display
getAgentDashboard(directory: string): string
getAgentObservatory(directory: string): { header, lines, summary }// Recording
recordAgentStart(directory, sessionId, agentId, agentType, task?, parentMode?, model?): void
recordAgentStop(directory, sessionId, agentId, agentType, success, durationMs?): void
recordToolEvent(directory, sessionId, agentId, toolName, eventType, durationMs?, success?): void
recordFileTouch(directory, sessionId, agentId, filePath): void
// Analysis
readReplayEvents(directory: string, sessionId: string): ReplayEvent[]
getReplaySummary(directory: string, sessionId: string): ReplaySummary
// Cleanup
cleanupReplayFiles(directory: string): number- Analytics System - Historical note on the removed analytics subsystem and current replacements
- Reference - Complete feature reference
- Architecture - System architecture overview