command-logger — Claude Code hook: what it does, how to install
Records every Claude Code tool call with a timestamp and file path to a local text file for debugging and auditing.
npx claude-code-templates@latest --hook development-tools/command-loggerWhat command-logger does
This hook triggers on the PreToolUse event across all tool calls. Before Claude Code executes an action, it appends an entry containing the current date, $CLAUDE_TOOL_NAME, and $CLAUDE_TOOL_FILE_PATH to ~/.claude/command-log.txt.
The setup relies purely on a shell echo command without extra runtimes or external services. Logging fails if the shell cannot write to ~/.claude/command-log.txt.
What it helps with
- log tool execution history locally
- audit file modifications and inspect accessed paths
- troubleshoot automated sessions during debugging
Example prompts for the agent
- Run the test suite and check the command output
- Update the source code according to the issue description
How to install command-logger
1claude-code-templates
npx claude-code-templates@latest --hook development-tools/command-logger2Manually: put the files in place
.claude/settings.jsonThe hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json
Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command
Questions about command-logger
How do I install command-logger in Claude Code?
Run npx claude-code-templates@latest --hook development-tools/command-logger in your terminal or insert the hook configuration into .claude/settings.json.
What does command-logger do?
It captures every tool invocation right before execution and appends the timestamp, tool name, and target path to ~/.claude/command-log.txt.
Where does command-logger save the log file?
Output goes directly to ~/.claude/command-log.txt on the local machine using basic shell redirection.
Source text
command-logger.json · MIT
{
"description": "Log all Claude Code commands to a file for audit and debugging purposes. Simple logging that records tool usage with timestamps.",
"hooks": {
"PreToolUse": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "echo \"[$(date)] Tool: $CLAUDE_TOOL_NAME | File: $CLAUDE_TOOL_FILE_PATH\" >> ~/.claude/command-log.txt"
}
]
}
]
}
}
© davila7 · MIT · davila7/claude-code-templates