Sign in
Explore
Add-ons · HookEveryday codingReviewed

question-log-hook.ts

PostToolUse hook that logs each AskUserQuestion question and the user's choice, so question prompts can be tuned.

Kind
Hook
Works with
Claude Code
Languages
TypeScript / JavaScript
Source
garrytan/gstack @ 01593aa67c94
Path
hosts/claude/hooks/question-log-hook.ts
Jobs
Automation

Credit

Made by
garrytan
Original
github.com/garrytan/gstack/blob/01593aa67c94780528e8f5121e473…
License
MIT

Listed by Skill Manifest; not made by us.

InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
Adds
  • Entries under `hooks` in .claude/settings.json
Runs scripts
Yes
  • question-log-hook.ts
  • command line in the text
  • the component is a script
Uses the network
None found
Needs secrets
None found
Reads environment variables
  • JSON
  • GSTACK_STATE_ROOT
  • GSTACK_HOME
Reads outside the project
  • /usr/bin/env (question-log-hook.ts)
  • ~/.claude/settings.json (question-log-hook.ts)
  • ~/.gstack/hook-errors.log (question-log-hook.ts)
Source revision
01593aa67c94
Licence
MIT
Last activity
27 Nov 2026
Source changed after the scan
Yes
  • Last push 27 Nov 2026, scanned 3 Nov 2026; read it again before you rely on this scan
Review
Reviewed

Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.

#!/usr/bin/env bun
/**
 * PostToolUse hook for AskUserQuestion (Claude Code, plan-tune cathedral T5).
 *
 * Reads hook stdin JSON, extracts every AUQ question + user choice from the
 * tool_input/tool_response, and writes them via gstack-question-log so the
 * substrate captures fires deterministically — no agent compliance required.
 *
 * Triggered by ~/.claude/settings.json:
 *   {
 *     "hooks": {
 *       "PostToolUse": [
 *         {
 *           "matcher": "(AskUserQuestion|mcp__.*__AskUserQuestion)",
 *           "hooks": [
 *             { "type": "command",
 *               "command": "$CLAUDE_PROJECT_DIR/.claude/skills/gstack/hosts/claude/hooks/question-log-hook",
 *               "timeout": 5 }
 *           ]
 *         }
 *       ]
 *     }
 *   }
 *
 * Invariants:
 *   - Always exits 0. A failing hook MUST NOT block the user's session.
 *     Errors land in ~/.gstack/hook-errors.log for postmortem.
 *   - Spawns gstack-question-log as a subprocess; that bin handles
 *     validation, dedup (source+tool_use_id), async derive.
 *   - Marker-first question_id (`<gstack-qid:foo-bar>`), hash fallback
 *     (D18 progressive markers).
 *
…