Skip to content

ludevdot/ludev-code-metrics

Repository files navigation

Ludev Code Metrics

A VS Code extension that shows your Claude Code subscription usage β€” session (5h) and weekly (7d) β€” directly in the Status Bar and in a dedicated sidebar panel.

πŸ“Έ Screenshots

Usage Overview

Session & Weekly Usage

Skills Management

Skills Browser & Install

Status Bar

Status Bar Styles

Features

  1. Status Bar items β€” live session and weekly usage at a glance, always visible.
  2. Four display styles β€” gradient (β–°β–±), blocks (β–ˆβ–‘), icon-only, or icon + gradient bar.
  3. Dynamic colors β€” green text in normal state β†’ warning background β†’ error background as usage rises.
  4. Sidebar panel β€” Activity Bar icon opens a panel with SVG circular progress rings, a linear bar, and reset countdowns.
  5. Style picker β€” radio buttons inside the panel to switch styles instantly, no settings file needed.
  6. Overview card β€” compact linear summary of Session (5h), Weekly (7d), and Opus (7d) usage in a single glance; the Opus row is hidden automatically when no Opus data is available.
  7. Compact / Extended mode β€” toggle between Extended (Session + Weekly detail cards) and Compact (Overview summary only) directly from the panel; preference is persisted per-user.
  8. Subscription plan badge β€” displays your plan (Free, Pro, Max 5Γ—, Max 20Γ—, Team…) in the sidebar header, read from local credentials.
  9. Skills browser β€” search and install Claude Code skills from skills.sh directly from the sidebar; installs into the current workspace's .claude/skills/ directory.
  10. Persistent tab β€” the sidebar remembers the last open tab (Usage or Skills) between panel hide/show cycles.
  11. Multilingual UI β€” automatically follows VS Code's display language (English, Spanish, Italian, French).
  12. Stale indicator β€” shows ~ when the last fetch failed but cached data is available.
  13. Cross-platform credentials β€” reads automatically from ~/.claude/.credentials.json (written by Claude Code CLI). No manual token setup required in most cases.
  14. Click to refresh β€” clicking either status bar item triggers an immediate update.
  15. Enter token manually β€” Command Palette command and sidebar button to paste a raw OAuth token when automatic resolution fails.
  16. Set credentials path β€” Command Palette command and sidebar button to point to a custom credentials JSON file; unlocks the plan badge in addition to usage data.
  17. Startup notification β€” if no credentials are found at launch, a notification appears with an option to set credentials immediately or skip.
  18. Activity Bar badge β€” the sidebar icon shows a 1 badge while no credentials are configured, disappearing once a valid token is found.

Quick Start

  1. Install the extension from the VS Code Extension menu or the Marketplace.
  2. Make sure Claude Code CLI is installed and you are logged in β€” credentials are read automatically.
  3. The two status bar items appear on the right side of the Status Bar immediately.
  4. Click the clock icon in the Activity Bar to open the usage panel.

If credentials are not found automatically, open the Command Palette (Cmd/Ctrl + Shift + P) and run Claude Usage: Enter Token Manually, or click the Enter token manually button in the sidebar panel.

πŸš€ Quick Start

  1. Install the extension from VS Code Marketplace.
  2. Authenticate with your Claude Code token (auto-detect or manual).
  3. Track usage in Status Bar or open the dedicated sidebar.
  4. Browse & install skills directly from VS Code.

Status Bar

Two items are shown on the right side of the Status Bar:

Item Priority Default format
Session (5h rolling) Right, 100 $(clock) β–°β–°β–°β–°β–°β–±β–±β–±β–±β–± Session: 45% Β· 2h left
Weekly (7d rolling) Right, 99 $(calendar) β–°β–°β–°β–°β–±β–±β–±β–±β–±β–± Weekly: 26% Β· 3d left

Colors change automatically:

Threshold Effect
< warningThreshold (default 80%) Text colored charts.green so the progress bar stands out
β‰₯ warningThreshold statusBarItem.warningBackground (orange)
β‰₯ 95% statusBarItem.errorBackground (red)

Clicking either item refreshes immediately.

Sidebar Panel

Click the gauge icon in the Activity Bar to open the Ludev Code Metrics panel.

