Skip to content

feat(hooks): warn when the installed plugin cache is stale — plugin-channel installs never auto-update #784

Closed

Description

@admarble

Problem

Claude Code pins plugin installs to a commit SHA at install time and never auto-updates them. For sequant's plugin channel (/plugin install sequant@sequant-io/sequant, README line ~67) that means every user runs the skills/hooks from whatever version they installed, forever, unless they manually run claude plugin update sequant@sequant — and nothing anywhere tells them to.

Incident (2026-07-18): an installed plugin cache sat at 1.20.3 (installed 2026-03-27, gitCommitSha 173095d) through ~4 months of active use and ~15 releases, while npm and the marketplace were at 2.8.0. In a consumer repo set up with installedVia: "plugin" (which has no local .claude/skills/ fallback — bare and qualified skill names both resolve to the stale cache), /assess produced pre-2.x output: box-drawn command blocks, hardcoded npx sequant run, no CMD_PREFIX resolution (#740), none of the Chain:/Flags:/ACs-column format, pre-#533 spec-skip logic.

Notably, the marketplace clone at ~/.claude/plugins/marketplaces/sequant was current (tracking main, .claude-plugin/marketplace.json said 2.8.0). Only the installed cache under ~/.claude/plugins/cache/sequant/sequant/<version>/ was stale. The drift is therefore detectable locally with zero network.

Why this is worse than a cosmetic format skew

Non-options

Proposed fix

Client-side, warn-only drift detection in the plugin's own hooks (they run from the cache on every session, so they are guaranteed present on exactly the affected installs):

On pre-tool (rate-limited), compare the running plugin's version (${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json or package.json) against the local marketplace clone's ~/.claude/plugins/marketplaces/sequant/.claude-plugin/marketplace.json. On mismatch, print one line:

sequant plugin v1.20.3 is stale (marketplace has v2.8.0) — run: claude plugin update sequant@sequant, then restart Claude Code

This check would have caught the incident above with no network access.

Acceptance Criteria

  • Pre-tool hook compares the running plugin version against the local marketplace clone's marketplace.json version; zero network calls; pure shell (grep/sed — no jq dependency), consistent with hook portability constraints.
  • Warn-only: a single stderr line including the exact remedy (claude plugin update sequant@sequant + restart note); the tool call is never blocked and the hook exit code is unchanged.
  • Rate-limited via a stamp file (at most once per day per install) so the warning does not repeat on every tool call.
  • Graceful no-op when: the marketplace clone is missing/unparsable, versions are equal, or the hook is not running from a plugin cache path (repo-local dev copies must not warn).
  • README plugin-install section documents that Claude Code does not auto-update plugins and shows the update command.
  • /release skill post-release checklist notes that installed plugins update only via claude plugin update (distinguishing it from the existing /plugin marketplace update listing refresh).

References

Activity

  1. added
    enhancement
    on Jul 18, 2026
  2. admarble commented on Jul 18, 2026

    @admarble
    ContributorAuthor

    → PROCEED — Well-specced warn-only hook; the manifest-version-floor non-option was already ruled out during #763.

    Workflow: spec → exec → qa

    Run: sequant run 784 -Q

    Notes:

    • Hook change must sync across all three hook dirs (.claude/hooks, templates/hooks, plugin hooks).
    • Repo-local dev copies must not warn (covered by the graceful no-op AC).
    • Scope spans three surfaces (hook + README + /release skill) — wider than a typical hook fix, hence -Q.
  3. admarble commented on Jul 18, 2026

    @admarble
    ContributorAuthor

    Plan (via /spec)

    Complexity: Standard (6 ACs, 3 directories) · Scope: ⚠️ SCOPE_WARNING (6 ACs, 3-dir spread) → quality loop enabled

    AC Checklist

    • AC-1: Pre-tool hook compares running plugin version vs local marketplace clone's marketplace.json; zero network; pure grep/sed — Integration Test
    • AC-2: Warn-only single stderr line with exact remedy (claude plugin update sequant@sequant + restart note); exit code unchanged, never blocks — Integration Test
    • AC-3: Stamp-file rate limit — warning at most once per day per install — Integration Test
    • AC-4: Graceful no-op when marketplace clone missing/unparsable, versions equal, or hook not running from a plugin cache path (repo-local dev copies never warn) — Integration Test
    • AC-5: README plugin-install section documents no-auto-update + update command — Manual (QA content check)
    • AC-6: /release post-release checklist distinguishes claude plugin update (installed plugin) from /plugin marketplace update (listing only) — Manual (QA content check)

    Implementation Plan

    Phase A — hook check (AC-1..4) in pre-tool.sh, mirrored identically across hooks/, templates/hooks/, .claude/hooks/:

    1. Resolve own path via BASH_SOURCE[0]; gate on */plugins/cache/* (repo-local copies no-op).
    2. Derive plugins root from the script's own path (${SCRIPT_DIR%%/plugins/cache/*}/plugins) — works under CLAUDE_CONFIG_DIR relocation, no hardcoded ~/.claude.
    3. Stamp file in existing _LOG_DIR holding today's date; stamp from today → skip; stamp written only when a warning is emitted.
    4. Extract "version" with sed from the running cache's .claude-plugin/plugin.json and <plugins-root>/marketplaces/sequant/.claude-plugin/marketplace.json; empty/missing → no-op.
    5. On mismatch: one stderr line, exact remedy, exit code untouched.

    Phase B — tests: __tests__/plugin-staleness-warning.integration.test.ts, parametrized over all three hook copies (existing pattern), staging each into a tmp plugins/cache/sequant/sequant/<v>/hooks/ tree: warn-once matrix + all four no-op scenarios.

    Phase C — docs (AC-5/AC-6): README install-section note; /release SKILL.md checklist note (3 skill mirrors); sibling fix to docs/internal/plugin-updates.md (its update recipe omits claude plugin update and overstates update notifications — contradicted by the motivating incident).

    Key Decisions

    • Inequality, not semver ordering — per issue text; a dev cache newer than the marketplace still warns (wording slightly off, impact negligible).
    • No jq — grep/sed only, consistent with hook portability constraints.
    • Check placement: after the timing/rotation section, before catastrophic blocks; runs for all tool names, cost gated by the stamp check.

    Open Questions

    1. Stderr visibility on exit 0 may be transcript-only in some Claude Code versions — AC prescribes stderr + unchanged exit code, implementing as written.

    Workflow: spec → exec → qa (quality loop on; no browser test — hooks/docs only)

  4. added
    planned
    on Jul 18, 2026
  5. admarble commented on Jul 18, 2026

    @admarble
    ContributorAuthor

    Exec Complete

    Commit: 377462d on feature/784-feat-hooks-warn-when-the-installed-plugin-cache-is

    • Staleness check added to pre-tool.sh (all three mirrors, byte-identical): path-gated to */plugins/cache/*, stamp-file rate limit (1/day), grep/sed only, warn-only stderr line with exact remedy, exit code untouched.
    • Tests: __tests__/plugin-staleness-warning.integration.test.ts — 21 passed (7 scenarios × 3 hook copies); existing hook suite 183 passed; build ✅ lint ✅ lint:skill-calls ✅.
    • Docs: README install note (AC-5), /release checklist distinction (AC-6, 3 skill mirrors), docs/internal/plugin-updates.md recipe corrections, CHANGELOG entry.

    Proceeding to QA.

  6. admarble commented on Jul 18, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #784

    AC Coverage

    AC Description Status Notes
    AC-1 Hook compares running vs marketplace-clone version; zero network; grep/sed only MET sed -n extraction from both manifests; no jq, no network calls; verified by 21 integration tests parametrized over all three hook mirrors
    AC-2 Warn-only single stderr line with exact remedy; never blocks; exit code unchanged MET Warning line matches the issue's verbatim fixture byte-for-byte; exit 0 on safe commands; a force-push still blocks (exit 2) with the warning riding along
    AC-3 Stamp-file rate limit, ≤1/day per install MET Stamp in $CLAUDE_PLUGIN_DATA/logs (falls back to ~/.sequant/logs); second same-day run emits nothing (tested)
    AC-4 Graceful no-op: clone missing/unparsable, versions equal, non-cache path MET All four scenarios tested; repo-local copies gated out by */plugins/cache/* path check on BASH_SOURCE
    AC-5 README documents no-auto-update + update command MET README.md:71; gap found & fixed: the generated marketplace README (prepare-marketplace.ts template) also has a plugin-install section — note added there too (52a6e14)
    AC-6 /release checklist distinguishes claude plugin update from marketplace-listing refresh MET All three release SKILL.md mirrors updated (Install block + Next-steps note); claude plugin update --help verified the command exists and confirms "restart required to apply"

    Coverage: 6/6 MET

    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 11 OK
    Lines +416 / −20 OK
    Hook mirrors 3/3 byte-identical (md5) OK
    bash -n pass OK

    Execution Evidence

    Test Result
    Dogfood: stale cache (1.20.3 vs 2.8.0) ✅ exact fixture line, exit 0
    Dogfood: same-day repeat ✅ silent
    Dogfood: repo-local copy w/ stale marketplace present ✅ silent
    Dogfood: equal versions / missing / unparsable clone ✅ silent
    Dogfood: blocked command + warning ✅ exit 2 preserved
    vitest staleness suite 21/21 (3 mirrors × 7 scenarios)
    Existing pre-tool suite 183/183
    sync/update suites 31/31
    build / lint / lint:skill-calls ✅ / ✅ / ✅
    npm run prepare:marketplace ✅ regenerated artifact carries the note

    Skill Command Verification

    Release SKILL.md added lines contain claude plugin update sequant@sequant — verified against claude plugin update --help (command exists; help text confirms restart requirement). No gh/npm/git commands added. Passed.

    Risk Assessment

    • Likely failure mode: Claude Code changes its plugin cache/marketplace directory layout — the check then finds no manifests and silently no-ops (fail-safe, never false-positive). Stderr on exit-0 hooks may be transcript-only in some clients; the AC prescribes this design and it was flagged in the spec's open questions.
    • Not tested: prepare-marketplace.ts has no direct unit tests (template-only change; verified by regenerating the artifact). Zero-network property is by construction (pure file reads), not asserted by a test.
    • Sibling sites considered: post-tool.sh also runs from the cache but the AC scopes the check to pre-tool; adding it there would double the daily warning. No other cross-file siblings.
    • Sibling-line audit: single insertion point after log rotation; no adjacent call sites share the root cause.

    Adversarial Re-Read

    Findings: Ran the implementation against the issue's verbatim fixture (precheck .checks.fixtures — byte-identical output). Audited evidence claims: all dogfood runs are post-fix validations, not bug repros. Surfaced one real gap — the generated marketplace README's install section lacked the note (feedback_docs_ac_all_locations class) — fixed in 52a6e14 and re-verified via regeneration. Non-Goals ("Non-options" in issue): no manifest version floor attempted, no server-side push — scope held. Status: Clean (after in-PR fix).

    CHANGELOG

    ✅ [Unreleased] → Added entry with (#784).

    Verdict: READY_FOR_MERGE

    All ACs met literally with runtime evidence; the one gap surfaced in review was fixed and re-verified within the PR.

  7. admarble commented on Jul 18, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #784
    Status: READY_FOR_MERGE

    Summary

    • AC: 6/6 MET (literal verification with runtime evidence)
    • Tests: 21 new integration tests (3 hook mirrors × 7 scenarios); 183 existing hook tests green; build/lint clean
    • QA: one gap surfaced by adversarial re-read (generated marketplace README missing the note) — fixed in-PR (52a6e14)

    Iterations

    • Exec loop: 1
    • QA loop: 1 (no /loop needed)

    PR: #787 — 8 CI checks dispatched, MERGEABLE


    Ready for human review and merge.

  8. added 2 commits that reference this issue on Jul 19, 2026
  9. added 2 commits that reference this issue on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions