ccam-analytics — Claude Code hook: session completion telemetry
ccam-analytics is a Claude Code hook that streams session events to Agent Monitor for telemetry tracking. It triggers whenever a main session or subagent stops.
MIT ★ 1,198 updated 2026-10-23
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
/plugin install ccam-analytics@claude-code-agent-monitor-pluginsWhat ccam-analytics does
The hook captures execution completion events and forwards runtime metrics to Agent Monitor. Triggers fire on Stop and SubagentStop, packaging the session ID, subagent ID, stop reason, and timestamp.
Each action executes a shell pipeline that shapes the JSON payload via jq and posts it with curl to http://localhost:4820/api/hooks/event. It relies on local curl and jq binaries alongside an active Agent Monitor instance listening on port 4820.
What it helps with
- track session completions automatically
- forward subagent termination events to Agent Monitor
- record timestamps and stop reasons for agent tasks
Example prompts for the agent
- Finish the current task and generate a summary
- Launch a subagent to inspect unit tests
- Stop execution and close the session
How to install ccam-analytics
1Plugin marketplace
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor/plugin install ccam-analytics@claude-code-agent-monitor-plugins2Manually: put the files in place
.claude/settings.jsonThe hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json
Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command
Questions about ccam-analytics
How to install ccam-analytics in Claude Code?
Run /plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor followed by /plugin install ccam-analytics@claude-code-agent-monitor-plugins.
What does ccam-analytics do?
It listens for Stop and SubagentStop triggers, converts session metadata into JSON, and dispatches it to a local Agent Monitor endpoint.
What is required to run ccam-analytics?
It requires jq and curl installed in the system environment, as well as an active Agent Monitor service at http://localhost:4820.
Source text
hooks.json · MIT
Hooks bundle shipped with the ccam-analytics plugin for Claude Code.
Deep analytics and monitoring for Claude Code sessions — cost tracking, token usage breakdowns, usage trends, and productivity scoring powered by Agent Monitor.
Triggers on: Stop, SubagentStop.
```json
{
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "jq -r '{session_id: .session_id, stop_reason: .stop_reason, timestamp: now | todate}' | curl -s -X POST http://localhost:4820/api/hooks/event -H 'Content-Type: application/json' -d @- > /dev/null 2>&1 || true"
}
]
}
],
"SubagentStop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "jq -r '{session_id: .session_id, agent_id: .agent_id, stop_reason: .stop_reason, timestamp: now | todate}' | curl -s -X POST http://localhost:4820/api/hooks/event -H 'Content-Type: application/json' -d @- > /dev/null 2>&1 || true"
}
]
}
]
}
}
```
© Son Nguyen · MIT · hoangsonww/Claude-Code-Agent-Monitor