1
0
Fork 0
claude-code-complete-agent/hooks/post-tool-use.sh
Kjell Tore Guttormsen 2491f5c732 feat: initial companion repo for OpenClaw vs Claude Code article
40 files demonstrating every major OpenClaw capability using Claude Code:
- 3 agents (researcher, writer, reviewer)
- 3 skills (daily-briefing, slack-message, web-research)
- 2 security hooks (pre-tool-use blocker, post-tool-use logger)
- 10 self-contained examples with copy-paste prompts
- Complete feature map (20 capabilities, 11 full match, 7 different, 2 gap)
- Security docs including NemoClaw comparison
- Automation, messaging, browser, memory documentation

Zero dependencies. Clone and run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 09:47:29 +01:00

21 lines
857 B
Bash
Executable file

#!/bin/bash
# PostToolUse hook: Log all tool executions to an audit trail.
#
# This hook runs AFTER every tool execution and appends a log entry
# to hooks/audit.log. Useful for reviewing what Claude Code did
# during a session.
#
# OpenClaw equivalent: command-logger hook + OpenTelemetry (NemoClaw)
# Claude Code approach: PostToolUse hooks with custom logging
input=$(cat)
tool_name=$(echo "$input" | python3 -c "import sys,json; print(json.load(sys.stdin).get('tool_name',''))" 2>/dev/null)
tool_input=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin).get('tool_input',{}); print(d.get('command', d.get('file_path', d.get('pattern', str(d)[:100])))" 2>/dev/null)
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
log_dir="$(dirname "$0")"
log_file="$log_dir/audit.log"
echo "$timestamp | $tool_name | $tool_input" >> "$log_file"
exit 0