Skip to content

Instantly share code, notes, and snippets.

@mohitmun
Created October 16, 2025 07:33
Show Gist options
  • Select an option

  • Save mohitmun/1911b64e036bbd569d09f13aee01e7d2 to your computer and use it in GitHub Desktop.

Select an option

Save mohitmun/1911b64e036bbd569d09f13aee01e7d2 to your computer and use it in GitHub Desktop.
Don't use the code you don't understand -Anon
#!/usr/bin/env python3
import sys
import json
import time
import os
data = json.load(sys.stdin)
ts = time.strftime("%Y-%m-%d %H:%M:%S")
log_entry = f"[{ts}] {json.dumps(data)}\n"
session_id = data.get("session_id", "unknown")
tool_name = data.get("tool_name", "unknown")
file_path = ""
if "tool_response" in data and isinstance(data["tool_response"], dict):
file_path = data["tool_response"].get("filePath", "")
if not file_path and "file" in data["tool_response"]:
file_path = data["tool_response"]["file"].get("filePath", "")
if file_path and tool_name in ["Edit", "Write", "Read"]:
project_dir = os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd())
local_audit_file = os.path.join(project_dir, "claude_audit.md")
local_entry = f"{session_id}:{tool_name}:{file_path}\n"
with open(local_audit_file, "a", encoding="utf-8") as f:
f.write(local_entry)
global_audit_file = os.path.expanduser("~/.claude/claude_global_audit.md")
global_entry = f"{session_id}:{tool_name}:{project_dir}:{file_path}\n"
with open(global_audit_file, "a", encoding="utf-8") as f:
f.write(global_entry)
with open(os.path.expanduser("~/Desktop/hooks_data.log"), "a", encoding="utf-8") as f:
f.write(log_entry)
response = {
"continue": True,
"suppressOutput": True
}
print(json.dumps(response))
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment