Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rothanachoun/4b5426e2b9be32c180ddca2f74152790 to your computer and use it in GitHub Desktop.

Select an option

Save rothanachoun/4b5426e2b9be32c180ddca2f74152790 to your computer and use it in GitHub Desktop.
Using Claude Code Hooks to automatically run rubocop --auto-correct on Ruby files
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "FILE_PATH=$(jq -r '.tool_input.file_path // empty'); if [[ \"$FILE_PATH\" =~ \\.(rb|rake)$|Rakefile$|Gemfile$ ]]; then echo \"Running RuboCop on $FILE_PATH\"; bundle exec rubocop --autocorrect \"$FILE_PATH\"; fi"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment