|
| 1 | +--- |
| 2 | +name: agent-performance |
| 3 | +description: Track and report agent invocation metrics including usage counts, success/failure rates, and completion times. Use for understanding which agents are utilized, identifying underused agents, and optimizing agent delegation patterns. |
| 4 | +source_urls: |
| 5 | + - https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices |
| 6 | +--- |
| 7 | + |
| 8 | +# Agent Performance Dashboard |
| 9 | + |
| 10 | +## Purpose |
| 11 | + |
| 12 | +Provides visibility into agent usage patterns to optimize delegation and identify improvement opportunities. |
| 13 | + |
| 14 | +## When I Activate |
| 15 | + |
| 16 | +I automatically load when you mention: |
| 17 | + |
| 18 | +- "agent performance" or "agent metrics" |
| 19 | +- "agent dashboard" or "agent usage" |
| 20 | +- "which agents are used" or "underutilized agents" |
| 21 | +- "agent success rate" or "agent statistics" |
| 22 | + |
| 23 | +## What I Do |
| 24 | + |
| 25 | +1. **Track Invocations**: Record agent usage via workflow tracker |
| 26 | +2. **Measure Success**: Track completion rates per agent |
| 27 | +3. **Analyze Patterns**: Identify usage trends and gaps |
| 28 | +4. **Generate Reports**: Create actionable dashboards |
| 29 | + |
| 30 | +## Quick Start |
| 31 | + |
| 32 | +``` |
| 33 | +User: "Show me agent performance metrics" |
| 34 | +Skill: *activates automatically* |
| 35 | + "Generating agent performance report..." |
| 36 | +``` |
| 37 | + |
| 38 | +## Core Capabilities |
| 39 | + |
| 40 | +### 1. Report Generation |
| 41 | + |
| 42 | +Generate a performance report by reading workflow logs and aggregating agent metrics: |
| 43 | + |
| 44 | +``` |
| 45 | +User: "Generate agent performance report" |
| 46 | +``` |
| 47 | + |
| 48 | +Report includes: |
| 49 | + |
| 50 | +- Invocation counts per agent |
| 51 | +- Success/failure rates |
| 52 | +- Average completion times (when tracked) |
| 53 | +- Underutilized agents list |
| 54 | +- Recommendations for optimization |
| 55 | + |
| 56 | +### 2. Live Tracking |
| 57 | + |
| 58 | +Track agent invocations during workflow execution using the existing `workflow_tracker`: |
| 59 | + |
| 60 | +```python |
| 61 | +# Already available in .claude/tools/amplihack/hooks/workflow_tracker.py |
| 62 | +from workflow_tracker import log_agent_invocation |
| 63 | + |
| 64 | +log_agent_invocation( |
| 65 | + agent_name="architect", |
| 66 | + purpose="Design authentication module", |
| 67 | + step_number=2 |
| 68 | +) |
| 69 | +``` |
| 70 | + |
| 71 | +### 3. Metrics Storage |
| 72 | + |
| 73 | +Metrics are stored in: |
| 74 | + |
| 75 | +- **Raw logs**: `.claude/runtime/logs/workflow_adherence/workflow_execution.jsonl` |
| 76 | +- **Aggregated**: `.claude/runtime/metrics/agent_performance.yaml` |
| 77 | + |
| 78 | +## Report Format |
| 79 | + |
| 80 | +### Summary Dashboard |
| 81 | + |
| 82 | +```yaml |
| 83 | +# Agent Performance Summary |
| 84 | +# Generated: 2025-11-25 |
| 85 | + |
| 86 | +total_invocations: 142 |
| 87 | + |
| 88 | +agents: |
| 89 | + architect: |
| 90 | + invocations: 45 |
| 91 | + success_rate: 95.6% |
| 92 | + avg_duration_ms: 2340 |
| 93 | + trend: increasing |
| 94 | + |
| 95 | + builder: |
| 96 | + invocations: 38 |
| 97 | + success_rate: 89.5% |
| 98 | + avg_duration_ms: 4520 |
| 99 | + trend: stable |
| 100 | + |
| 101 | + reviewer: |
| 102 | + invocations: 25 |
| 103 | + success_rate: 100% |
| 104 | + avg_duration_ms: 1890 |
| 105 | + trend: increasing |
| 106 | + |
| 107 | +underutilized: |
| 108 | + - database (0 invocations in last 30 days) |
| 109 | + - integration (2 invocations in last 30 days) |
| 110 | + - patterns (3 invocations in last 30 days) |
| 111 | + |
| 112 | +recommendations: |
| 113 | + - Consider using database agent for schema work |
| 114 | + - Integration agent available for external service connections |
| 115 | + - Patterns agent can identify reusable solutions |
| 116 | +``` |
| 117 | +
|
| 118 | +## Implementation Guide |
| 119 | +
|
| 120 | +### To Generate a Report |
| 121 | +
|
| 122 | +1. Read workflow execution logs: |
| 123 | +
|
| 124 | + ``` |
| 125 | + Read: .claude/runtime/logs/workflow_adherence/workflow_execution.jsonl |
| 126 | + ``` |
| 127 | +
|
| 128 | +2. Filter for `agent_invoked` events: |
| 129 | + |
| 130 | + ```json |
| 131 | + { "event": "agent_invoked", "agent": "architect", "purpose": "...", "step": 2 } |
| 132 | + ``` |
| 133 | + |
| 134 | +3. Aggregate by agent name: |
| 135 | + - Count invocations |
| 136 | + - Calculate success rates from workflow_end events |
| 137 | + - Compute average durations |
| 138 | + |
| 139 | +4. Identify underutilized agents: |
| 140 | + - List all available agents from `.claude/agents/amplihack/` |
| 141 | + - Compare against invocation counts |
| 142 | + - Flag agents with <5 invocations in analysis period |
| 143 | + |
| 144 | +5. Write report to: |
| 145 | + ``` |
| 146 | + .claude/runtime/metrics/agent_performance.yaml |
| 147 | + ``` |
| 148 | + |
| 149 | +### Available Agents Inventory |
| 150 | + |
| 151 | +**Core Agents** (6): |
| 152 | + |
| 153 | +- architect, builder, reviewer, tester, optimizer, api-designer |
| 154 | + |
| 155 | +**Specialized Agents** (25): |
| 156 | + |
| 157 | +- ambiguity, amplifier-cli-architect, analyzer, azure-kubernetes-expert |
| 158 | +- ci-diagnostic-workflow, cleanup, database, documentation-writer |
| 159 | +- fallback-cascade, fix-agent, integration, knowledge-archaeologist |
| 160 | +- memory-manager, multi-agent-debate, n-version-validator, patterns |
| 161 | +- philosophy-guardian, pre-commit-diagnostic, preference-reviewer |
| 162 | +- prompt-writer, rust-programming-expert, security, visualization-architect |
| 163 | +- worktree-manager, xpia-defense |
| 164 | + |
| 165 | +**Note**: Agent count may change as specialized agents are added/removed. Use `ls .claude/agents/amplihack/specialized/` for current count. |
| 166 | + |
| 167 | +## Tracking Best Practices |
| 168 | + |
| 169 | +### When Invoking Agents |
| 170 | + |
| 171 | +Always log invocations for accurate tracking: |
| 172 | + |
| 173 | +```python |
| 174 | +# Before invoking an agent via Task tool |
| 175 | +log_agent_invocation( |
| 176 | + agent_name="security", |
| 177 | + purpose="Audit authentication implementation", |
| 178 | + step_number=7 # Optional: link to workflow step |
| 179 | +) |
| 180 | +
|
| 181 | +# Then invoke the agent |
| 182 | +Task(subagent_type="security", prompt="...") |
| 183 | +``` |
| 184 | + |
| 185 | +### Workflow Integration |
| 186 | + |
| 187 | +The DEFAULT_WORKFLOW.md specifies agent delegation at each step. This skill helps verify adherence: |
| 188 | + |
| 189 | +- Step 1: prompt-writer |
| 190 | +- Step 2: architect |
| 191 | +- Step 3: builder |
| 192 | +- Step 4: tester |
| 193 | +- Step 5: reviewer |
| 194 | +- etc. |
| 195 | + |
| 196 | +## Configuration |
| 197 | + |
| 198 | +| Setting | Default | Description | |
| 199 | +| ------------------------- | ------------------------ | -------------------------------------- | |
| 200 | +| `ANALYSIS_DAYS` | 30 | Days of history to analyze | |
| 201 | +| `UNDERUTILIZED_THRESHOLD` | 5 | Invocations below this = underutilized | |
| 202 | +| `METRICS_FILE` | `agent_performance.yaml` | Output file name | |
| 203 | + |
| 204 | +## Philosophy Alignment |
| 205 | + |
| 206 | +This skill follows: |
| 207 | + |
| 208 | +- **Ruthless Simplicity**: Uses existing infrastructure (workflow_tracker) |
| 209 | +- **Zero-BS**: No placeholders, working aggregation logic |
| 210 | +- **Modular Design**: Self-contained skill, clear boundaries |
| 211 | +- **Emergence**: Insights emerge from simple tracking patterns |
| 212 | + |
| 213 | +## Interpreting Metrics |
| 214 | + |
| 215 | +### Success Rate Guidelines |
| 216 | + |
| 217 | +| Rate | Assessment | Action | |
| 218 | +| --------- | --------------- | ------------------------------------------ | |
| 219 | +| 95-100% | Excellent | Maintain current patterns | |
| 220 | +| 85-94% | Good | Review occasional failures for patterns | |
| 221 | +| 70-84% | Needs Attention | Investigate failure causes, adjust prompts | |
| 222 | +| Below 70% | Critical | Agent may need redesign or prompt overhaul | |
| 223 | + |
| 224 | +### Invocation Volume Interpretation |
| 225 | + |
| 226 | +- **High volume (30+ in 30 days)**: Core workflow agent, ensure reliability |
| 227 | +- **Medium volume (10-29)**: Regular use, monitor for optimization opportunities |
| 228 | +- **Low volume (5-9)**: Specialized use case, verify still needed |
| 229 | +- **Very low (<5)**: Consider if agent is discoverable or relevant |
| 230 | + |
| 231 | +### Duration Benchmarks |
| 232 | + |
| 233 | +- **< 2 seconds**: Fast execution, typical for simple analysis |
| 234 | +- **2-10 seconds**: Normal for moderate complexity |
| 235 | +- **10-60 seconds**: Expected for deep analysis or multi-step tasks |
| 236 | +- **> 60 seconds**: May indicate inefficiency, consider optimization |
| 237 | + |
| 238 | +## Empty State Handling |
| 239 | + |
| 240 | +When no log data exists (new project or logs cleared): |
| 241 | + |
| 242 | +```yaml |
| 243 | +# Agent Performance Report |
| 244 | +# Period: Last 30 days |
| 245 | +# Status: No data available |
| 246 | +
|
| 247 | +summary: |
| 248 | + total_invocations: 0 |
| 249 | + message: "No agent invocations logged yet" |
| 250 | +
|
| 251 | +getting_started: |
| 252 | + - "Agent tracking begins when workflow_tracker logs invocations" |
| 253 | + - "Ensure agents are invoked via Task tool with proper logging" |
| 254 | + - "First report available after initial workflow execution" |
| 255 | +
|
| 256 | +next_steps: |
| 257 | + - "Run a workflow task to generate initial data" |
| 258 | + - "Verify workflow_tracker is properly configured" |
| 259 | + - "Check .claude/runtime/logs/ directory exists" |
| 260 | +``` |
| 261 | + |
| 262 | +## Limitations |
| 263 | + |
| 264 | +This skill has the following constraints: |
| 265 | + |
| 266 | +1. **Depends on workflow_tracker**: Only tracks agents invoked through the logging system |
| 267 | +2. **No real-time metrics**: Reports are generated on-demand, not streamed |
| 268 | +3. **Historical data only**: Cannot predict future usage patterns |
| 269 | +4. **Manual log analysis**: Does not auto-detect anomalies or alert on issues |
| 270 | +5. **Single-project scope**: Metrics are per-project, no cross-project aggregation |
| 271 | +6. **Time-based only**: No correlation with code quality or PR outcomes |
0 commit comments