The command-safety hook only checked the first word of each segment, so destructive commands inside if/for/while blocks, subshells, braces, PowerShell script blocks, or behind wrapper options (xargs -0, sudo -E, timeout 30) ran unchecked. A comment with an apostrophe, an escaped quote, or a line continuation also hid the following command. Skip shell keywords, split on braces, drop comments, honor backslash escapes, join continued lines, and check every suffix after a wrapper. CLI mode also strips the byte order mark that Windows PowerShell 5.1 adds to piped stdin, which let every command pass there. with-credential.ps1 returned the child's exit code from a function, so the child's stdout was captured and the exit code became 0. Run the child as a statement and exit with its code. add-credentials now refreshes the installed helper on every run so fixes reach existing machines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hooks
This directory contains registered hooks and optional utilities. They do not bypass client permission prompts or grant access.
When Flashbang is enabled, both clients register Stop (flashbang) for finish notifications. Claude also registers PreCompact (Record-Compact/record-compact.sh) and SessionStart (Show-SessionStatePointer/show-session-state-pointer.sh). PreCompact records its timestamp under the installed configuration root. Both session hooks point to an existing workspace .ai-session/state.json, using event cwd or the process working directory. The main agent owns that state; hooks never write it or print its contents. Missing state is a successful no-op.
Both clients register PreToolUse (Validate-CommandSafety/validate-command-safety.sh), which blocks clearly destructive shell commands by exiting 2; it parses command text, so it is a guard rail rather than a security boundary, and it fails open. Both clients also register Stop (Check-CompletionEvidence/check-completion-evidence.sh) and UserPromptSubmit (Show-CorrectionPrompt/show-correction-prompt.sh). Both call agent-guards.py, store nothing, and fail open. The first pushes back once on a completion claim without a named check while non-prose changes exist; the second asks the agent to propose a durable rule after a likely correction. A second PreToolUse hook (Show-SearchReminder/show-search-reminder.sh, also through agent-guards.py) reminds the agent to run semantic-search before the first open search and again after every 10 open searches without qmd-search.mjs, which also covers context lost to compaction; it never blocks, stays silent while the session keeps using qmd-search.mjs, does nothing unless QMD is installed, and keeps only hashed per-session markers under ~/.my-ai-configuration/state/search-reminder/.
Invoke-PostChangeVerification/invoke-post-change-verification.sh is not registered or invoked automatically; it runs the repository build only when explicitly invoked. Python-based hooks resolve their interpreter through Resolve-Python.ps1/resolve-python.sh and are silently skipped without Python 3.11+. Test-SessionConfig/test-session-config.sh checks repository inputs during a build.
When local QMD search is enabled, both clients also register a SessionStart warm-up hook (Start-QmdWarm.ps1/start-qmd-warm.sh). It starts the installed Node wrapper in the background from the process working directory, only inside a Git repository. Warm-up errors are recorded in ~/.my-ai-configuration/qmd/warm.log; they do not fail the session. Disabling local search removes the hook registration.
Codex also registers PostToolUse (matcher Edit|Write|apply_patch) and Stop hooks for Impeccable's design detector (Invoke-ImpeccableHook.ps1/invoke-impeccable-hook.sh). The wrapper runs the installed Impeccable Codex skill's impeccable hook and is a no-op when that skill is missing. Claude receives the same hooks from the Impeccable plugin. The detector is on by default in every project; a project opts out with impeccable hooks off.