plugin: add the cost-policy skill, two commands, and a Stop hook - #7
Draft
aadereiko wants to merge 2 commits into
Draft
plugin: add the cost-policy skill, two commands, and a Stop hook#7aadereiko wants to merge 2 commits into
aadereiko wants to merge 2 commits into
Conversation
Ships the plain-language layer that turns the session intro's "your Claude Code has been optimized" into something a developer can check for themselves. - skills/cost-policy/SKILL.md — which MCP servers org policy denies for this user, how to turn one off or back on for themselves, and how to read the outcome off `opik-cipx mcp`'s exit code so a refusal is never reported back as a success. Claude pulls it in on its own, which is the point: Claude Code drops a denied server silently, so the skill is usually how a user finds out what happened. - commands/cost-intelligence.md — the receipt. What cipx changed on this machine, what is blocked, what this session and the last 30 days cost and where the tokens went, which cost policies are in effect and who set each one, and for anything a policy turned off, the one route that turns it back on. Takes an optional MCP server / skill / tool / settings key to answer about just that one thing. - commands/mcp-policy.md — the MCP policy table on its own. - hooks/hooks.json — a Stop entry wired exactly like SessionStart and UserPromptSubmit. The launcher ignores the event argument and always runs `opik-cipx sync`, which is idempotent, so this is a no-op on the current 0.0.61 binary; it is here so a later binary can render its turn-end notice without another plugin release. The three markdown files are copied verbatim from the PoC branch and call `opik-cipx` as a bare command on PATH. That only resolves once the release following comet-ml/cost-intelligence-proxy-internal#123 lands the `bin/opik-cipx` dispatcher, so this must not merge before that release. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…intelligence-mcp Matches the PoC branch: the skill that explains policy and drives `opik-cipx mcp` is `cost-intelligence-policy`, the MCP slash command is `/cost-intelligence-mcp`, and the report command keeps `/cost-intelligence`. Files are byte-identical to the PoC's; the report command's stale "adds nothing to PATH" passage now reflects the bin/opik-cipx dispatcher the release adds. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every cipx session opens by telling the developer their Claude Code "has been optimized" and pointing them at a command. On its own that sentence is unverifiable, and until now the command it points at did not exist in the plugin. This PR ships the layer that makes the claim checkable.
What this adds
skills/cost-policy/SKILL.md— which MCP servers the org's cost policy denies for this user, how to turn one off or back on for themselves, and how to read the outcome offopik-cipx mcp's exit code (0 changed, 3 locked by an admin, 5 ambiguous, 9 backend refused, …) so a refusal is never handed back as "done". Claude pulls it in on its own, which is the whole point: Claude Code removes a denied MCP server silently — it vanishes from/mcpandclaude mcp listwith no warning — so this skill is usually how a user finds out what happened.commands/cost-intelligence.md(/opik-cipx:cost-intelligence [thing]) — the receipt. What cipx changed on this machine, what org policy blocks, what this session cost, what the last 30 days cost and where the tokens went, which cost policies are in effect and who set each one, and for anything a policy turned off, the one route that turns it back on. Given an argument it answers about that one MCP server / skill / tool / settings key and nothing else. The instructions are mostly guardrails against the model retelling the report: paste the measured output, never compute a figure, never conflate the three different kinds of dollar the spend section prints (real money,at listshadow price,cashmarginal), and never fill inin-planorn/awith$0.00.commands/mcp-policy.md(/opik-cipx:mcp-policy) — the policy table on its own, shown every time it is asked for.hooks/hooks.json— aStopentry, wired exactly like the existingSessionStartandUserPromptSubmitones:The launcher is untouched — hook forward-compat is a hard rule. It ignores the event argument it is passed and always runs
opik-cipx sync, which is idempotent, so this is a no-op on the current 0.0.61 binary: one extrasyncat the end of a turn, the same operationUserPromptSubmitalready performs at the start of one. It is here so a later binary can render its turn-end notice without needing another plugin release. Per the hooks docs aStophook that exits 0 with no stdout does not block or alter anything, and the launcher exits 0 even when it finds no binary.plugins/opik-cipx/hooks.json(the Codex variant) is deliberately not changed.This is release-gated, which is why it is a draft. All three markdown files call
opik-cipxas a bare command, and on the currently released plugin that does not work:bin/holds only per-platform directories (bin/opik-cipx-darwin-arm64/, …), so nothing on PATH answers toopik-cipx— bare calls reach the user as exit 127 /command not found.mcp,statuslineorcost-intelligencesubcommand —unknown command.The release that follows comet-ml/cost-intelligence-proxy-internal#123 fixes both: it adds those subcommands, and its "Stage binaries into public repo bin/" step writes a
bin/opik-cipxdispatcher that execs the right per-platform build. Claude Code puts an installed plugin'sbin/on the Bash tool's PATH, so that dispatcher is what makes the bare command real.The files are copied verbatim from the PoC branch on purpose. Rewriting them here to use absolute paths would fork the two copies and hide the dependency instead of stating it; the correct fix is to merge this after the release, not to edit around it.
Validated
claude plugin validate .(CLI 2.1.259) — passes; the single warning (marketplace has nodescription) is pre-existing onmainand unrelated.claude plugin validate ./commandsand./skills, both plain and--strict— pass. Worth noting:--strictfails on unrecognized frontmatter fields, and it acceptsargument-hintandallowed-tools, which the public docs page does not currently list.claude plugin validate .claude-plugin/plugin.json— passes.yaml.safe_load; keys aredescription/argument-hint/allowed-toolsandname/description/allowed-toolsrespectively.hooks/hooks.jsonparses as JSON with all three events present in the right case (SessionStart,UserPromptSubmit,Stop).scripts/opik-cipx-hook-launcher stoprun with nothing reachable on PATH: prints its install hint and exits 0, confirming the extra event argument is harmless underset -u.diff -q).skills/opik-cipx/SKILL.md,scripts/, andplugins/are untouched.🤖 Generated with Claude Code
Update 2026-09-03 — naming
The skill ships as
cost-intelligence-policyand the MCP command as/cost-intelligence-mcp, matching the PoC branch;/cost-intelligenceis unchanged. A skill namedcost-intelligencewould have collided with the command in Claude Code's shared command/skill namespace. Files remain byte-identical to the PoC's.