Skip to content

Package tokenjam as a Claude Code plugin - #716

Merged
anshss merged 2 commits into
mainfrom
claude-code-plugin
Aug 11, 2026
Merged

anshss merged 2 commits into
mainfrom
claude-code-plugin

Conversation

@anshss

@anshss anshss commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Packages tokenjam as an installable Claude Code plugin, in its own subdirectory: plugin/ (plugin/.claude-plugin/plugin.json, name tokenjam) plus five slash commands (/onboard, /status, /optimize, /doctor, /uninstall) that wrap the existing tj CLI entry points — no new Python code, no reimplemented logic. plugin/README.md documents install (a git-subdir marketplace source with path: "plugin") and the commands.
  • The plugin root lives in a subdirectory rather than the repo root so it doesn't collide with this repo's own CLAUDE.md (load-bearing dev context, unrelated to plugin behavior) — a subdirectory plugin root is an officially supported layout (git-subdir marketplace source, same pattern claude-plugins-official uses for its own example plugin).
  • The plugin intentionally ships no hooks/hooks.json and no .mcp.json:
    • A plugin's own settings.json only supports the agent and subagentStatusLine keys — there is no plugin-manifest path to the main terminal statusLine (plugins-reference, "File locations reference"; statusline docs). /onboard gets there by invoking tj onboard --claude-code instead.
    • Declaring the SessionStart resume-brief hook independently in the plugin would risk double-firing against tj onboard's own idempotent, marker-based hook wiring. /onboard delegates to the existing entry point, so there's exactly one writer of ~/.claude/settings.json.
    • tj mcp stays out of the default install — it's built for SDK/API integrations already in the request path; auto-wiring it for Claude Code would contradict the project's own measured decision (+36% token tax) to keep Claude Code users on the zero-token statusline instead.
  • Adds a short "Claude Code plugin" pointer section to the root README.

Test plan

  • claude plugin validate ./plugin — passes clean (✔ Validation passed, no warnings).
  • claude plugin validate ./plugin --strict — passes clean (✔ Validation passed), exit 0.
  • No Python code changed; no test suite impact (grepped tests/ for existing "plugin" references — test_deadweight_plugins.py etc. cover an unrelated tokenjam feature that prices other installed plugins' token cost, not this repo's own plugin packaging).

🤖 Generated with Claude Code

Adds .claude-plugin/plugin.json and slash commands (/onboard, /status,
/optimize, /doctor, /uninstall) that wrap the existing tj CLI entry points.

The plugin deliberately ships no hooks.json or .mcp.json: a plugin manifest
cannot register the main terminal statusLine at all (only subagentStatusLine
is supported), and declaring the SessionStart resume-brief hook independently
would risk double-firing against tj onboard's own idempotent hook wiring. So
/onboard simply invokes `tj onboard --claude-code`, keeping settings.json to
one writer. The MCP server (tj mcp) also stays out of the default install —
it's built for SDK/API integrations already in the request path, not for
Claude Code, where an in-loop MCP measurably taxes every turn.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@anshss
anshss requested a review from anilmurty as a code owner August 11, 2026 15:49
@greptile-apps

greptile-apps Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR packages TokenJam as a Claude Code plugin that delegates to the existing tj CLI rather than duplicating application logic.

  • Adds the plugin manifest and command definitions for onboarding, status, optimization, diagnostics, and uninstall.
  • Documents marketplace installation, CLI prerequisites, and the deliberate omission of plugin hooks and MCP configuration.

Confidence Score: 3/5

The PR is not yet safe to merge because command failures and warning states can still be presented to users as successful or as evidence that the CLI is missing.

The status and doctor wrappers conflate meaningful nonzero report states with a missing installation, while the uninstall wrapper confirms teardown despite underlying removal failures being reduced to warnings and successful exit statuses.

Files Needing Attention: plugin/commands/status.md, plugin/commands/doctor.md, plugin/commands/uninstall.md

Important Files Changed

Filename Overview
plugin/commands/status.md Adds a slash-command wrapper around the verbose TokenJam status report.
plugin/commands/doctor.md Adds a slash-command wrapper around TokenJam’s configuration, ingestion, and storage health check.
plugin/commands/uninstall.md Adds a slash-command wrapper for removing the CLI-managed Claude Code integration.
plugin/commands/onboard.md Adds installation detection and delegates Claude Code onboarding to the existing CLI.
plugin/.claude-plugin/plugin.json Defines the Claude Code plugin’s identity and package metadata.
plugin/README.md Documents plugin installation, available commands, and architecture choices.

Reviews (2): Last reviewed commit: "Move the Claude Code plugin into its own..." | Re-trigger Greptile

Comment thread plugin/commands/status.md
---

## tj status
!`tj status --verbose 2>&1 || echo "tj is not installed. Run /onboard first, or install with npx tokenjam@latest / pipx install tokenjam."`

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.

P1 Nonzero results report missing CLI

When tj status returns 1 for active alerts, this fallback says that tj is not installed, causing Claude to recommend installation instead of accurately presenting the alerts. The same pattern in commands/doctor.md mislabels warnings, and in commands/optimize.md mislabels configuration or validation errors.

Prompt To Fix With AI
This is a comment left during a code review.
Path: commands/status.md
Line: 7

Comment:
**Nonzero results report missing CLI**

When `tj status` returns 1 for active alerts, this fallback says that `tj` is not installed, causing Claude to recommend installation instead of accurately presenting the alerts. The same pattern in `commands/doctor.md` mislabels warnings, and in `commands/optimize.md` mislabels configuration or validation errors.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +9 to +10
## Instructions
Confirm to the user what was torn down (statusline, hooks, OTel env vars) and note that this only removes the CLI's Claude Code wiring, not the tokenjam plugin itself — that's removed separately via `/plugin uninstall tokenjam` or the plugin manager.

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.

P1 Failed teardown is confirmed successful

When removal of settings, hooks, environment configuration, files, or the package fails, tj uninstall reports the failure but still exits successfully; these instructions then tell Claude to confirm teardown, causing users to believe components were removed when they remain installed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: commands/uninstall.md
Line: 9-10

Comment:
**Failed teardown is confirmed successful**

When removal of settings, hooks, environment configuration, files, or the package fails, `tj uninstall` reports the failure but still exits successfully; these instructions then tell Claude to confirm teardown, causing users to believe components were removed when they remain installed.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

`claude plugin validate --strict` failed on the previous layout: with
.claude-plugin/plugin.json at the repo root, the validator also picked up
this repo's own CLAUDE.md (load-bearing dev context for the codebase, not
plugin behavior) and flagged it as "not loaded as project context."
Relocating the plugin to plugin/ removes the collision without touching
CLAUDE.md. A subdirectory plugin root is an officially supported layout
(git-subdir marketplace source with a required `path` field), the same
pattern claude-plugins-official itself uses for its example-plugin.

Adds plugin/README.md documenting install (via a git-subdir source pointing
at `path: "plugin"`) and the commands, and updates the root README's
pointer accordingly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@anshss
anshss merged commit d05aecb into main Aug 11, 2026
6 checks passed
@anilmurty
anilmurty deleted the claude-code-plugin branch September 18, 2026 21:02
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