Skip to main content
skill CX Codex

pattern-detect — Claude Code skill: what it does, how to install

Analyzes agent sessions via Agent Monitor to find recurring tool sequences, error cascades, and delegation habits. Generates a ranked report with recommendations.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill pattern-detect -a claude-code
Open on GitHub

What pattern-detect does

The skill queries the local Agent Monitor backend to inspect session history. It fetches workflow metrics from /api/sessions and /api/workflows/{sessionId}. Using the toolFlow transition matrix, it maps sequential tool transitions and flags loops where tools retry after errors.

Pattern detection examines five categories: tool chains, workflow shapes, error cascades by agent depth, subagent pairing, and temporal activity peaks. The resulting report ranks the top 10 patterns by frequency multiplied by impact. Every pattern receives an impact rating and an actionable fix.

Without a running Agent Monitor instance, the skill cannot work. It does not parse raw logs directly. You can pass filters such as "tools", "errors", "workflows", or a session count to focus the report on specific behavior.

What it helps with

  • detect repetitive tool retries and loops during agent execution
  • trace error cascades across different subagent depth levels
  • evaluate model delegation habits and subagent pairing efficiency
  • identify context compaction triggers in long coding sessions

Example prompts for the agent

  • Run pattern-detect tools on the last 15 sessions
  • Identify error cascades using pattern-detect: errors
  • Generate a full report with pattern-detect all

How to install pattern-detect

1Skills CLI (Vercel)

npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill pattern-detect -a claude-code

2Manually: put the files in place

~/.claude/skills/pattern-detect/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/pattern-detect/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about pattern-detect

How do I install pattern-detect in Claude Code?

Run npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill pattern-detect -a claude-code in your terminal. This registers the skill for Claude Code.

What does pattern-detect do?

It analyzes session data from Agent Monitor to highlight habitual workflows, tool transition matrices, and error propagation paths. It then produces a top 10 pattern report with recommendations.

What are the prerequisites for pattern-detect?

It requires an active Agent Monitor service exposing endpoints like /api/sessions and /api/workflows/{sessionId}. The skill queries this API directly rather than analyzing raw files.

Source text

SKILL.md · MIT
---
name: pattern-detect
description: >
  Detect recurring patterns using the Agent Monitor's workflow intelligence —
  toolFlow transitions (tool A → B frequency matrices), recurring workflow
  patterns, agent co-occurrence pairs, model delegation habits, error
  propagation paths by agent depth, and compaction triggers. Use to discover
  habitual usage patterns and anti-patterns.
---

# Pattern Detect

Identify recurring patterns using the Agent Monitor's workflow intelligence engine.

## Input

The user provides: **$ARGUMENTS**

Options: "all", "tools", "errors", "workflows", "last N sessions".

## Data Sources

| Endpoint | Returns |
|----------|---------|
| `GET /api/sessions?limit=200` | Session list with status, model, cwd, metadata |
| `GET /api/analytics` | tool_usage top 20, event_types, agent_types |
| `GET /api/workflows/{sessionId}` | 11 datasets per session (see below) |

### Workflow datasets used for pattern detection

| Dataset | Pattern insight |
|---------|----------------|
| `toolFlow` | **Tool transition matrix**: tool A → tool B with counts — reveals sequential habits |
| `patterns` | **Detected workflow patterns**: recurring sequences with frequency scores |
| `cooccurrence` | **Agent co-occurrence**: which agents frequently run together |
| `modelDelegation` | **Model habits**: which models are chosen for which task types |
| `errorPropagation` | **Error patterns**: where errors start and how they cascade by agent depth |
| `effectiveness` | **Subagent patterns**: which types succeed most, avg duration per type |
| `compaction` | **Compaction triggers**: what causes context overflow |
| `complexity` | **Complexity patterns**: session complexity scores over time |

## Pattern Categories

### 1. Tool Chain Patterns (from `toolFlow`)
- **Most common sequences**: Top 10 tool transitions (e.g., Read → Edit: 145 times)
- **Starter tools**: First tool used in sessions (indicates task type)
- **Finisher tools**: Last tool before Stop event
- **Anti-patterns**: Tool → same Tool repeated (retries/failures)
- **Co-occurrence**: Tools that always appear together in sessions

### 2. Workflow Patterns (from `patterns`)
- **Named patterns**: Workflow sequences the API has detected with frequency
- **Session archetypes**: Common session shapes (short edit, long debug, subagent-heavy)
- **Project-specific**: Patterns that appear in specific working directories

### 3. Error Patterns (from `errorPropagation` + `event_types`)
- **Error origins**: Which agent depth level produces most errors
- **Cascade patterns**: Errors that trigger chains of follow-up errors
- **APIError frequency**: quota hits, rate_limit, overloaded — by time of day
- **Recovery patterns**: How errors are typically resolved (tool retry vs agent switch)

### 4. Agent Patterns (from `cooccurrence` + `effectiveness`)
- **Agent pairs**: Which agents are spawned together frequently
- **Delegation patterns**: Main agent → subagent task delegation habits
- **Success by type**: Which subagent types (task/explore/code-review) work best for which tasks

### 5. Temporal Patterns (from session timestamps + `daily_sessions`)
- **Peak hours**: When sessions cluster
- **Duration patterns**: Short vs long session distribution
- **Day-of-week trends**: Productive days vs quiet days

## Output

**Pattern Report** with top 10 patterns ranked by frequency × impact:
- Pattern name and description
- Frequency (occurrences across analyzed sessions)
- Impact: positive (reinforce), negative (eliminate), or neutral (observe)
- Actionable recommendation for each

© hoangsonww · MIT · hoangsonww/Claude-Code-Agent-Monitor

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set60

remote-collection A skill that walks the agent through CCAM remote data sources: connect machines over SSH and pull Claude and Codex history. Useful when sessions live beyond your laptop. CX Codex +1 ★ 1,121repo stars alert-management Inspects fired CCAM alerts and manages monitoring rules for token thresholds, inactivity, and status duration. CX Codex +1 ★ 1,121repo stars session-compare Compare two Agent Monitor sessions across cost, tokens, events, and agent activity. Use it to see what changed between runs with different outcomes. CX Codex +1 ★ 1,121repo stars regression-watch Compares an older baseline window of session history with a recent one and reports which metrics got worse: errors, cache, compactions, cost per session. CX Codex +1 ★ 1,121repo stars optimization-suggest This skill reviews Claude Code session history and ranks ways to cut costs, improve speed, and prevent errors. Use it to plan changes based on recorded activity. CX Codex +1 ★ 1,121repo stars benchmark The benchmark skill takes one session or a few recent ones and compares them with the rolling average from Agent Monitor data: cost, tokens, tool count and workflow complexity. Each metric comes back as a percentile of the population. CX Codex +1 ★ 1,121repo stars anomaly-alert Flags anomalous Claude Code sessions by checking spending spikes and tool execution errors via local Agent Monitor. CX Codex +1 ★ 1,121repo stars transcript-grep Search a session’s conversation for text or a regex and inspect each hit in context. Handy when you need to track down a prompt, tool call, or error. CX Codex +1 ★ 1,121repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor