question-preference-hook.ts
PreToolUse hook that enforces never-ask, always-ask and ask-only-for-one-way preferences for AskUserQuestion calls.
- Kind
- Hook
- Works with
- Claude Code
- Languages
- TypeScript / JavaScript
- Source
- garrytan/gstack @ 01593aa67c94
- Path
- hosts/claude/hooks/question-preference-hook.ts
- Jobs
- Guardrails
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-preference-hook.ts
- command line in the text
- the component is a script
- Uses the network
- None found
- Needs secrets
- None found
- Reads environment variables
- CONDUCTOR_SPAWNED_DENY_REASON
- GSTACK_STATE_ROOT
- GSTACK_HOME
- GSTACK_SESSION_KIND
- Reads outside the project
- /usr/bin/env (question-preference-hook.ts)
- ~/.gstack/hook-errors.log (question-preference-hook.ts)
- Calls other skills
- /plan-tune
- 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 /** * PreToolUse hook for AskUserQuestion (Claude Code, plan-tune cathedral T6). * * Enforces never-ask / always-ask / ask-only-for-one-way preferences * deterministically — no agent compliance required. * * Decision tree (per question in tool_input.questions): * 1. Extract question_id via marker (<gstack-qid:foo-bar>). If no marker, * enforcement is skipped for this question (D18 — hash IDs are * observed-only, never used as preference keys). * 2. Look up door_type from scripts/question-registry.ts (default two-way). * 3. Read preferences with precedence: project-local > global (D8). * 4. Apply: * never-ask + one-way → pass through (safety override; one-way always asks). * never-ask + two-way + marker → deny with auto-decided recommendation * in reason. Mark tool_use_id so PostToolUse logs as 'auto-decided'. * ask-only-for-one-way + two-way + marker → same as never-ask. * always-ask, or no preference → pass through. * * Pass-through = exit 0 with empty stdout (or additionalContext-only output * when memory nuggets exist) — NEVER permissionDecision:'defer', whose …