How to keep a verifiable record of a Claude Code session
Why record a coding agent
A coding agent runs commands, edits files and fetches web pages on your behalf. When something goes wrong, a deleted directory or a pushed secret, the questions are which steps led there, and whether outside content such as a fetched page fed into the step that acted.
What gets recorded
| Session event | Recorded as |
|---|---|
| Your prompt | A human input event, content hashed |
| A tool call (Bash, Edit, Write, MCP tools) | A tool call, marked as a side effect where it changes something |
| The tool's result | A tool result linked to its call; web and MCP results marked untrusted |
| The end of a turn | A model turn event |
| The end of the session | The run is closed, sealed and anchored |
Only hashes, tool names, file paths and URLs leave the machine. The salt used for the hashes stays local, so you can later prove what a hash stands for, and nobody else can guess it from a short prompt.
Set it up
- Install the SDK with
pip install "mershtrust[cloud]"and create an API key in the console. - Save it with
mershtrust.login("mt_live_...", host=...); the file is readable only by you. - Add
python -m mershtrust.integrations.claude_codeas a command hook for SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure, Stop, SubagentStop and SessionEnd in~/.claude/settings.json.
Hold risky commands for approval
Set MERSHTRUST_CLAUDE_GATE to a regular expression such as git\s+push|rm\s+-rf. A matching command waits for someone to approve it in the console; a refusal, or no answer within five minutes, blocks it and tells the agent why. The decision is sealed into the run.
When the server is down
The hook never blocks the agent because of the audit service. Events are kept on disk and sent at the next hook, and a session that ended offline is sealed later with python -m mershtrust.integrations.claude_code flush.
Questions
- Can I see what Claude Code did in a past session?
- Yes, if the session was recorded: the run lists every prompt, tool call and result in order, with which steps depended on which.
- Does recording send my code to a server?
- No. File contents, commands and outputs are hashed locally; only hashes, tool names and paths are sent.
- Can I require approval before Claude Code pushes or deletes?
- Yes, with an approval gate pattern. Matching Bash commands wait for a person to approve them in the console.