Claude Code
Add Treeship to Claude Code for signed, verifiable session receipts of every tool call and command.
Claude Code integration uses the instruction boundary pattern: add TREESHIP.md to your project root and Claude Code follows the instructions to wrap commands, track costs, and produce verifiable receipts.
Quick setup
Install Treeship CLI
curl -fsSL treeship.dev/install | sh
treeship initAdd TREESHIP.md to your project
Copy the skill file from the Treeship repo:
curl -o TREESHIP.md https://raw.githubusercontent.com/zerkerlabs/treeship/main/TREESHIP.mdClaude Code reads TREESHIP.md automatically when it exists in the project root.
Start a session
Claude Code will follow the TREESHIP.md instructions to start a session, wrap commands, and close with a narrative. You can also start manually:
treeship session start --name "my task"How it works
Claude Code's built-in tools (read_file, write_file, bash, search) are not MCP server tools. They run inside the Claude Code runtime. Treeship captures them through the command wrapping pattern:
- Claude Code reads
TREESHIP.mdfrom the project root - The skill instructs Claude Code to prefix every shell command with
treeship wrap -- - Each wrapped command produces a signed artifact with the command string, exit code, duration, and output digest
- At session close, all artifacts are composed into a Session Receipt with a Merkle root
Environment variables for rich receipts
Set these before starting Claude Code to capture model and cost data:
export TREESHIP_MODEL=claude-opus-4-6
export TREESHIP_TOKENS_IN=12000
export TREESHIP_TOKENS_OUT=3000
export TREESHIP_COST_USD=0.42These flow into the receipt's agent table showing model, token counts, and cost per interaction.
Live monitoring
While Claude Code is working, watch the session in real time from another terminal:
treeship session status --watchThis shows a live TUI with agents, events, security status, and verification progress updating every 2 seconds.
What appears in the receipt
| Section | Content | Capture method |
|---|---|---|
| Agent identity | "treeship-cli", model name, host | TREESHIP_MODEL env var [AUTO] |
| Timeline | Every wrapped command in order | treeship wrap events [AUTO] |
| Commands | Full command strings with exit codes | Process events [AUTO] |
| File operations | Created/modified/deleted files | File snapshot diff [AUTO] |
| Cost | Model, tokens, cost per wrap | Env vars [EXPLICIT] |
| Narrative | Headline, summary, review | CLI flags at close [EXPLICIT] |
Claude Code's file reads (when it reads source code to understand context) are NOT captured through wrapping. To capture file reads, run treeship daemon start before the session. The daemon uses atime-based detection for sensitive files (.env, .ssh, .aws).
Attach to Hub for shareable receipts
treeship hub attach --endpoint https://api.treeship.devFollow the device code flow to authenticate. Then after any session:
treeship session reportThis uploads the receipt and prints a permanent public URL like https://treeship.dev/receipt/ssn_xxx.
Integration patterns
| Pattern | What it captures | Setup |
|---|---|---|
TREESHIP.md in project root | Shell commands via wrapping | Drop-in, zero config |
treeship daemon start | Sensitive file reads via atime | One command |
TREESHIP_MODEL env var | Model, tokens, cost | Environment setup |
treeship session status --watch | Live monitoring | Separate terminal |
What is NOT captured
- Claude Code's internal tool calls (read_file, write_file, search): these happen inside the runtime and are not shell commands. They don't go through
treeship wrap. - Network connections: not auto-captured. Use
treeship session event --type agent.connected_networkexplicitly. - Multi-agent handoffs: only captured if agents explicitly emit handoff events.
The TREESHIP.md skill is honest about this boundary. The receipt proves what was instrumented, not everything the agent did.