Adapter skill: /Users/blingabc/.promptify/current/adapters/codex/skills/promptify/SKILL.md Fallback instructions: /Users/blingabc/.promptify/current/adapters/codex/instructions/promptify.md Shared rules: /Users/blingabc/.promptify/current/shared
Codex-Claude-Monitor is a local VS Code extension that shows the current Codex or Claude Code context usage percentage in the status bar.
The project uses CommonJS, Node built-in modules, and the vscode API. There is no build step and no runtime dependency beyond VS Code.
Run all tests:
npm testRun one test file:
node --test test/claudeUsage.test.jsLocal development install:
ln -s /path/to/codex-claude-monitor ~/.vscode/extensions/codex-claude-monitorThen run Developer: Reload Window in VS Code.
Data flow:
local session JSONL files -> provider parsers -> latest active provider -> VS Code status bar
Workspace filtering is handled outside the VS Code entry point where possible. readLatestAgentUsage accepts optional workspaceFolders as absolute paths. Empty or missing workspaceFolders means no filtering.
src/sessionFiles.js: shared provider utilities for recursive file scanning, mtime sorting, JSONL parsing, context percentage calculation, and cached last-matching-event reads.src/codexUsage.js: scans~/.codex/sessionsforrollout-*.jsonl, reads the latesttoken_countevent, and useslast_token_usage.input_tokens / model_context_window.src/claudeUsage.js: scans~/.claude/projectsfor.jsonl, reads the latest assistantmessage.usage, and infers the context window from the model name. Files without an assistant usage entry (e.g. probe sessions) are skipped, trying the newest 10 by mtime.src/claudeRateLimits.js: probes Claude subscription usage by runningclaude -p "/usage"asynchronously and parsing the "Current session" / "Current week (all models)" lines into the Codex-shapedrateLimitsobject, including the trailingresets …text parsed intoresets_at(Unix seconds, machine-local wall clock, nearest-year inference); resolves the CLI path across common install locations. Failures resolvenull.src/agentUsage.js: aggregation and formatting layer. It reads provider candidates, selects the most recentupdatedAt, attaches probedclaudeRateLimitswhen Claude wins, and formats status bar text (provider, context percent, and compact rate-limit segments using codicon icons, e.g.Codex $(comment) 3% · $(history) 45% · $(calendar) 23%orClaude $(comment) 50% · $(history) 25% · $(calendar) 8%), tooltip text, usage severity (low/medium/high, used byextension.jsfor status bar coloring), model details, and rate-limit rows. The friendly model name and rate-limit reset times (absolute time plus a relative countdown, e.g.Reset at 14:32 (in 2h 13m)) are kept out of the status bar and surfaced only in the tooltip.src/extension.js: the only file that depends on thevscodeAPI. It owns the status bar item, refresh timer, the Claude usage probe timer (default 15 min,claudeUsageProbeIntervalMs, 0 disables, minimum 5 min to avoid tripping Anthropic's rate limiting), configuration reads, workspace folder extraction, andagentTokenStatus.refresh.
Provider contract:
{
provider,
sessionFile,
updatedAt,
contextTokens,
contextWindow,
contextPercent,
...
}New providers should implement that shape and be added to the candidate list in src/agentUsage.js. Formatting should remain in the aggregation layer.
- Keep parsing and formatting logic independent from the
vscodeAPI so it can be tested with Node's built-in test runner. - Keep changes small and scoped to the requested behavior.
- Do not introduce a build system, bundler, or dependency unless the task explicitly requires it.
- Preserve public command ids and configuration keys such as
agentTokenStatus.refresh,agentTokenStatus.sessionsRoot,agentTokenStatus.claudeRoot,agentTokenStatus.refreshIntervalMs,agentTokenStatus.claudeUsageProbeIntervalMs, andagentTokenStatus.claudeCliPath. - When adding support for new Claude model context windows, update
inferClaudeContextWindowinsrc/claudeUsage.js. - Test fixtures should use
test/testUtils.jshelpers such asmakeTempDir,writeJsonl, andsetMtime.
For behavior or parser changes, run:
npm testFor UI-facing text changes, update the matching expectations in test/agentUsage.test.js and verify the extension manually in VS Code when practical:
- Run
Developer: Reload Window. - Confirm the status bar shows the active provider, context percentage, and the severity color (green / yellow / red).
- Hover the status bar item to inspect tooltip details.
- Click the status bar item and confirm it refreshes without opening a notification.