CLI tool for monitoring and browsing Claude Code sub-agent and session transcripts.
View and search through Claude Code session history and sub-agent transcripts. All views display rich metadata headers showing model, version, branch, project, timestamps, message count, and token usage breakdown. Auto-detects whether an ID is a session or agent.
Block until one or more sub-agents complete. Essential for parallel agent workflows. Uses up to three detection methods:
- Token log -- instant detection via hook-based completion entries
- PID liveness -- checks if the Claude process is still running via
kill -0 - JSONL staleness -- fallback: no activity for 5 minutes = presumed complete
The PID hook is required for robust wait behavior. Without it, wait falls back to JSONL staleness, which will incorrectly presume an agent is dead if it's alive but idle for >5 minutes (e.g. long tool execution, slow model response). See the setup guide to configure hooks.
fzf-based selection with preview panels showing metadata and first exchanges. Browse sessions or agents, then view, watch live, or open full transcripts.
Navigate large sessions without loading everything into memory. --limit sets a token budget (chars/4), --offset skips messages. Output includes NEXT_OFFSET=M for continuation.
Non-interactive commands (list, list-sessions, view, session, wait) are safe for use by Claude Code agents themselves -- no TTY required.
Sessions that hit context limits are compacted by Claude Code, which previously made the rest of the conversation invisible. agent-watch now renders these boundaries:
[COMPACT]-- marks where compaction occurred (auto/manual, token count)[SUMMARY]-- the AI-generated summary injected after compaction (distinct from[USER])[HOOK]-- hook executions showing event, name, and script (e.g.SessionStart:startup → session-start.sh)
Both full compaction and in-place microcompaction are supported. Synthetic callback entries are filtered out.
Stream agent output in real-time with colorized role markers ([USER], [ASST], [TOOL], [RESULT], [COMPACT], [HOOK], [SUMMARY]).
- bash 4+ (macOS ships bash 3 -- install via
brew install bash) - jq -- JSON parsing (
brew install jq) - fzf -- interactive selection and previews (
brew install fzf), only needed for interactive mode - bc -- token formatting (optional, usually pre-installed)
curl -fsSL https://github.com/restot/agent-watch/releases/latest/download/agent-watch \
-o ~/.local/bin/agent-watch && chmod +x ~/.local/bin/agent-watchVerify it's in your PATH:
which agent-watchIf not found:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.$(basename "$SHELL")rcRestart your shell or run exec $SHELL to apply.
Append the agent-watch reference to your global Claude Code memory:
curl -fsSL https://raw.githubusercontent.com/restot/agent-watch/main/CLAUDE.md >> ~/.claude/CLAUDE.mdUsage: agent-watch [command] [args] [flags]
Non-interactive commands (safe for agents):
list [count] List recent sub-agents (default: 20)
-p, --project <name> Filter by project (case-insensitive partial match)
list-sessions [n] List all sessions (or last n)
-p, --project <name> Filter by project (case-insensitive partial match)
view [id] View agent transcript (most recent if no id)
session <id> View a specific session
<id> Auto-detect: view agent or session by ID
wait <id> [id...] Block until agent(s) complete
update Self-update to the latest release
Interactive commands (require TTY):
(none) fzf selection of sub-agents
sessions [id] fzf browser for sessions (or view specific session by ID)
watch [id] Live tail of agent output
All views display a metadata header:
Model, Version, Branch, Project, Started/Ended, Messages, Tokens
Sub-agents also show Slug; Permission shown when available.
Message markers:
[USER] User messages [TOOL] Tool calls (name + input)
[ASST] Assistant responses [RESULT] Tool results
[COMPACT] Compaction boundary [SUMMARY] Post-compaction summary
[HOOK] Hook execution (callbacks are filtered out)
Pagination (for large sessions/agents):
--limit N Token budget (chars/4); prints NEXT_OFFSET=M when exceeded
--offset N Skip first N messages (combine with --limit to paginate)
--last [N] Show last message, or last N tokens (no header, no pager)
Other flags:
--skip-tool-output Show tool calls and args but hide tool result output
--no-color Disable colored output (also respects NO_COLOR env var)
--debug Show debug output
--help Show this help message
--version Show version number
Environment:
NO_COLOR Disable colored output (see https://no-color.org/)
AGENT_WATCH_STALE_TIMEOUT Staleness threshold in seconds for wait fallback (default: 300)
List the 10 most recent sub-agents:
agent-watch list 10View the most recent agent transcript:
agent-watch viewView a specific session or agent by ID (auto-detected):
agent-watch abc123deFilter agents or sessions by project name:
agent-watch list -p my-project
agent-watch list-sessions -p my-projectPaginate through a large session:
agent-watch session abc123de --limit 5000
# Output includes NEXT_OFFSET=M if truncated
agent-watch session abc123de --offset 50 --limit 5000Show the last 5000 tokens of a session (chronological order):
agent-watch abc123de --last 5000View agent decision flow without tool result noise:
agent-watch abc123de --skip-tool-output --limit 5000Disable colors (useful when calling from agents to save tokens):
NO_COLOR=1 agent-watch view
# or
agent-watch --no-color viewWait for sub-agents to finish before continuing:
agent-watch wait abc123 def456Browse sessions with fzf:
agent-watch sessionsBrowse sub-agents with fzf:
agent-watchLive tail an active sub-agent:
agent-watch watchArchitecture and internals
~/.claude/projects/
<project>/
<session-id>.jsonl <-- main session transcripts
sessions-index.json <-- session metadata (prompts, dates)
subagents/
agent-<id>.jsonl <-- sub-agent transcripts
~/.claude/.agent-pids/ <-- PID files (optional, via hooks)
~/.claude/subagent-tokens.log <-- token log (optional, via hooks)
agent-watch reads Claude Code's JSONL session and agent files from ~/.claude/projects/. It parses metadata from the first few entries in each file (model, version, branch, timestamps) and aggregates token usage across all assistant entries.
JSON parsing is handled by jq. Interactive selection uses fzf with preview windows that show session metadata and recent messages. Output is colorized with role-based markers ([USER], [ASST], [TOOL], [RESULT], [COMPACT], [HOOK], [SUMMARY]) for readability. Color can be disabled via NO_COLOR=1 or --no-color to reduce token overhead when output is consumed by agents.
Compaction boundaries (compact_boundary, microcompact_boundary) and hook progress entries (hook_progress, stop_hook_summary) are parsed from the JSONL and rendered inline. Synthetic callback entries are filtered out to reduce noise.
See the wiki for guides and screenshots:
- UI Overview -- screenshots of interactive session browsing, agent history, transcript view, and pagination
- Token Log & PID Tracking -- Claude Code hooks for faster
waitdetection and token usage logging
- Fork the repo
- Create a branch (
git checkout -b my-feature) - Edit source modules in
cli/ - Build:
./build.sh(assemblesbin/agent-watch, runs syntax check) - Run tests:
make test(ormake docker-testto run in Docker) - Submit a PR
Source modules live in cli/, assembled by build.sh into bin/agent-watch. The root agent-watch is the legacy monolith kept for backwards compatibility.
CI runs on both Ubuntu and macOS to catch GNU/BSD differences. Quick syntax + unit check: make check.
Run tests and coverage analysis in Docker without installing dependencies locally:
make docker-test # Run all tests
make docker-coverage # Run coverage, copies badge + HTML report to project rootMIT
