Skip to content

PreToolUse hook outputs plain text instead of additionalContext JSON #83

Description

@lucasyhzhu-debug

Problem

The graphify PreToolUse hook installed in .claude/settings.json outputs a plain text string:

[ -f graphify-out/graph.json ] && echo 'graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files.' || true

Plain echo output goes to stdout/transcript but is not injected into the model's context. Claude Code requires hooks to return structured JSON with hookSpecificOutput.additionalContext for the message to appear as a <system-reminder> that the model actually sees.

Expected behavior

The hook should output JSON so Claude receives the graphify reminder before every Glob/Grep call:

[ -f graphify-out/graph.json ] && echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files."}}' || true

Impact

Without the JSON wrapper, the hook fires silently — Claude never sees the reminder and searches raw files instead of consulting the knowledge graph first. The feature described in the README/docs doesn't actually work as intended.

Environment

  • Claude Code on Windows 11
  • graphify knowledge graph present (graphify-out/graph.json exists)
  • Hook matcher: Glob|Grep

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions