agentleFS
poweruserzpoweruserz/OpenTokenUsage/.claude/skills/add-provider/SKILL.md

add-provider

Skill76 starsChanged 8 months agoMITView on GitHub

Add a new AI tool (provider) to OpenTokenUsage, or move an existing provider to a new API, touching every place a provider lives (plugin, manifest, tests, error strings, 11 locales, log redaction, Rust tables, docs, README, site). Use for "add X support", a provider request issue, or a provider whose endpoint changed (e.g. a 405 or a wrong number).

23 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use add-migration, add-tool and 3 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • PipelexSkill

    add-migration

    Write a migration ledger entry for a configuration schema change in pipelex, so that a user's existing file can be repaired instead of thrown away. Use when `make check-migration-schemas` (alias `cmig`) or `make check-ledger` (alias `cl`) refuses a change, when the user says "add a migration", "write the ledger entry", "the coverage gate is failing", "bump the schema version", "migration entry", "the migration gate won't let me", "account for this schema change", or after any edit to a configuration model that removed a key, renamed one, moved one, retired an enum member, or tightened what a value may be. This is the only skill that writes a ledger.

    Also in 3 projects that use this

  • MicrosoftSkill

    add-tool

    Add a new tool to PilotSwarm. Covers defining the tool with defineTool(), registering it on the worker (worker-level or per-session), referencing it from the client via toolNames, and adding an integration test.

    Also in 3 projects that use this

  • Microsoft AzureSkill

    release-notes

    Author and update release notes for Azure App Configuration libraries and providers. USE FOR: write release notes, add release note entry, update release notes, draft release notes, new version release notes, format release notes. DO NOT USE FOR: generating changelogs from git history, writing internal engineering notes.

    Also in 3 projects that use this

  • Microsoft AzureSkill

    verify

    End-to-end app testing pipeline for browser-based web apps on cloud browsers via Azure Playwright Workspaces: verify the live app, author tests for working flows, heal failing tests, then re-run with video and produce one consolidated report. Three phases (app verification, test authoring, test healing) plus a scoped final sanity run; each phase emits a sub-report. Use when asked to "verify my app", "make sure my app works and has good test coverage", "do a full QA pass", "add tests where I'm missing coverage", "fix failing tests and add new ones", "smoke test before deploy", "QA my deployment", or any combined verify-and-test ask. Requires Azure CLI (`az login`) and a Playwright Workspace resource ID — bootstraps configs on first invocation. Browser-based web apps with Playwright only — not for unit/API tests, native mobile/desktop, load/perf, or full accessibility audits.

    Also in 3 projects that use this

  • SentrySkill

    commit

    Create commit messages following Sentry conventions. Use when committing code changes, writing commit messages, or formatting git history. Follows conventional commits with Sentry-specific issue references.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 20 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Look for it in reference projects: CodexBar (docs/<x>.md), ai-usagebar, quota-axi, and upstream's Swift provider (git show …

    line 15
  2. Distinctive:

    When probing live yourself, log host, status and key names only, never bodies or headers.

    line 21
  3. Very specific:

    Nothing set up: must throw a message isNotSetUpError (src/lib/plugin-errors.ts) knows, without any request (plugins/not-set-up.test.js).

    line 33

“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add or update a provider

A provider is a plugin in plugins/<id>/ plus a few tables around it. A missed table rarely fails a test: it shows up as a blank card, a log that leaks an email, or a "Sign in" button that does nothing. Work through every step below and tick off the ones that don't apply. Model on a recent one: plugins/muse/ (PR #92) or plugins/factory/ (PR #110).

0. Learn the API without guessing

  • Look for it in reference projects: CodexBar (docs/<x>.md), ai-usagebar, quota-axi, and upstream's Swift provider (git show upstream/main:Sources/OpenUsage/Providers/<X>/, CLAUDE.md "What this is").
  • Without a way to test, ask the reporter on the issue for: where the login lives (path and key names only), the request (host, path, method), and the response shape with values removed. Never ask for or accept tokens, keys or full responses. If calling the endpoint writes anything (mints a key, refreshes a token), stop and raise it with the owner first.
  • When probing live yourself, log host, status and key names only, never bodies or headers.

1. The plugin

