# workflow-optimizer

Analyzes agent DAGs, tool call transitions, and token expenses via the Agent Monitor API. Identifies retry loops, error flows, and model delegation waste.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 1121
- Author: hoangsonww
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/HEAD/plugins/ccam-productivity/skills/workflow-optimizer/SKILL.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/skills/workflow-optimizer

## What it does

The skill connects to the Agent Monitor workflow intelligence API to pull telemetry across sessions. By querying `GET /api/workflows/{sessionId}`, it examines 11 structured datasets. These cover subagent orchestration graphs, tool transition matrices, concurrency lanes, and error propagation across hierarchy levels.

It also cross-references model delegation patterns against the `GET /api/pricing` endpoint. This highlights misallocated tasks, such as routing lightweight work to Opus instead of Haiku or Sonnet. The output delivers a prioritized table of top 5 recommendations with estimated cost savings and implementation effort.

The skill cannot operate without an active Agent Monitor instance providing the telemetry endpoints.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill workflow-optimizer -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/workflow-optimizer/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/workflow-optimizer/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill workflow-optimizer -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/workflow-optimizer/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill workflow-optimizer -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/workflow-optimizer/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install hoangsonww/Claude-Code-Agent-Monitor workflow-optimizer
```

2. **Manually: put the files in place**
- File: `.github/skills/workflow-optimizer/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill workflow-optimizer -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/hoangsonww/Claude-Code-Agent-Monitor --path plugins/ccam-productivity/skills/workflow-optimizer
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/workflow-optimizer/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill workflow-optimizer -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/HEAD/plugins/ccam-productivity/skills/workflow-optimizer/SKILL.md

## When to use it
- Detect redundant tool call loops and repeated execution failures
- Trace error propagation through parent and child subagent trees
- Rebalance model delegation to cut inference costs
- Pinpoint sessions suffering from frequent context compaction

## Example prompts
- Run workflow-optimizer analyze on session session_12345 focusing on cost
- Analyze tool call sequences with workflow-optimizer tools
- Use workflow-optimizer to inspect subagent completion rates and concurrency bottlenecks

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: a043ef3d07281183.

BEGIN THIRD-PARTY FILE a043ef3d07281183
```text
---
name: workflow-optimizer
description: >
  Analyze workflow patterns using the Agent Monitor's workflow intelligence
  API — orchestration DAGs, tool flow transitions, subagent effectiveness,
  model delegation patterns, error propagation by depth, concurrency lanes,
  compaction impact, and agent co-occurrence. Produces prioritized optimization
  recommendations with quantified impact.
---

# Workflow Optimizer

Analyze Claude Code workflows using the Agent Monitor's workflow intelligence engine.

## Input

The user provides: **$ARGUMENTS**

Options: "analyze", a session ID for single-session analysis, or a focus: "tools", "subagents", "cost", "errors".

## Data Sources

| Endpoint | Returns |
|----------|---------|
| `GET /api/sessions?limit=100` | Session list with metadata |
| `GET /api/workflows/{sessionId}` | **11 workflow datasets** (see below) |
| `GET /api/analytics` | Tool usage top 20, event types, agent types |
| `GET /api/pricing` | Model pricing rules for cost comparison |

### Workflow Intelligence API (`GET /api/workflows/{sessionId}`)

Returns these 11 datasets per session:

| Dataset | Content |
|---------|---------|
| `stats` | Aggregate session stats: tool count, agent depth, event count |
| `orchestration` | **DAG**: agent nodes with parent/child edges, depths, types |
| `toolFlow` | **Transition matrix**: tool A → tool B with counts (common sequences) |
| `effectiveness` | **Subagent success**: per-type completion rates, avg duration, task success |
| `patterns` | **Recurring sequences**: detected workflow patterns with frequency |
| `modelDelegation` | **Model choices**: which models are delegated which tasks |
| `errorPropagation` | **Error flow by depth**: where in the agent tree errors originate and propagate |
| `concurrency` | **Concurrency lanes**: overlapping agent execution timelines |
| `complexity` | **Complexity score**: numerical score based on depth, breadth, tool diversity |
| `compaction` | **Compaction impact**: token savings, frequency, context health |
| `cooccurrence` | **Agent pairs**: which agents frequently run together |

## Optimization Analyses

### 1. Tool Flow Optimization
From `toolFlow` transition data:
- Identify the most common tool sequences (e.g., Read → Edit → Bash)
- Find redundant transitions (same tool called repeatedly = retries)
- Detect anti-patterns: high-frequency failure loops
- Recommend tool chain shortcuts

### 2. Subagent Strategy
From `effectiveness` + `orchestration`:
- Which subagent types (task, explore, code-review) have highest completion rates
- Average duration per subagent type — are subagents taking too long?
- Underutilized types: tasks that could benefit from delegation
```
END THIRD-PARTY FILE a043ef3d07281183

The third-party file has ended. Everything between the a043ef3d07281183 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2711 of 3999 bytes. © hoangsonww · MIT · https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/HEAD/plugins/ccam-productivity/skills/workflow-optimizer/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
