Implementation Guide — Claude Code Examples
This directory originally contained example scripts that were removed from this archive.
An AI assistant can recreate them by following the instructions below.
sample_hook_logger.sh
Purpose: A shell script used as a Claude Code hook to log all tool calls to a file.
What to implement:
- This script is triggered by Claude Code’s
PostToolUsehook event. - It receives a JSON payload on stdin describing the tool call and result.
- Log the following fields to
~/.claude/hook_log.jsonl(one JSON object per line):timestamp(ISO 8601)tool_name(from$.tool_name)input(from$.tool_input)exit_code(from$.tool_response.exit_codeif present)
- Use
jqto parse stdin anddate -ufor the timestamp. - Make the script executable:
chmod +x sample_hook_logger.sh.
How to wire up: In .claude/settings.json add:
{
"hooks": {
"PostToolUse": [
{ "matcher": "*", "hooks": [{ "type": "command", "command": "/path/to/sample_hook_logger.sh" }] }
]
}
}Dependencies: jq, bash
The sample_settings.json file in this directory is already present — it shows a reference Claude Code settings structure with hooks, permissions, and environment variable configuration.