Plugin errors
Common error signatures
Failures in the plugin's hooks fall into three categories:
- State discovery failures —
discover_specs()raises when it cannot walk aspecs/directory under a workspace root (for example, aPermissionErroror a root that no longer exists).workspace_roots()returning an empty list silently produces an empty spec scan, which causesformat_orientation()inhooks.spec_orientto render nothing. - Git state failures —
git_state()raises whencwdis not inside a git repository or thegitbinary is not onPATH. The resultingGitStatefields (branch,last_sha,last_subject,uncommitted) are never populated, so any downstream call tobuild_resume_prompt()that depends on them will receive incomplete data. - Security guard rejections —
validate_bash_command()andvalidate_file_path()inhooks.security_guardreturn(False, <reason>)when a command matches a blocked prefix or a path falls under aSYSTEM_DIRECTORIESentry such as/etc,/sys, or/proc. These are not exceptions — they are structured rejections thatmain()inhooks.security_guardconverts into a blocked response. - Utilization estimation failures —
estimate_utilization()inhooks._transcript_sizeraises when the transcript path does not exist or is unreadable. When this happens,format_warning()inhooks.compact_warningnever receives a validutilfloat, so no compact warning is emitted. - Sentinel path errors —
session_sentinel_path()raises if the session ID resolves to an unwritable location.prune_stale_sentinels()silently returns0if no sentinels are found, which is expected, but anOSErrorhere indicates a filesystem permission problem.
Where errors originate
| Function | Module | What goes wrong |
|---|---|---|
main() |
hooks._handoff_cli |
Entry point for /handoff; any unhandled exception from the call chain surfaces here as a non-zero exit |
build_resume_prompt() |
hooks._resume_prompt |
Receives None for spec_info when discovery found nothing; downstream templates render without spec context |
discover_specs() |
hooks._state |
Raises on unreadable specs/ directories; returns an empty list when roots are empty |
git_state() |
hooks._state |
Raises when cwd is not a git repo or git is unavailable |
session_sentinel_path() |
hooks._state |
Raises when the resolved path is unwritable |
estimate_utilization() |
hooks._transcript_size |
Raises on a missing or unreadable transcript file |
validate_bash_command() / validate_file_path() |
hooks.security_guard |
Returns (False, reason) — not an exception, but the main() caller must check the boolean |
How to diagnose
-
Identify the hook entry point that failed. Each hook module exposes a
main()function. The hook name in the error output (handoff,compact_warning,spec_orient,security_guard, and so on) tells you whichmain()was active when the failure occurred. -
Check whether
discover_specs()returned an empty list. Ifworkspace_roots()found no roots,discover_specs()receives an emptyrootslist and returns[]. This produces no exception — the symptom is a silent no-op informat_orientation()or abuild_resume_prompt()call wherespec_infoisNone. -
Verify git availability for
git_state()failures. Rungit rev-parse --show-toplevelin the working directory. If that fails,git_state()will fail for the same reason, andGitState.branch,GitState.last_sha, andGitState.last_subjectwill be unpopulated. -
For security guard rejections, check the return value, not the exception.
validate_bash_command()andvalidate_file_path()signal rejection via(False, reason_string)— they do not raise. If a command or path is being silently blocked, print the second element of the return tuple to read the rejection reason. Blocked path prefixes include everything underSYSTEM_DIRECTORIES:/etc,/sys,/proc,/dev,/boot,/sbin,/usr/sbin,/private/etc, and/private/var. -
For utilization warnings that never appear, confirm that the transcript file passed to
estimate_utilization()exists and is readable. A missing transcript causes an exception that preventsformat_warning()from composing the warning and resume prompt.
Source files
hooks._handoff_clihooks._resume_prompthooks._statehooks._transcript_sizehooks.compact_warninghooks.format_on_savehooks.help_freshness_checkhooks.help_on_errorhooks.help_post_commithooks.security_guardhooks.spec_orienthooks.welcome
Tags: plugin, claude-code