# Connecting Claude Code to Treasure AI

[Claude Code](https://code.claude.com/docs) is Anthropic's CLI for agentic coding. Connect it to Treasure AI to query databases, build segments, debug workflows, and search documentation from natural-language prompts, without switching to the TD Console.

Our Claude Code integration supports two billing patterns — Treasure AI's AI Credits or your own Anthropic Enterprise subscription.

## Prerequisites

- [Claude Code](https://code.claude.com/docs) installed
- Node.js and npm
- A Treasure AI account with API access


## Quick Start 1: with Treasure AI Subscription

Use this pattern if you don't have your own Claude subscription, or want to bill Claude Code usage through Treasure AI. `tdx claude` launches Claude Code pre-configured with [Treasure AI's AI Credits](https://www.treasure.ai/terms/ai-credits-definition/) billing, TD Skills, and documentation search already installed — no separate Claude Code subscription required.

```bash
npm install -g @treasuredata/tdx
tdx auth setup
tdx claude
```

Once inside, ask Claude Code to operate on your data:

```
> Create a segment of customers who abandoned their cart in the last 7 days

● Reading parent segment schema (tdx ps describe)
● Drafting rules → cart_abandoners_7d.yml
● Validating (tdx sg validate) ✓ 128,540 profiles matched

✓ Segment "Cart Abandoners – 7d" pushed to production.
```

For command-level details on what `tdx claude` configures, see the [tdx claude command reference](/treasure-code/commands/claude).

## Quick Start 2: with Your Anthropic Subscription

Use this pattern if your organization already has an Anthropic Enterprise, AWS Bedrock, or Vertex AI subscription for Claude Code and wants to keep billing there.

With the `--no-proxy` option, it launches your existing Claude Code account with TD Skills and documentation search pre-configured. See the [tdx claude command reference](/treasure-code/commands/claude) for the full list of options.

```bash
npm install -g @treasuredata/tdx
tdx auth setup
tdx claude --no-proxy
```

Alternatively, you can manually install skills to your Claude Code setup. See [TD Skills](/treasure-code/guide/td-skills) for the full skill catalog and single-skill install commands.

```bash
/plugin marketplace add treasure-data/td-skills
/plugin install tdx-skills@td-skills
/plugin install sql-skills@td-skills
/plugin install workflow-skills@td-skills
```

Additionally, you need to let Claude Code search Treasure AI documentation directly via [MCP Server (Docs)](/getting-started/ai/mcp-server-docs) for solving errors quickly and reliably.

```bash
claude mcp add td-docs https://docs.treasure.ai/mcp --transport http
```

Verify the connection with `/mcp` in the Claude Code CLI — it lists `td-docs` with its available tools.

## Next Steps

- [MCP Server (Docs)](/getting-started/ai/mcp-server-docs) — reference for documentation search tools
- [MCP Server (Platform)](/getting-started/ai/mcp-server-platform) — reference for `tdx_run` and `tdx_search`
- [TD Skills](/treasure-code/guide/td-skills) — full skill catalog for SQL, workflows, and CDP operations
- [tdx claude command reference](/treasure-code/commands/claude)
- Connect a different tool: [OpenAI Codex](/getting-started/ai/openai-codex) · [VS Code and GitHub Copilot](/getting-started/ai/vscode-github-copilot) · [Cursor](/getting-started/ai/cursor)
- [Why teams pair Claude Code with Treasure AI](https://www.treasure.ai/works-with/claude-code)