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.
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill pattern-detect -a claude-codeWhat 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-code2Manually: put the files in place
~/.claude/skills/pattern-detect/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/pattern-detect/
1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill pattern-detect -a codex2Manually: put the files in place
.agents/skills/pattern-detect/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill pattern-detect -a cursor2Manually: put the files in place
.cursor/skills/pattern-detect/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install hoangsonww/Claude-Code-Agent-Monitor pattern-detect2Manually: put the files in place
.github/skills/pattern-detect/SKILL.md1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill pattern-detect -a gemini-cli2Platform CLI
gemini skills install https://github.com/hoangsonww/Claude-Code-Agent-Monitor --path plugins/ccam-insights/skills/pattern-detectManually: put the files in place
.devin/skills/pattern-detect/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill pattern-detect -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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