Miqyasمقياس — Arabic for gauge. Claude Code session and weekly API usage, always visible in your VS Code status bar. Miqyas reads the OAuth credentials that Claude Code writes to your machine, makes a minimal probe call to Status bar
Hover the item for a full tooltip:
Threshold coloursThe entire item — cloud, cells, and text — recolours together. Higher severity wins when the two windows differ.
Thresholds are configurable (see Configuration). Prerequisites
Miqyas reads the credentials that Claude Code writes to the OS credential store. It never asks you to log in separately. InstallationFrom the VS Code MarketplaceSearch Miqyas in the Extensions panel (
From a
|
| Setting | Type | Default | Min | Description |
|---|---|---|---|---|
miqyas.enabled |
boolean | true |
— | Show or hide the status bar item |
miqyas.pollInterval |
number | 30 |
10 |
Seconds between usage fetches |
miqyas.warningThreshold |
number | 70 |
0 |
% at which the item turns yellow |
miqyas.criticalThreshold |
number | 90 |
0 |
% at which the item turns red |
settings.json example:
{
"miqyas.pollInterval": 60,
"miqyas.warningThreshold": 80,
"miqyas.criticalThreshold": 95
}
pollInterval is clamped to a minimum of 10 seconds regardless of the stored value. Setting it below 10 has no effect.
How it works
Credential source
Claude Code stores OAuth tokens in the OS credential store after claude auth login:
| Platform | Location |
|---|---|
| macOS | Keychain — security find-generic-password -s 'Claude Code-credentials' -w |
| Linux | ~/.claude/.credentials.json |
| Windows | WSL users: use the Linux path above |
Miqyas reads credentials once at startup, then re-reads only when a 401 response is received or when the expiresAt timestamp is within 60 seconds of expiry. It never writes, rotates, or revokes credentials.
Usage data
Claude's API returns rate-limit utilisation in response headers on every call. Miqyas makes a minimal 1-token probe call on each poll tick:
POST https://api.anthropic.com/v1/messages
Authorization: Bearer <accessToken>
Content-Type: application/json
anthropic-version: 2023-06-01
{ "model": "claude-haiku-4-5-20251001", "max_tokens": 1, "messages": [{"role":"user","content":"."}] }
The response headers carry the utilisation data:
anthropic-ratelimit-unified-5h-utilization: 0.24 ← session % used (0–1)
anthropic-ratelimit-unified-5h-reset: 1780743600 ← session reset (Unix seconds)
anthropic-ratelimit-unified-7d-utilization: 0.31 ← weekly % used (0–1)
anthropic-ratelimit-unified-7d-reset: 1780815600 ← weekly reset (Unix seconds)
Token consumption from probe calls is negligible — roughly 2 tokens per call, every 30 seconds.
Poll cycle
- Check
expiresAt; re-read credentials if within 60 s of expiry POSTtoapi.anthropic.com/v1/messageswith a 10 sAbortControllertimeout- Parse the four utilisation headers
- Update the status bar item text, tooltip, and colour
- On
429: multiply the poll interval by 2 (up to 4× the configured value); reset on the next successful response - On
401: re-read credentials and retry once before showing an error state
Error states
When Miqyas cannot display usage data it shows ☁ — in the status bar. Hovering explains why.
| Code | Cause | Tooltip |
|---|---|---|
NO_CREDENTIALS |
Credentials absent or unreadable | Run claude auth login in your terminal |
AUTH_FAILED |
Token rejected after re-read | Re-run claude auth login |
FETCH_FAILED |
Network error or unexpected HTTP status | Check your connection |
PARSE_FAILED |
Response headers missing or malformed | Check extension logs |
TIMEOUT |
Request did not complete within 10 s | Will retry next interval |
RATE_LIMITED |
API returned 429 |
Backing off automatically |
All diagnostic output is written to the Miqyas output channel (View → Output → Miqyas). Token values are never logged.
Troubleshooting
The item shows ☁ — immediately after install
Claude Code has not been authenticated yet. Run claude auth login in a terminal and follow the browser prompt.
macOS: a Keychain access dialog appears
The first read may trigger a system prompt asking whether VS Code can access the Claude Code-credentials keychain entry. Click Allow. Subsequent reads are silent.
The percentages never change
Check the Miqyas output channel for error messages. A persistent FETCH_FAILED usually means a corporate proxy is blocking api.anthropic.com.
The item disappears
miqyas.enabled may have been set to false. Open Settings, search Miqyas, and re-enable it.
Development
Requirements
- Node.js 18+
- VS Code
Setup
git clone https://github.com/miftahv-inc/miqyas.git
cd miqyas
npm ci
Verification (all three must pass before any change is considered complete)
npm test # → 33 tests, 0 failures
npm run lint # → 0 errors, 0 warnings
npm run format:check # → no diff
Run in VS Code
Open the project folder in VS Code and press F5. A new Extension Development Host window opens with Miqyas loaded. Look for the ☁ item in the status bar bottom-right.
Build
npm run compile # TypeScript → out/
npm run package # produces miqyas-<version>.vsix
Architecture
src/
extension.ts — activation, poll loop, config change listener
config.ts — single getConfiguration wrapper; enforces poll floor
credentialReader.ts — OS keychain / file read; returns Result<Credentials>
usageFetcher.ts — probe POST, header parse; returns Result<UsageData>
formatter.ts — bar glyphs, countdown strings, status bar text
display.ts — writes to StatusBarItem; maps error codes to tooltips
types.ts — shared interfaces and Result<T> type
media/
cub.woff — custom icon font (cloud, full cell, empty cell glyphs)
src/__tests__/
formatter.test.ts
credentialReader.test.ts
usageFetcher.test.ts
All I/O functions return Result<T> — they never throw. extension.ts is the only file that calls VS Code APIs directly.
Security
- Credentials are read from the OS credential store and held in memory only for the current session. They are never written to disk, logged, or sent anywhere other than
api.anthropic.com. execFile(notexec) is used for the macOS Keychain read — no shell injection surface.- All header values from the API go through
parseInt/parseFloatbefore use — no injection into status bar text. - No webview, no HTML surface, no script execution.
- The extension requests no VS Code permissions beyond
vscode.env.openExternal.
Changelog
0.0.1
- Initial release
- Session (5 h) and weekly (7 d) usage meters
- Custom icon font for crisp status bar rendering
- Yellow/red threshold colours
- 429 back-off, credential refresh on 401
License
MIT — see LICENSE.