FileWhat
plugins/<id>/plugin.jsonschemaVersion: 1, id, name, version: "0.0.1", entry, icon, brandColor, links (dashboard), lines. Every label the card can show is declared with scope: "overview" (and primaryOrder), or that account gets a blank card. Weekly windows get "period": "weekly". A CLI that also runs in WSL gets "wsl": { "login": [<login paths>] }.
plugins/<id>/icon.svgThe brand mark in one color: fill="currentColor" (the app tints it).
plugins/<id>/plugin.jsIIFE ending in globalThis.__openusage_plugin = { id, probe } (plus accountKey from local files when it has WSL). A fresh QuickJS runtime per probe: nothing survives in module variables; keep state under ctx.app.pluginDataDir. Don't re-implement 429 backoff or timeouts (the host does).
plugins/<id>/plugin.test.jsmakeCtx from ../test-helpers.js, loadPlugin via globalThis.__openusage_plugin. Cover: not set up, rejected login, each line, missing fields, any date or period math (month ends, leap years).

Rules the shared tests enforce:

  • Nothing set up must throw a message isNotSetUpError (src/lib/plugin-errors.ts) knows, without any request (plugins/not-set-up.test.js); otherwise first-start detection turns the card on for everyone.
  • A rejected login throws "Session expired …", never a not-set-up message.
  • A probe with side effects (writes, key minting): add the id to MANUAL_ONLY in src/hooks/app/use-provider-detection.ts so first-start detection skips it and only the user turns it on. That is all it does: once on, Smart refresh probes it every few minutes, so the plugin itself must limit its calls (keep the last answer in pluginDataDir and return it until the next call is due, as plugins/muse/ does) plus a floor in smartFloorMinutes (src/lib/smart-refresh.ts). A tight rate budget gets the same.

2. Text and translations

  • Error strings: reuse the shapes in src/lib/plugin-errors.ts ("Not logged in. Run x login to authenticate.", "Session expired. …", "Rate limited by X, retry in ~10m") so they get translated. Add each string to FIXTURES in src/lib/plugin-errors.test.ts. A new shape needs a pattern in PLUGIN_ERROR_PATTERNS (src/lib/plugin-errors.ts), a key in all 11 src/locales/plugin-errors/*.ts, and, when it means "nothing set up" or "sign in", its key in NOT_SET_UP or ACTION_NEEDED in the same file (otherwise first start turns the card on, or a signed-out card shows red instead of grey).
  • Line labels: reuse existing label.* keys in src/locales/en.ts (Session, Weekly, Monthly, Credits …). A new label needs label.<Label> in all 11 src/locales/*.ts, then bun run locales:lock to refresh src/locales/en.lock.json, only after all 11 are translated.

3. Rust tables (only those that apply)

  • src-tauri/src/plugin_engine/host_api.rs redact_body: every identity field the new endpoint returns (email, name, ids, card, checkout links) goes into the list, with a test next to the others.
  • src-tauri/src/setup_actions.rs ALLOWED_COMMANDS: the exact login command the error text tells users to run (bump the array length).
  • src-tauri/src/foreground.rs: APPS (desktop exe), CLIS (CLI exe) or MARKERS (a node/bun CLI) so "Follow the active app" and "Only while an AI tool runs" know it.
  • src-tauri/src/tokscale.rs CLIENTS: only if tokscale's pinned version lists that client id (an unknown id fails the whole run). When that id differs from the plugin id, map it in LOCAL_CARDS (src/lib/spend.ts), as droid → factory, or its spend is set against the wrong card.

4. Docs and listings

  • docs/providers/<id>.md: Overview, Endpoints (headers, response as jsonc), Lines table, Authentication (where the login lives, refresh), WSL. Note it is reverse-engineered when it is.
  • README.md: a line in "Supported Providers" (- [**Name**](docs/providers/<id>.md) / what it shows) and the count in the header ("Copilot and N more AI coding tools").
  • CLAUDE.md: only a fact that is easy to get wrong (a manual-only probe, a rate floor).
  • Site (../opentokenusage.github.io, ships after the release that carries the provider): the list, every count (N more, N other AI, Works with N providers, the same in meta tags, JSON-LD and the visible FAQ), the provider list in llms.txt, assets/providers/<id>.svg (copy of the icon) with a .p-<id> color class in site.css (and a light-theme override when the brand color is dark), then bump site.css?v= in both index.html and 404.html.

5. Verify

bunx tsc --noEmit; bun run test
cd src-tauri; cargo check; cargo test --lib   # whenever Rust changed

With the account on this PC, the run-opentokenusage skill can try the build, but tell the owner first: launch restarts the app they may be using. Read the result with driver.ps1 usage, not ss (it copies screen pixels and has caught other windows); ask the owner for a screenshot instead. Without the account, say plainly that it is untested against the real service and ask the reporter to try the next build. A reviewer subagent reads the diff before the push.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.