Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b86yyhhudsSLnwNUFY
33 lines
1.5 KiB
Plaintext
33 lines
1.5 KiB
Plaintext
# protect-files.sh: PreToolUse on Edit|Write|MultiEdit
|
|
|
|
## Edit an ordinary Java file
|
|
input : {"hook_event_name":"PreToolUse","tool_name":"Edit","tool_input":{"file_path":"<project>/src/main/java/com/ankurm/claudecode/orders/OrderService.java"}}
|
|
stdout: (empty)
|
|
stderr: (empty)
|
|
exit : 0
|
|
|
|
## Edit production config
|
|
input : {"hook_event_name":"PreToolUse","tool_name":"Edit","tool_input":{"file_path":"<project>/src/main/resources/application-prod.properties"}}
|
|
stdout: (empty)
|
|
stderr: Blocked: <project>/src/main/resources/application-prod.properties is production configuration. Ask the user to change it.
|
|
exit : 2
|
|
|
|
## Edit an existing migration
|
|
input : {"hook_event_name":"PreToolUse","tool_name":"Edit","tool_input":{"file_path":"<project>/src/main/resources/db/migration/V1__create_orders.sql"}}
|
|
stdout: (empty)
|
|
stderr: Blocked: <project>/src/main/resources/db/migration/V1__create_orders.sql is an existing Flyway migration. Add a new V<next>__*.sql file instead.
|
|
exit : 2
|
|
|
|
## Write over an existing migration
|
|
input : {"hook_event_name":"PreToolUse","tool_name":"Write","tool_input":{"file_path":"<project>/src/main/resources/db/migration/V1__create_orders.sql"}}
|
|
stdout: (empty)
|
|
stderr: Blocked: <project>/src/main/resources/db/migration/V1__create_orders.sql is an existing Flyway migration. Add a new V<next>__*.sql file instead.
|
|
exit : 2
|
|
|
|
## Write a new migration
|
|
input : {"hook_event_name":"PreToolUse","tool_name":"Write","tool_input":{"file_path":"<project>/src/main/resources/db/migration/V2__add_status.sql"}}
|
|
stdout: (empty)
|
|
stderr: (empty)
|
|
exit : 0
|
|
|