Skip to content

Expose sk-* utilities via bin/ - #45

Merged
minarc merged 1 commit into
mainfrom
feat/plugin-bin-utilities
Apr 22, 2026
Merged

minarc merged 1 commit into
mainfrom
feat/plugin-bin-utilities

Conversation

@minarc

@minarc minarc commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Claude Code plugins add everything in bin/ to the Bash tool's PATH while the plugin is active. This PR ships three utilities there, named to match the plugin's sk-* slash command namespace (/skillmeter:sk-activate, /skillmeter:sk-telemetry):

Path Latency Use case
/skillmeter:sk-telemetry disable (slash) 3–5s (LLM roundtrip × 2) Discoverability, autocomplete
! sk-telemetry disable (bin) <50ms Repeat toggles, scripting, power users

Both flows stay supported; this is additive.

Utilities

sk-telemetry {enable|disable|status} — thin wrapper around scripts/telemetry.js. Same effect as the slash command, no LLM roundtrip.

sk-jwt — prints decoded license JWT metadata (iss/sub, org id + login, github_id, telemetry_endpoint, iat, exp, validity vs the 5-minute refresh skew, device id). Never prints the raw token body. Uses the credstore's unsafe decoder since output is local diagnostic only.

sk-refresh — clears stored license + resets gh silent-failure cooldown, then runs scripts/activate.js. Useful for tenant swaps, rotated licenses, or testing the silent path.

Design

All three resolve the plugin root from path.resolve(__dirname, "..") (bin/ sits at plugin root), so they work:

  • inside Claude Code when CLAUDE_PLUGIN_ROOT is injected
  • from a bare shell if PATH includes the bin/ dir
  • from Claude Code's ! prefix, which runs the binary with the plugin's PATH entry available

No code duplication: sk-telemetry delegates to scripts/telemetry.js via require(); sk-refresh delegates to scripts/activate.js the same way.

Naming

sk-* matches the plugin's slash command namespace, which users already type. sk alone is the skim fuzzy finder's binary on some systems; the multi-part sk-telemetry / sk-jwt / sk-refresh names don't collide with it.

Verified

  • node -c on all three files
  • sk-telemetry status — prints current state
  • sk-jwt with seeded valid token — full metadata block, status valid
  • sk-jwt with seeded expired token — status EXPIRED
  • sk-refresh against a seeded license + 24h cooldown — stderr clearing stored license JWT, license_jwt reset to null, cooldown reset to 0, then activate.js starts the silent-gh flow (terminated before real network call in the test)

Executable bits set (git preserves mode).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added sk-jwt command to view stored license information and device ID with decoded token details and validity status.
    • Added sk-refresh command to clear stored license and re-trigger the activation workflow.
    • Added sk-telemetry command to manage telemetry settings with enable, disable, and status options.

@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Three new executable Node.js CLI scripts added to skillmeter/bin/: sk-jwt decodes and reports stored license JWT payloads, sk-refresh clears the cached JWT and reinvokes activation, and sk-telemetry forwards telemetry subcommands (enable/disable/status) to the telemetry module.

Changes

Cohort / File(s) Summary
JWT & License Management CLI
skillmeter/bin/sk-jwt, skillmeter/bin/sk-refresh
sk-jwt decodes stored JWT payload without exposing raw token, reports selected claims and validity status; sk-refresh clears license token from credstore, resets gh retry cooldown, and invokes activation workflow.
Telemetry Management CLI
skillmeter/bin/sk-telemetry
Simple wrapper that loads and forwards telemetry subcommands (enable, disable, status) to scripts/telemetry.js.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • jhunlee-dev

Poem

🐰 Three CLI friends now hopping about,
sk-jwt reads what tokens shout,
sk-refresh clears the old and tries anew,
sk-telemetry tracks what users do,
Scripts bundled with love, now ready to run! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Expose sk-* utilities via bin/' is a clear, concise summary of the main change—adding three executable CLI utilities to the bin/ directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/plugin-bin-utilities

Comment @coderabbitai help to get the list of available commands and usage tips.

Claude Code plugins add everything in bin/ to the Bash tool's PATH
while the plugin is active. This commit ships three utilities there,
named to match the plugin's sk-* slash command namespace:

  sk-telemetry {enable|disable|status}
    Thin wrapper around scripts/telemetry.js. Same effect as the
    /skillmeter:sk-telemetry slash command but runs in under 50ms
    because it doesn't go through Claude's tool-use loop twice.

  sk-jwt
    Prints the stored license JWT's decoded metadata in a tidy
    block: iss/sub, org id + login, github_id, telemetry_endpoint,
    iat, exp, validity status relative to the 5-minute refresh
    skew, and the device id stored alongside. Never prints the raw
    token body. Uses the unsafe decoder from credstore (no
    signature check) because the output is local diagnostic only.

  sk-refresh
    Clears any stored license JWT, resets the gh silent-failure
    cooldown, then runs scripts/activate.js. Useful for swapping
    tenants without waiting 15 minutes for natural expiry, recover-
    ing from a rotated license, or testing the silent-gh path.

All three resolve the plugin root from __dirname (bin/ sits at the
plugin root), so they work whether CLAUDE_PLUGIN_ROOT is injected
by Claude Code or the binary is invoked from a bare shell.

