* fix(shellcheck): declare and assign separately in router.sh (SC2155) * feat(plugin): enhance context management and skill invocation - Update .context-manifest.json to include profile and detailed source information. - Revise context-scout.md to clarify context root discovery and navigation. - Modify commands to replace deprecated skills with updated ones (brainstorming → approach, systematic-debugging → debugger). - Streamline install-context.md for clarity and remove interactive profile selection. - Improve oac-status.md to provide a more comprehensive status report. - Add OAC system paths to session-start.sh for better context management. - Remove obsolete skills and improve documentation for existing commands.
1.2 KiB
1.2 KiB
Code Formatting Hook
Purpose: Auto-format files after Claude edits them
TypeScript/Prettier Hook
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{
"type": "command",
"command": "jq -r '.tool_input.file_path' | { read file_path; if echo \"$file_path\" | grep -q '\\.ts$'; then npx prettier --write \"$file_path\"; fi; }"
}]
}]
}
}
How It Works
- Triggers after Edit or Write tool completes
- Extracts file path from JSON input via jq
- Checks if file is
.tsextension - Runs prettier on matching files
Variations
Go files:
if echo "$file_path" | grep -q '\\.go$'; then gofmt -w "$file_path"; fi
Python files:
if echo "$file_path" | grep -q '\\.py$'; then black "$file_path"; fi
Multiple extensions:
if echo "$file_path" | grep -qE '\\.(ts|tsx|js|jsx)$'; then npx prettier --write "$file_path"; fi
Related
../../lookup/hook-events.md- Hook events reference./protection-hook.md- File protection example
Reference: https://docs.anthropic.com/en/docs/claude-code/hooks