basic-memory icon indicating copy to clipboard operation
basic-memory copied to clipboard

[BUG] Stop hook with "type": "prompt" causes JSON validation error (regression from #531)

Open ryanstraight opened this issue 9 months ago • 3 comments

The Stop hook in basic-memory-plugins v0.2.1 still causes a JSON validation error on every session stop in Claude Code. Issue #531 fixed the unsupported "matcher": "*" field, but the underlying problem persists: "type": "prompt" hooks on the Stop event fail validation.

Current hooks.json (v0.2.1)

"Stop": [
  {
    "hooks": [
      {
        "type": "prompt",
        "prompt": "If this conversation contained valuable insights..."
      }
    ]
  }
]

Error

● Ran 1 stop hook
  ⎿  Stop hook error: JSON validation failed

This fires on every /exit or session end.

Workaround

Removing the entire Stop section from hooks/hooks.json eliminates the error. The /remember prompt behavior is still available via CLAUDE.md instructions.

Environment

  • Claude Code (latest, Feb 2026)
  • basic-memory 0.18.4
  • basic-memory-plugins v0.2.1
  • Windows 11

Notes

  • The plugins repo (basicmachines-co/basic-memory-plugins) was archived on Feb 15, 2026, so filing here instead.
  • "type": "prompt" works fine on PreToolUse hooks (e.g., the mcp__basic-memory__write_note validation prompt). The issue appears specific to the Stop event.

ryanstraight avatar Feb 19 '26 17:02 ryanstraight

Hey Ryan — thanks for the detailed report. You're right that the plugins repo was archived; we've moved the memory skills into the openclaw-basic-memory plugin now (bundled as memory-reflect, memory-defrag, memory-tasks).

The Stop hook type: prompt validation failure looks like a Claude Code change in how they validate hook schemas — prompt type works on PreToolUse but not on Stop. We'll investigate whether this is a Claude Code regression or a schema constraint we need to work around.

For now your workaround (removing the Stop section) is the right call. The /remember behavior via CLAUDE.md instructions is actually more reliable anyway since it doesn't depend on hook validation.

bm-clawd avatar Feb 22 '26 14:02 bm-clawd

"Can you check the type value of the prompt hook and ensure it's set to "text" instead of "prompt", as the latter is causing the JSON validation error?"

clawdney avatar Mar 07 '26 20:03 clawdney

Thanks for filing this here after the plugins repo was archived. Confirmed: there's no Stop hook handling, hooks.json schema, or related code in basic-memory itself. The hooks.json you referenced lives in basicmachines-co/basic-memory-plugins which was archived in Feb 2026, so a fix there isn't possible without un-archiving the repo.

Verified by searching this repo for any Stop-event hook code:

grep -rn "Stop hook\|hooks.json\|type.*prompt" src/

The only match is unrelated (type: "prompt_template" in a Claude conversation importer).

Three paths forward, none of which can land in this PR/repo:

  1. Un-archive basic-memory-plugins so a fix to hooks/hooks.json can be PR'd against the source. This is the cleanest fix — the offending "type": "prompt" on the Stop event needs to either change to a supported hook type or move to a different event (your PreToolUse example works because Claude Code accepts prompt there).

  2. Migrate hook config into basic-memory proper as part of installer output / docs, so the project owns its own hook recipe going forward. Larger scope.

  3. Close as won't-fix if the user-facing workaround (removing the entire Stop section from hooks/hooks.json) is acceptable and the plugin is effectively deprecated.

Closing here as out-of-scope for this repo. Happy to reopen and help if (1) becomes the chosen path — please tag me on the un-archived plugins repo.

phernandez avatar Apr 29 '26 02:04 phernandez