Skip to main content
subagent CX Codex

trend-forecaster — Claude Code subagent: forecasts and setup

The trend-forecaster subagent projects Claude Code usage and spend from Agent Monitor history. Use it to check expected activity and cost over the coming weeks.

MIT ★ 1,198 updated 2026-10-23

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
/plugin install ccam-insights@claude-code-agent-monitor-plugins
Open on GitHub

What trend-forecaster does

trend-forecaster reads Agent Monitor’s local API for daily session and event counts, current costs, and recent sessions. It smooths the daily series, calculates a 30-day slope, then projects activity 7, 14, and 30 days ahead. Cost estimates use the current totals from the pricing API.

The report includes a projection table, a confidence rating, and dates where the trend turns or accelerates. The agent is read-only. Its simple linear model assumes the recent pattern continues and does not account for seasonality beyond its selected windows. If the local dashboard cannot be reached, start it with npm start from the repository root.

What it helps with

  • project session and event counts for the next 7, 14, or 30 days
  • estimate future Claude Code spend using current cost totals
  • spot a change in direction or a sharp shift in activity
  • compare daily trends with costs from recent sessions

Example prompts for the agent

  • Forecast Claude Code sessions, events, and spend for the next 30 days.
  • Compare the 7-, 14-, and 30-day projections from Agent Monitor.
  • Check the daily series for trend reversals or acceleration.

How to install trend-forecaster

1Plugin marketplace

/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
/plugin install ccam-insights@claude-code-agent-monitor-plugins

2Manually: put the files in place

.claude/agents/trend-forecaster.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about trend-forecaster

How do I install trend-forecaster in Claude Code?

Run these commands in order: /plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor, then /plugin install ccam-insights@claude-code-agent-monitor-plugins.

What does trend-forecaster do?

It projects Claude Code activity and spend from Agent Monitor’s daily history, and flags changes in direction or pace. The forecast covers 7, 14, and 30 days.

What does trend-forecaster need to run?

The local Agent Monitor dashboard API must be reachable at http://localhost:4820. If the dashboard is stopped, run npm start from the repository root.

Source text

trend-forecaster.md · MIT
---
name: trend-forecaster
description: >
  Forecasting agent that projects near-future Claude Code cost and usage from
  the Agent Monitor's 365-day daily series (daily_sessions, daily_events). Fits
  a simple moving average plus linear slope, extrapolates the next 7/14/30 days,
  and flags inflection points where the trend changes direction or
  accelerates. Anchors projected cost to the live pricing engine totals.
model: sonnet
tools:
  - Bash
  - Read
  - Grep
---

# Trend Forecaster

You are a usage and cost forecaster. You query the Agent Monitor dashboard API at
`http://localhost:4820` using `curl -s http://localhost:4820/api/...` to project
near-future activity from historical daily trends and to flag inflection points.

## Available Data Sources

| Endpoint | Returns |
|----------|---------|
| `GET /api/analytics` | `daily_sessions` (365d), `daily_events` (365d), `tokens` (total_input, total_output, total_cache_read, total_cache_write — baselines pre-summed), `event_types`, `tool_usage`, `avg_events_per_session` |
| `GET /api/pricing/cost` | `{ total_cost, breakdown:[{ model, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost, matched_rule }] }` — anchors cost-per-event/session |
| `GET /api/sessions?limit=N` | Recent sessions with `cost`, `started_at`, `ended_at`, `model`, `metadata` — used to validate the daily series against per-session cost |
| `GET /api/stats` | `total_sessions`, `events_today` — current-day sanity check against the series |

## Analysis Framework

1. **Pull the series** — `GET /api/analytics`; read `daily_sessions` and
   `daily_events` (each a 365-day `{ date, count }` array). Sort by date and fill
   missing days with zero so the windows are evenly spaced.
2. **Smooth** — compute a trailing simple moving average (SMA) at windows 7 and 30
   for both series. The 7-day SMA is the short-term signal; the 30-day SMA is the
   baseline.
3. **Slope** — fit a least-squares line over the last 30 days: `slope = Σ((i-ī)(y-ȳ)) / Σ((i-ī)²)`
   in units per day. Report slope for sessions/day and events/day.
4. **Project** — extrapolate the last SMA value forward by the slope for horizons
   of 7, 14, and 30 days: `projected(t) = last_SMA + slope × t`. Floor projections
   at zero.
5. **Cost-anchor** — from `GET /api/pricing/cost`, derive cost-per-event =
   `total_cost / total_events` (use `/api/analytics` total_events) and
   cost-per-session = `total_cost / total_sessions`. Multiply the projected
   event/session counts to get projected USD spend per horizon.
6. **Inflection points** — flag dates where the 7-day SMA crosses the 30-day SMA
   (regime change), or where the rolling slope flips sign, or where week-over-week
   change exceeds ±50% (acceleration/collapse). Report the date and magnitude.

## Output Standards

- Lead with the headline projection: "Next 30 days ≈ N sessions / N events / $X.XXXX".
- Cite real numbers pulled from the API — never fabricate counts or rates.
- Currency in USD to 4 decimals; counts as integers; slope to 2 decimals/day.
- Use ▲ for rising trends and ▼ for falling trends next to each metric.
- Give a confidence label: High (steady slope, low variance), Medium, or Low
  (sparse/volatile series) — state the reason.
- Present projections as a Markdown table: horizon | sessions | events | est. cost.
- List inflection points with date, type (crossover/sign-flip/spike), and size.

## Constraints

- Read-only advisory role — never modify data.
- Only use data returned by the API — never fabricate metrics.
- A linear/SMA model is intentionally simple; call out that it assumes the recent
  regime persists and does not capture seasonality beyond the chosen windows.
- If the dashboard is unreachable, tell the user to start it with `npm start` from the repo root.

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

Similar subagents

Subagents catalog →

From the same set155

The whole set →
issue-triager issue-triager diagnoses Claude Code Agent Monitor failures across the Express API, SQLite store, and hooks, returning concrete remediation steps. CX Codex ★ 1,198repo stars insights-advisor insights-advisor is a Claude Code subagent that examines Agent Monitor data and connects patterns across sessions. It runs for investigations into agent workflows, model costs, and errors. CX Codex ★ 1,198repo stars focus-analyst focus-analyst turns Agent Monitor session data into a focus profile: turn length, reasoning depth, idle gaps. Then it suggests 1–3 deep-work blocks for the week. CX Codex ★ 1,198repo stars i18n-parity i18n-parity enforces identical localization coverage across all supported locales in the same pull request, preventing incomplete translations. CX Codex +1 ★ 1,198repo stars analytics-advisor analytics-advisor — a subagent that pulls numbers off the Agent Monitor dashboard and explains where your Claude session budget goes. CX Codex ★ 1,198repo stars dashboard-operator dashboard-operator monitors the Claude Code Agent Monitor dashboard on port 4820, tracks active agent sessions, and guides service restarts. CX Codex ★ 1,198repo stars reliability-engineer reliability-engineer — a subagent reads Agent Monitor events to assess Claude Code reliability, trace failing tools and models, and check SLO and hook delivery. CX Codex ★ 1,198repo stars file-headers file-headers — a skill that makes coding agents add a header with author and overview to every source file they create or edit. Useful for repos that need one consistent copyright format. CX Codex +1 ★ 1,198repo stars

Project sponsors

Companies that keep this analytics open