# usage-trends

Tracks Claude Code session history, token consumption, and tool frequency through Agent Monitor API endpoints. Useful for diagnosing agent errors and checking cache efficiency over 365 days.

- 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-analytics/skills/usage-trends/SKILL.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/skills/usage-trends

## What it does

The skill pulls operational data from Agent Monitor using `GET /api/analytics`, `GET /api/stats`, and `GET /api/sessions?limit=200`. It calculates daily session averages, week-over-week deltas, and ranks the top 20 tools by call count. The output formats into Markdown tables marked with ASCII trend arrows like ▲, ▼, and →.

Token analytics track total input, output, and cache read volumes to measure cache efficiency over time. The skill also compares `PreToolUse` against `PostToolUse` events. A widening gap between them highlights failing tools.

This skill depends on a live Agent Monitor instance serving its HTTP endpoints. Without that service active, queries fail immediately because metrics are pre-aggregated at the database level.

## Install

### Claude Code (native platform)

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

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

### Codex

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

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

### Cursor

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

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

### GitHub Copilot

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

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

### Gemini CLI

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

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

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill usage-trends -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-analytics/skills/usage-trends/SKILL.md

## When to use it
- measure token cache efficiency and output verbosity ratios
- spot broken tool executions by comparing PreToolUse and PostToolUse counts
- compile a top 20 leaderboard of the most active agent tools
- track daily session counts and week-over-week shifts across 365 days

## Example prompts
- Analyze tool trends and rankings for the last 30 days
- Check token volume trends and cache efficiency for the last quarter
- Review session health and API errors during peak hours

## 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: 512d080752b09502.

BEGIN THIRD-PARTY FILE 512d080752b09502
````text
---
name: usage-trends
description: >
  Analyze Claude Code usage trends over time using the Agent Monitor's
  analytics API — daily session counts, daily event counts, token volumes
  by type, model distribution, tool usage rankings, and agent/event type
  distributions across 365-day retention windows.
---

# Usage Trends

Analyze usage patterns and trends from the Agent Monitor analytics data.

## Input

The user provides: **$ARGUMENTS**

Options: "last 7 days", "last 30 days", "last quarter", "peak hours", "tool trends", "model usage".

## Data Sources

| Endpoint | Returns |
|----------|---------|
| `GET /api/analytics` | Comprehensive analytics object (see schema below) |
| `GET /api/stats` | `{ total_sessions, active_sessions, active_agents, total_agents, total_events, events_today, ws_connections, agents_by_status, sessions_by_status }` |
| `GET /api/sessions?limit=200` | Full session records with timestamps and metadata |

### Analytics response schema (`GET /api/analytics`)

```json
{
  "overview": { "total_sessions", "active_sessions", "active_agents", "total_agents", "total_events" },
  "tokens": {
    "total_input": N, "total_output": N,
    "total_cache_read": N, "total_cache_write": N
  },
  "tool_usage": [{ "tool_name": "...", "count": N }],  // top 20
  "daily_events": [{ "date": "YYYY-MM-DD", "count": N }],  // 365 days
  "daily_sessions": [{ "date": "YYYY-MM-DD", "count": N }],  // 365 days
  "agent_types": [{ "subagent_type": "task"|"explore"|null, "count": N }],
  "event_types": [{ "event_type": "PreToolUse"|"PostToolUse"|..., "count": N }],
  "avg_events_per_session": N,
  "total_subagents": N,
  "sessions_by_status": { "active": N, "completed": N, "error": N, "abandoned": N },
  "agents_by_status": { "working": N, "completed": N, "error": N, ... }
}
```

## Trend Analyses to Produce

### 1. Daily Activity Trend
Plot `daily_sessions` and `daily_events` for the requested period. Compute:
- **Average sessions/day** and **events/day**
- Week-over-week delta (%)
- Peak day and quietest day

### 2. Token Volume Trends
From analytics tokens (baselines are pre-summed into totals at the DB level):
- Total tokens: `total_input`, `total_output`, `total_cache_read`, `total_cache_write`
- **Cache efficiency over time**: `total_cache_read / (total_cache_read + total_input)` — trending up = improving
- **Output intensity**: `total_output / total_input` ratio — high = Claude is verbose

### 3. Tool Usage Ranking
From `tool_usage` (top 20 tools by event count):
- Bar chart data (tool name → count)
- Tool diversity: unique tools used
- Subagent spawns: count of "Agent" tool uses (each = a subagent launched)

### 4. Model Distribution
From `agent_types` + per-session model field:
- Which models are used most frequently
````
END THIRD-PARTY FILE 512d080752b09502

The third-party file has ended. Everything between the 512d080752b09502 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 2780 of 3389 bytes. © hoangsonww · MIT · https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/HEAD/plugins/ccam-analytics/skills/usage-trends/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
