diff --git a/hooks/hooks.json b/hooks/hooks.json index 8fb52cb3..e54c6a4e 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -153,6 +153,26 @@ } ], "PostToolUse": [ + { + "matcher": "Bash", + "hooks": [ + { + "type": "command", + "command": "#!/bin/bash\nmkdir -p ~/.claude; INPUT=$(cat);\necho \"$INPUT\" | jq -r '\"[\" + (now | todate) + \"] \" + ((.tool_input.command // \"?\") | gsub(\"\n\"; \" \") | gsub(\"--token[= ][^ ]*\"; \"--token=\") | gsub(\"Authorization:[: ]*[^ ]*[: ]*[^ ]*\"; \"Authorization:\") | gsub(\"AKIA[A-Z0-9]{16}\"; \"\") | gsub(\"ASIA[A-Z0-9]{16}\"; \"\") | gsub(\"password[= ][^ ]*\"; \"password=\") | gsub(\"ghp_[A-Za-z0-9_]+\"; \"\") | gsub(\"gho_[A-Za-z0-9_]+\"; \"\") | gsub(\"ghs_[A-Za-z0-9_]+\"; \"\") | gsub(\"github_pat_[A-Za-z0-9_]+\"; \"\"))' >> ~/.claude/bash-commands.log 2>/dev/null || true;\nprintf '%s\n' \"$INPUT\"" + } + ], + "description": "Audit log all bash commands to ~/.claude/bash-commands.log" + }, + { + "matcher": "Bash", + "hooks": [ + { + "type": "command", + "command": "#!/bin/bash\nmkdir -p ~/.claude; INPUT=$(cat);\necho \"$INPUT\" | jq -r '\"[\" + (now | todate) + \"] tool=Bash command=\" + ((.tool_input.command // \"?\") | gsub(\"\n\"; \" \") | gsub(\"--token[= ][^ ]*\"; \"--token=\") | gsub(\"Authorization:[: ]*[^ ]*[: ]*[^ ]*\"; \"Authorization:\") | gsub(\"AKIA[A-Z0-9]{16}\"; \"\") | gsub(\"ASIA[A-Z0-9]{16}\"; \"\") | gsub(\"password[= ][^ ]*\"; \"password=\") | gsub(\"ghp_[A-Za-z0-9_]+\"; \"\") | gsub(\"gho_[A-Za-z0-9_]+\"; \"\") | gsub(\"ghs_[A-Za-z0-9_]+\"; \"\") | gsub(\"github_pat_[A-Za-z0-9_]+\"; \"\"))' >> ~/.claude/cost-tracker.log 2>/dev/null || true;\nprintf '%s\n' \"$INPUT\"" + } + ], + "description": "Cost tracker - log bash tool usage with timestamps" + }, { "matcher": "Bash", "hooks": [