# Claude Code Integration

Launch [Claude Code](https://docs.anthropic.com/en/docs/claude-code) with Treasure Data's [TD LLM Proxy](https://docs.treasuredata.com/products/customer-data-platform/ai-agent-foundry) as the backend.

Treasure Data customers can use Claude Code with their existing [AI Suite credits](https://www.treasuredata.com/terms/ai-suite-credits-definition/) — no separate Claude subscription required.

## Features

- **Use Your Own TD Subscription** - Run Claude Code using [AI Suite credits](https://www.treasuredata.com/terms/ai-suite-credits-definition/)
- **Full Claude Code Features** - Extended thinking, plan mode, subagents, and Opus model support
- **TD Documentation Search** - AI-powered search across [Treasure Data documentation](https://docs.treasuredata.com/getting-started)
- **TD Skills Integration** - Enhanced with [td-skills](/treasure-code/guide/td-skills) for writing SQL queries, workflows, and building user segments on CDP


## Architecture


```mermaid
flowchart LR
    subgraph TDX["tdx claude"]
        CC["Claude Code<br/>• td-skills • td-docs MCP"]
        Proxy["Local Proxy"]
    end

    subgraph TD[Treasure Data]
        LLM[TD LLM Proxy]
    end

    CC <-->|/v1/messages| Proxy
    Proxy <-->|Anthropic API| LLM

    style TDX fill:transparent,stroke:#888
    style CC padding:10px
```

When you run `tdx claude`:

1. Starts a local pass-through proxy for TD LLM Proxy
2. Launches Claude Code with [td-skills](/treasure-code/guide/td-skills) and td-docs MCP pre-configured
3. The proxy forwards Claude Code API requests (`/v1/messages`) to TD's [LLM Proxy](https://docs.treasuredata.com/products/customer-data-platform/ai-agent-foundry), which provides Anthropic-compatible API access to Claude models


## Usage


```bash
tdx claude [options] [-- claude-options]
```

## Options

| Option | Description |
|  --- | --- |
| `-c, --continue` | Continue most recent conversation |
| `-r, --resume` | Resume a conversation (shows selector) |
| `--no-proxy` | Use your own Claude Code account (Anthropic/AWS Bedrock/Vertex AI, etc.) |


## Examples


```bash
# Launch Claude Code with TD LLM Proxy
tdx claude

# Continue most recent conversation
tdx claude -c

# Resume a conversation (shows selector)
tdx claude -r

# Start with an initial prompt
tdx claude -- "Explain this code"

# Use your own Claude Code account with TD skills
tdx claude --no-proxy
```

## Example Conversations

Once inside Claude Code, you can ask questions like:


```
> How to set up data ingestion to TD from Snowflake?

> How to add web access log collector in my web page?

> Analyze mydb.user_events data

> Write a workflow to periodically import data from S3

> Create a SQL query to find top customers by revenue

> Build a user segment for customers who purchased in the last 30 days
```

## Requirements

### Install Claude Code

See the [Claude Code Quick Start](https://code.claude.com/docs/en/quickstart) for installation instructions.


```bash
curl -fsSL https://claude.ai/install.sh | bash
```

Minimum Version
Claude Code **2.0.20 or later** is required for td-skills support. Update with:


```bash
claude update
```

### Other Requirements

- Valid TD API key with LLM access


## Subcommands

### usage

Show AI Suite credit consumption statistics by profile.


```bash
tdx claude usage [options]
```

| Option | Description |
|  --- | --- |
| `--json` | Output as JSON |
| `--jsonl` | Output as JSON Lines |


**Example:**


```bash
# Display credit usage by profile
tdx claude usage

# JSON output for programmatic access
tdx claude usage --json
```

**Output:**


```
AI Suite Credit Usage Summary
──────────────────────────────────────────────────
  Today:   0.24 credits
  Month:   2.15 credits
  Total:   10.45 credits

Usage by Profile
────────────────────────────────────────────────────────────
  Profile          Credits    Requests  Last Used
  (default)           8.23         245  today 10:30 AM
  production          2.22          30  yesterday

Note: Credit values are estimates based on token usage.
```

### statusline

Output credit usage for Claude Code's status bar. This is automatically configured when running `tdx claude`. See [Claude Code Statusline Documentation](https://code.claude.com/docs/en/statusline) for more details.


```bash
tdx claude statusline
```

Reads session info from stdin (JSON with `session_id` and `model`) and outputs a formatted statusline.

When using `--profile`, the statusline shows profile-specific today/month credits:


```bash
tdx --profile myprofile claude
```

**Output:**


```
🤖 tdx - Sonnet 4.5 | 🪙 credit: 0.12 session / 1.23 today / 10.45 month | 🧠 22,396 (11%)
```

The statusline shows:

- Current model name
- Session / Today / Month credits (estimates, filtered by profile when specified)
- Context memory usage


## Learn More

For generic Claude Code usage, refer to the official documentation:

- [Claude Code Documentation](https://code.claude.com/docs)
- [Claude Code in Action (Tutorial)](https://anthropic.skilljar.com/claude-code-in-action)