The panel shows:

  • Circular SVG progress ring β€” fills and changes colour with usage level.
  • Linear bar β€” secondary visual below the ring info.
  • Reset countdown β€” "2h left", "3d left", etc.
  • Subscription plan badge β€” your plan (Free, Pro, Max 5×…) shown in the header when credentials are loaded from the local store (Keychain or ~/.claude/.credentials.json). Hidden in the no-auth state, and not shown when using a manual token (see note below).
  • Stale badge β€” appears if the last API call failed and cached data is shown.
  • Refresh button β€” triggers an immediate API call (30-second cooldown to avoid rate limits).
  • Enter token manually button β€” shown in the no-auth state; opens an input box to paste a raw token. Usage data loads but the plan badge will not appear.
  • Set credentials path button β€” shown alongside the token button; opens a native file picker to select the Claude Code credentials JSON. Provides full credentials including the plan badge.
  • Activity Bar badge (1) β€” visible on the sidebar icon whenever no credentials are configured.
  • Overview card β€” compact linear progress bars for Session (5h), Weekly (7d), and Opus (7d) all in one row. Visible in Compact mode. The Opus row is hidden if the API returns no Opus data.
  • View mode toggle β€” Extended (default) shows the Session and Weekly detail cards; Compact shows the Overview card only. Switching saves the preference to VS Code settings.
  • Style picker β€” four radio buttons to switch the Status Bar display style live.
  • Last updated timestamp at the bottom.

Skills Browser

The Skills tab in the sidebar lets you discover and install skills.sh skills without leaving VS Code.

  • Auto-load β€” the skill list loads automatically the first time you open the tab (top 50 results).
  • Search β€” type two or more characters to filter skills by name.
  • Per-skill actions β€” each result shows two buttons:
    • Install β€” downloads SKILL.md from GitHub and writes it to .claude/skills/<skillId>/SKILL.md in your current workspace, then updates skills-lock.json.
    • View on skills.sh β€” opens the skill's page in your browser.
  • Installed indicator β€” once installed, the Install button turns green and is disabled.
  • Result cap β€” when 50 results are returned a hint appears to refine the query.

Skills are installed per workspace, not globally. Requires an open workspace folder.

Configuration

Open Settings (Cmd/Ctrl + ,) and search for ludevMetrics.

Setting Type Default Description
ludevMetrics.barStyle string "gradient" Status bar display style: gradient, blocks, icon-only, icon+gradient
ludevMetrics.refreshInterval number 60 Poll interval in seconds (minimum 30)
ludevMetrics.warningThreshold number 80 Usage % at which the warning colour activates
ludevMetrics.credentialsPath string "" Path to a custom credentials JSON file (full credentials, includes plan type)
ludevMetrics.viewMode string "extended" Sidebar view mode: extended (Session + Weekly cards) or compact (Overview only)
ludevMetrics.manualToken string "" Raw OAuth token fallback (usage data only, no plan badge)

All settings take effect immediately β€” no reload required.

Bar styles

Value Status bar looks like
gradient $(clock) β–°β–°β–°β–°β–°β–±β–±β–±β–±β–± Session: 45% Β· 2h left
blocks $(clock) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘ Session: 45% Β· 2h left
icon-only $(pass) Session: 45% Β· 2h left β†’ $(warning) β†’ $(error)
icon+gradient $(pass) β–°β–°β–°β–°β–°β–±β–±β–±β–±β–± Session: 45% Β· 2h left

Credential Resolution

The extension tries the following sources in order and uses the first valid token found:

  1. macOS only: system Keychain via security find-generic-password -s "Claude Code-credentials".
  2. ~/.claude/.credentials.json β€” written automatically by Claude Code CLI (all platforms).
  3. ~/.claude/credentials.json β€” alternative path.
  4. Linux only: secret-tool lookup service "Claude Code-credentials".
  5. Windows only: %APPDATA%\claude\credentials.json.
  6. ludevMetrics.credentialsPath setting β€” or run Claude Usage: Set Credentials File Path from the Command Palette / sidebar button. Point to any valid credentials.json file; provides full credentials including the plan badge.
  7. ludevMetrics.manualToken setting β€” or run Claude Usage: Enter Token Manually from the Command Palette / sidebar button. Raw token only.