The sk- prefix matches the slash command names the user already
types (/skillmeter:sk-activate, /skillmeter:sk-telemetry). `sk`
alone is the skim fuzzy finder's binary on some systems; the multi-
part sk-* names don't collide with it.

Verified:
  - node -c on all three files
  - sk-telemetry status → prints current state
  - sk-jwt with seeded valid token → full metadata block, status=valid
  - sk-jwt with seeded expired token → status=EXPIRED
  - sk-refresh against a seeded license + cooldown → stderr
    "clearing stored license JWT", license_jwt reset to null,
    cooldown reset to 0, then activate.js begins the silent-gh
    flow (terminated before network call)

Files have executable bit set (git preserves mode).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
skillmeter/bin/skillmeter-show-jwt (1)

31-33: Keep show command read-only (avoid implicit device ID creation).

credstore.getDeviceId(LOG_DIR) creates and persists a new device ID when absent. For an inspection utility, a non-mutating read path would be safer to avoid changing credential state during diagnostics.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skillmeter/bin/skillmeter-show-jwt` around lines 31 - 33, The show command
currently calls credstore.getDeviceId(LOG_DIR) which auto-creates and persists a
device ID; change the script to use a non-mutating read instead (e.g.,
credstore.getDeviceIdIfExists or credstore.peekDeviceId) so the inspection
remains read-only, and fall back to "(none)" if that read returns
null/undefined; if such a non-creating accessor doesn't exist, add one to
credstore and use it here (referencing token, getLicenseToken,
getDeviceId/peekDeviceId, and LOG_DIR to locate the change).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skillmeter/bin/skillmeter-show-jwt`:
- Around line 51-55: The ternary branch producing "expiring soon" is unreachable
because expired (computed by isLicenseTokenExpired(token)) already applies a
5-minute skew, so any token with secsUntilExp < 60 will be marked expired;
remove the unreachable branch and simplify statusLabel to only check expired vs
not expired (i.e., set statusLabel based on expired and otherwise "valid") by
updating the expression around statusLabel (referencing statusLabel, expired,
isLicenseTokenExpired, and secsUntilExp).

---

Nitpick comments:
In `@skillmeter/bin/skillmeter-show-jwt`:
- Around line 31-33: The show command currently calls
credstore.getDeviceId(LOG_DIR) which auto-creates and persists a device ID;
change the script to use a non-mutating read instead (e.g.,
credstore.getDeviceIdIfExists or credstore.peekDeviceId) so the inspection
remains read-only, and fall back to "(none)" if that read returns
null/undefined; if such a non-creating accessor doesn't exist, add one to
credstore and use it here (referencing token, getLicenseToken,
getDeviceId/peekDeviceId, and LOG_DIR to locate the change).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9c5c793d-8fdc-4c04-9bde-6682f2b015b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1d256f8 and 0107a7a.

📒 Files selected for processing (3)
  • skillmeter/bin/skillmeter-force-refresh
  • skillmeter/bin/skillmeter-show-jwt
  • skillmeter/bin/skillmeter-telemetry

Comment thread skillmeter/bin/sk-jwt
Comment on lines +51 to +55
const statusLabel = expired
? "EXPIRED (or within 5-minute refresh skew)"
: secsUntilExp !== null && secsUntilExp < 60
? "expiring soon"
: "valid";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

expiring soon status is currently unreachable.

Because expired is computed via isLicenseTokenExpired(token) (5-minute skew), any token under 60s is already classified into the first branch. The expiring soon branch never executes.

Suggested simplification
-const statusLabel = expired
-  ? "EXPIRED (or within 5-minute refresh skew)"
-  : secsUntilExp !== null && secsUntilExp < 60
-    ? "expiring soon"
-    : "valid";
+const statusLabel = expired
+  ? "EXPIRED (or within 5-minute refresh skew)"
+  : "valid";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const statusLabel = expired
? "EXPIRED (or within 5-minute refresh skew)"
: secsUntilExp !== null && secsUntilExp < 60
? "expiring soon"
: "valid";
const statusLabel = expired
? "EXPIRED (or within 5-minute refresh skew)"
: "valid";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skillmeter/bin/skillmeter-show-jwt` around lines 51 - 55, The ternary branch
producing "expiring soon" is unreachable because expired (computed by
isLicenseTokenExpired(token)) already applies a 5-minute skew, so any token with
secsUntilExp < 60 will be marked expired; remove the unreachable branch and
simplify statusLabel to only check expired vs not expired (i.e., set statusLabel
based on expired and otherwise "valid") by updating the expression around
statusLabel (referencing statusLabel, expired, isLicenseTokenExpired, and
secsUntilExp).

@minarc
minarc force-pushed the feat/plugin-bin-utilities branch from 0107a7a to 3909cb7 Compare April 22, 2026 18:04
@minarc minarc changed the title Expose skillmeter-* utilities via bin/ Expose sk-* utilities via bin/ Apr 22, 2026
@minarc
minarc merged commit c36bd0a into main Apr 22, 2026
1 check was pending
@TheStarkor
TheStarkor deleted the feat/plugin-bin-utilities branch September 21, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant