-
Notifications
You must be signed in to change notification settings - Fork 26
Hooks Troubleshooting
Symptoms:
- Hook fails with "python: command not found"
- VS Code shows hook error in console
- Claude Code logs show exec failure
Cause: Python not installed or not in PATH
Solution (macOS / Linux):
# Check if Python is installed
which python3
# If not found, install Python 3.8+
# macOS (Homebrew)
brew install python@3.11
# Ubuntu/Debian
sudo apt install python3
# Update hook command to use python3
sed -i 's/python /python3 /g' .github/hooks/hooks-consolidated.jsonSolution (Windows PowerShell):
# Check if Python is installed
Get-Command python
# If not found, install from python.org or Microsoft Store
winget install Python.Python.3.11
# Update hook command if needed
(Get-Content .github\hooks\hooks-consolidated.json) -replace 'python ', 'py ' | Set-Content .github\hooks\hooks-consolidated.jsonSymptoms:
- macOS/Linux: "Permission denied: '.github/hooks/scripts/session-start.py'"
- Hook fails to execute
Cause: Hook scripts not marked as executable
Solution (macOS / Linux):
chmod +x .github/hooks/scripts/*.pyNote: Windows does not require execute permissions for Python scripts.
Symptoms:
- Expected hook output not appearing
- Edit gate not blocking UI files
- Session start context not injected
Debugging Steps:
Step 1: Verify Hook Configuration Exists
# VS Code
cat .github/hooks/hooks-consolidated.json
# Claude Code
cat .claude/hooks/hooks-consolidated.jsonStep 2: Check Platform Support
- VS Code: Hooks require VS Code 1.110+ (February 2026 or later)
- Claude Code: Hooks supported in all recent versions
- Gemini CLI: Hook support TBD
Step 3: Enable Hook Debugging
VS Code (settings.json):
{
"copilot.hooks.debug": true
}Claude Code (~/.claude/settings.json):
{
"debugHooks": true
}Step 4: Test Hook Script Manually
# SessionStart
echo '{"hookEventName": "SessionStart"}' | python .github/hooks/scripts/session-start.py
# PreToolUse (edit gate)
echo '{"hookEventName": "PreToolUse", "tool_name": "replace_string_in_file", "tool_input": {"filePath": "src/App.jsx"}}' | python .github/hooks/scripts/enforce-edit-gate.pyExpected output: Valid JSON with hookSpecificOutput key
Symptoms:
-
.github/.a11y-reviewedpersists across sessions - Edit gate never re-engages after first review
Cause: Session end hook not firing or failing
Solution:
Step 1: Manually Remove Marker
rm .github/.a11y-reviewedStep 2: Verify Session End Hook
# Test Stop event (VS Code)
echo '{"hookEventName": "Stop"}' | python .github/hooks/scripts/session-end.py
# Test SessionEnd event (Claude Code)
echo '{"hookEventName": "SessionEnd"}' | python .github/hooks/scripts/session-end.pyStep 3: Check .gitignore Ensure marker is not committed:
# Add to .gitignore if missing
echo ".github/.a11y-reviewed" >> .gitignoreSymptoms:
- Windows: Hook fails with "No such file or directory"
- macOS/Linux: Hook can't find scripts
Cause: Forward slash vs backslash path separators
Solution:
Python scripts use pathlib.Path() which handles cross-platform paths automatically. Verify hook configuration uses forward slashes only:
{
"command": "python .github/hooks/scripts/session-start.py"
}Not:
{
"command": "python .github\\hooks\\scripts\\session-start.py"
}Symptoms:
- Hook aborted after 5-10 seconds
- "Hook execution timeout" in logs
Cause: Hook script taking too long (network calls, heavy computation)
Solution:
Increase timeout in hook configuration:
{
"type": "command",
"command": "python .github/hooks/scripts/session-start.py",
"timeout": 20
}Optimize hook script:
- Remove network calls
- Cache expensive operations
- Use set() for O(1) lookups instead of list iteration
Symptoms:
- "Invalid JSON input" in stderr
- Hook fails immediately
Cause: Hook script receiving malformed JSON or no input
Debugging:
# Test hook with valid input
echo '{"hookEventName": "SessionStart"}' | python .github/hooks/scripts/session-start.py
# If this works, issue is with platform passing invalid input
# Check platform logs for what JSON was sentSymptoms:
- Edit gate blocks Python, markdown, or non-UI files
- False positive matches
Cause: File extension check too broad or missing extension
Solution:
Edit .github/hooks/scripts/enforce-edit-gate.py to refine is_ui_file():
def is_ui_file(file_path):
"""Check if file is a UI file that requires accessibility review."""
ui_extensions = {
".jsx", ".tsx", ".vue", ".svelte", ".astro",
".html", ".htm", ".css", ".scss", ".sass", ".less",
".leaf", ".ejs", ".erb", ".hbs", ".mustache", ".pug"
}
# Exclude test files
if "test" in file_path.lower() or "spec" in file_path.lower():
return False
# Exclude node_modules, vendor folders
if "node_modules" in file_path or "vendor" in file_path:
return False
path = Path(file_path)
return path.suffix.lower() in ui_extensionsSymptoms:
- Set
SKIP_A11Y_HOOKS=1but hooks still run
Cause: Environment variable not read by platform
Current Status: Hook scripts don't check for SKIP_A11Y_HOOKS yet (feature planned for v3.1)
Workaround:
# Disable hooks by renaming configuration
mv .github/hooks/hooks-consolidated.json .github/hooks/hooks-consolidated.json.disabledRe-enable:
mv .github/hooks/hooks-consolidated.json.disabled .github/hooks/hooks-consolidated.jsonSymptoms:
- Hook fires on one platform but not the other
- "Stop" vs "SessionEnd" confusion
Cause: Platform-specific event names
Solution: Hooks configuration includes both Stop (VS Code) and SessionEnd (Claude Code):
{
"hooks": {
"Stop": [
{
"type": "command",
"command": "python .github/hooks/scripts/session-end.py",
"timeout": 5
}
],
"SessionEnd": [
{
"type": "command",
"command": "python .github/hooks/scripts/session-end.py",
"timeout": 5
}
]
}
}Both events call the same script. Platform ignores unknown events.
If these solutions don't resolve your issue:
-
Check Hook Logs:
- VS Code: View → Output → GitHub Copilot Chat
- Claude Code: ~/.claude/logs/hooks.log
-
Test Hook Scripts Manually:
echo '{"hookEventName": "PreToolUse", "tool_name": "replace_string_in_file", "tool_input": {"filePath": "src/App.jsx"}}' | python .github/hooks/scripts/enforce-edit-gate.py
-
Open GitHub Issue: https://github.com/Community-Access/accessibility-agents/issues/new?labels=hooks,bug
-
Discord Community: Join #accessibility-agents channel for real-time help
- hooks-guide.md - Full hooks documentation
- HOOKS-CROSS-PLATFORM-STRATEGY.md - Implementation strategy (56 pages)
- VS Code Hooks API
- Claude Code Hooks Reference
- Accessibility Lead
- Web Accessibility Wizard
- Document Accessibility Wizard
- Alt Text and Headings
- ARIA Specialist
- Contrast Master
- Forms Specialist
- Keyboard Navigator
- Link Checker
- Live Region Controller
- Modal Specialist
- Tables Data Specialist
- Word Accessibility
- Excel Accessibility
- PowerPoint Accessibility
- PDF Accessibility
- Office Scan Config
- PDF Scan Config
- Testing Coach
- WCAG Guide