Note β€” manual token limitations: sources 1–5 provide the full credentials JSON, which includes the subscriptionType field used to display the plan badge (Pro, Max 5Γ—, etc.). Source 6 is a raw token string only β€” the extension can fetch and display your usage data normally, but the plan badge will not appear because the subscription type is not available from the token alone and is not returned by the usage API.

The token is never logged or written to disk by this extension.

Internationalization

The UI automatically follows the display language configured in VS Code. Supported languages:

Locale Language
en English (default)
es Spanish / EspaΓ±ol
it Italian / Italiano
fr French / FranΓ§ais

How it works: strings in TypeScript files use vscode.l10n.t(). Webview strings are pre-translated on the extension host and injected as a JSON constant. Manifest strings (command names, setting descriptions) use package.nls.*.json files. Translation bundles live in l10n/bundle.l10n.{locale}.json.

To add a new language, create l10n/bundle.l10n.{locale}.json (following the existing files as templates) and package.nls.{locale}.json for the manifest strings.

Architecture

Source files under src/:

File Responsibility
extension.ts Entry point β€” wires up UsageStatusBar and UsageSidebarProvider
statusBar.ts Two StatusBarItem instances, polling interval, stale cache, config listener
sidebarView.ts WebviewViewProvider β€” assembles the HTML panel, routes webview messages
usageApi.ts HTTPS fetch to api.anthropic.com/api/oauth/usage (Node built-ins only)
credentials.ts Cross-platform token resolution; also exports getSubscriptionType()
skillsManager.ts skills.sh API search, skill installation (SKILL.md + skills-lock.json), cache
usageHistory.ts Snapshot ring-buffer for historical usage data
utils.ts Pure helpers: formatTimeLeft, buildProgressBar, getColorByUsage, getTextColorByUsage, getDynamicIcon

Sidebar sub-modules under src/sidebar/:

File Responsibility
sharedStyles.ts Base CSS (layout, tabs, buttons, animations) shared across all panels
usageTab.ts Usage tab HTML, styles, and client-side script
skillsTab.ts Skills tab HTML, styles, and client-side script
types.ts SidebarI18n interface β€” all localizable strings for the webview

i18n files:

File/Folder Purpose
package.nls.json English manifest strings (command titles, setting descriptions)
package.nls.{locale}.json Translated manifest strings
l10n/bundle.l10n.{locale}.json Runtime translation bundles for vscode.l10n.t()

Testing

Unit tests are written with Vitest and run without a VS Code instance. The vscode module is replaced by a lightweight mock so tests execute in plain Node.js.

pnpm test          # run all tests once
pnpm test:watch    # watch mode during development
Test file What is covered
src/test/utils.test.ts formatTimeLeft, buildProgressBar, getDynamicIcon, getColorByUsage
src/test/usageApi.test.ts fetchUsage β€” 200/non-200 responses, bad JSON, network errors, timeout, headers
src/test/credentials.test.ts getAccessToken β€” file paths, JSON errors, Linux secret-tool, manual token fallback
src/test/sidebarView.test.ts UsageSidebarProvider β€” HTML generation, message handling, i18n

Change Log

See CHANGELOG.md for the full version history.

This project uses Changesets for versioning.

In your feature branch:

pnpm changeset        # choose bump type (patch/minor/major) and write a summary
git add .
git commit            # the .changeset/*.md file is committed alongside your code

On merge to main: a GitHub Action consumes the changesets, bumps package.json, and updates CHANGELOG.md via an automatic "Version Packages" PR.

πŸ”— Repository Links

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository

  2. Create your feature branch (git checkout -b feature/AmazingFeature)

  3. Commit your changes (git commit -m 'Add some AmazingFeature')

  4. Create a changeset before opening the PR:

    pnpm changeset

    This will prompt you to:

    • Select the bump type (patch, minor, or major)
    • Write a summary of your changes

    A new file will be created in .changeset/ β€” commit this file alongside your code.

  5. Push to the branch (git push origin feature/AmazingFeature)

  6. Open a Pull Request

Note: Changesets are consumed automatically when merging to main, which bumps the version and updates CHANGELOG.md.

About

A VS Code extension to manage your Claude Code tools and usage.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors