How ovid/claude-context works
claude-context is a Claude Code plugin that exposes context-window, usage, cost, and compaction facts to agents. The main workflow is: a statusline collector captures Claude Code’s stdin data into per-session snapshots; an agent invokes the report, which combines snapshot and transcript data into a human-readable summary and JSON. Setup/teardown wire and restore the statusline, including coexistence with an existing command. The graph reflects documented capabilities and shown imports/calls; unsampled command and skill internals are represented by their exact directories, with uncertain links omitted.
Main entry points: collect.mjs Statusline collector · report.mjs Resource report · wiring.mjs Statusline wiring · command.mjs Command builder
Components 19
Capture and persistence
- Statusline collector
plugins/claude-context/scripts/collect.mjs - Statusline input
plugins/claude-context/scripts/lib/stdin.mjs - Snapshot store
plugins/claude-context/scripts/lib/snapshot.mjs
Agent reporting
- Report skill
plugins/claude-context/SKILL.md - Resource report
plugins/claude-context/scripts/report.mjs - Transcript analysis
plugins/claude-context/scripts/lib/transcript.mjs
Statusline lifecycle
- Setup command
plugins/claude-context/commands - Teardown command
plugins/claude-context/commands - Statusline wiring
plugins/claude-context/scripts/wiring.mjs - Coexist wrapper
plugins/claude-context/scripts/coexist.mjs - Command builder
plugins/claude-context/scripts/lib/command.mjs - Ownership marker
plugins/claude-context/scripts/lib/marker.mjs - Command redaction
plugins/claude-context/scripts/lib/redact.mjs
Shared runtime utilities
- Atomic file writes
plugins/claude-context/scripts/lib/atomic-write.mjs - Config paths
plugins/claude-context/scripts/lib/config-dir.mjs - Token calculations
plugins/claude-context/scripts/lib/token-math.mjs - Time utilities
plugins/claude-context/scripts/lib/time.mjs
Other components
- Claude Code
- Agent
Connections 27
- Claude Code → Statusline collector: sends statusline data
README.md - Statusline collector → Statusline input: reads input
plugins/claude-context/scripts/collect.mjs - Statusline collector → Token calculations: calculates usage
plugins/claude-context/scripts/collect.mjs - Statusline collector → Time utilities: normalizes resets
plugins/claude-context/scripts/collect.mjs - Statusline collector → Config paths: resolves snapshot path
plugins/claude-context/scripts/collect.mjs - Statusline collector → Snapshot store: writes snapshot
plugins/claude-context/scripts/collect.mjs - Snapshot store → Atomic file writes: writes atomically
plugins/claude-context/scripts/lib/snapshot.mjs - Agent → Report skill: requests report
README.md - Report skill → Resource report: runs report script
README.md - Resource report → Snapshot store: reads snapshots
plugins/claude-context/scripts/report.mjs - Resource report → Config paths: resolves session paths
plugins/claude-context/scripts/report.mjs - Resource report → Transcript analysis: reads usage and compactions
plugins/claude-context/scripts/report.mjs - Resource report → Token calculations: calculates context
plugins/claude-context/scripts/report.mjs - Resource report → Time utilities: formats reset times
plugins/claude-context/scripts/report.mjs - Resource report → Agent: returns summary and JSON
README.md - Setup command → Statusline wiring: configures statusline
README.md - Teardown command → Statusline wiring: restores statusline
README.md - Statusline wiring → Command builder: builds wrapper command
plugins/claude-context/scripts/wiring.mjs - Statusline wiring → Ownership marker: detects ownership
plugins/claude-context/scripts/wiring.mjs - Statusline wiring → Command redaction: previews commands
plugins/claude-context/scripts/wiring.mjs - Command builder → Ownership marker: creates marker
plugins/claude-context/scripts/lib/command.mjs - Command builder → Statusline collector: launches collector variant
plugins/claude-context/scripts/lib/command.mjs - Command builder → Coexist wrapper: launches coexist variant
plugins/claude-context/scripts/lib/command.mjs - Coexist wrapper → Statusline collector: invokes collector
plugins/claude-context/scripts/coexist.mjs - Coexist wrapper → Snapshot store: uses snapshot support
plugins/claude-context/scripts/coexist.mjs - Statusline wiring → Config paths: resolves settings paths
plugins/claude-context/scripts/wiring.mjs - Statusline wiring → Atomic file writes: persists settings
plugins/claude-context/scripts/wiring.mjs