Skip to main content

Claude Code & Cursor Integration

Add Treeship verification to Claude Code (Anthropic) and Cursor agents for tamper-proof records of every action.

For Cursor / IDE Agents

Add this to your project’s CLAUDE.md to enable automatic verification:
## Treeship Verification

This project uses [Treeship](https://treeship.dev) for tamper-proof verification of AI agent actions.

### Setup

\`\`\`bash
pip install treeship-sdk
export TREESHIP_API_KEY=ts_live_...  # Get key at https://treeship.dev
\`\`\`

### Usage

After completing significant actions (approvals, decisions, generated outputs), create an attestation:

\`\`\`python
from treeship_sdk import Treeship

ts = Treeship()

# After any important action
result = ts.attest(
    agent="your-agent-name",
    action="Description of what was done",
    inputs_hash=ts.hash({"relevant": "data"})  # Hash of inputs - never sent to Treeship
)

print(f"Verified: {result.url}")
\`\`\`

### When to Attest

Create attestations for:
- Decisions (approvals, rejections, escalations)
- Generated content (reports, summaries, code)
- External actions (API calls, file modifications, deployments)
- Data processing (analysis results, transformations)

Python SDK Integration

pip install treeship-sdk anthropic
from anthropic import Anthropic
from treeship_sdk import Treeship

client = Anthropic()
ts = Treeship()

def run_agent_with_verification(user_message: str):
    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=4096,
        messages=[{"role": "user", "content": user_message}]
    )
    
    attestation = ts.attest(
        agent="claude-code-agent",
        action=f"Processed: {user_message[:100]}",
        inputs_hash=ts.hash({
            "user_message": user_message,
            "model": "claude-sonnet-4-20250514"
        })
    )
    
    return {
        "response": response.content[0].text,
        "verification_url": attestation.verify_url
    }

Tool Use Verification

Attest each tool execution for a complete audit trail:
def execute_tool_with_verification(tool_name: str, tool_input: dict):
    result = execute_tool(tool_name, tool_input)
    
    attestation = ts.attest(
        agent="claude-code-agent",
        action=f"Tool: {tool_name}",
        inputs_hash=ts.hash(tool_input),
        metadata={
            "tool_name": tool_name,
            "success": result.success
        }
    )
    
    return result, attestation.url

Extended Thinking Attestation

For Claude with extended thinking, attest the reasoning bound to the output:
response = client.messages.create(
    model="claude-opus-4-6",
    thinking={"type": "enabled", "budget_tokens": 8000},
    messages=[{"role": "user", "content": prompt}]
)

thinking_block = response.content[0]  # the reasoning
output_block = response.content[1]    # the response

ts.attest(
    agent="reasoning-agent",
    action=f"Analysis: {output_block.text[:100]}",
    inputs_hash=ts.hash({
        "thinking_hash": ts.hash(thinking_block.thinking),
        "output_hash": ts.hash(output_block.text),
        "model": "claude-opus-4-6"
    })
)

MCP Server Integration

from treeship_sdk import Treeship

ts = Treeship()

class VerifiedMCPServer:
    def __init__(self, server_name: str):
        self.server_name = server_name
    
    async def call_tool(self, tool_name: str, arguments: dict):
        result = await self.mcp_client.call_tool(tool_name, arguments)
        
        ts.attest(
            agent=f"mcp-{self.server_name}",
            action=f"MCP tool: {tool_name}",
            inputs_hash=ts.hash(arguments)
        )
        
        return result

Privacy Contract

Sent to TreeshipStays local
Agent nameActual data
Action descriptionFiles, PII
SHA-256 hash of inputsRaw inputs
You control what’s in the action description. Sensitive data never leaves your infrastructure.

Verification Page

Every action creates a verification URL:
https://treeship.dev/verify/claude-code-agent
Share with clients to prove exactly what your agent did.

Next Steps