/plugin marketplace add bastos/rails-plugin/plugin install bastos-ruby-on-rails@bastos/rails-pluginDefined in hooks/hooks.json
{
"PreToolUse": [
{
"hooks": [
{
"type": "prompt",
"prompt": "Check if this is a Rails project and if there are any Rails-specific issues to warn about:\n\n1. Check for pending migrations: If running any Rails command, first check if `rails db:migrate:status` shows any 'down' migrations. If so, add a warning.\n\n2. Check for missing indexes on foreign keys: If the command involves migrations or schema, check schema.rb for `t.references` or `_id` columns that may lack indexes.\n\n3. Basic security check: If editing controller files, verify strong parameters are being used.\n\nReturn JSON with the hooks schema. If there are warnings, include them in `systemMessage`.\n\nIf no issues found, return:\n{\n \"decision\": \"approve\",\n \"reason\": \"Rails checks passed\"\n}\n\nHook input:\n$ARGUMENTS",
"timeout": 30
}
],
"matcher": "Bash"
}
],
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path // empty' | ${CLAUDE_PLUGIN_ROOT}/scripts/format_ruby.sh",
"timeout": 60
},
{
"type": "command",
"command": "jq -r '.tool_input.file_path // empty' | { read -r file_path; if echo \"$file_path\" | grep -Eq '/(spec/.*_spec\\.rb|test/.*_test\\.rb)$'; then ${CLAUDE_PLUGIN_ROOT}/scripts/run_tests_for_file.sh \"$file_path\"; fi; }",
"timeout": 300
}
],
"matcher": "Edit|Write"
}
]
}{
"riskFlags": {
"touchesBash": true,
"matchAllTools": false,
"touchesFileWrites": true
},
"typeStats": {
"prompt": 1,
"command": 2
},
"eventStats": {
"PreToolUse": 1,
"PostToolUse": 2
},
"originCounts": {
"absolutePaths": 0,
"pluginScripts": 2,
"projectScripts": 0
},
"timeoutStats": {
"commandsWithoutTimeout": 0
}
}