Metadata-Version: 2.4
Name: snowflake-claude-code
Version: 1.1.0
Summary: Run Claude Code against Claude models hosted on Snowflake Cortex.
Project-URL: Homepage, https://github.com/dylan-murray/snowflake-claude-code
Project-URL: Repository, https://github.com/dylan-murray/snowflake-claude-code
Project-URL: Issues, https://github.com/dylan-murray/snowflake-claude-code/issues
Author: Dylan Murray
License: MIT License
        
        Copyright (c) 2026 Dylan Murray
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: anthropic,claude,claude-code,cortex,llm,proxy,snowflake
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: fastapi>=0.111.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: rich>=12.3.0
Requires-Dist: snowflake-connector-python[secure-local-storage]>=4.4.0
Requires-Dist: snowflake>=1.12.0
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
Requires-Dist: typer>=0.16.0
Requires-Dist: uvicorn>=0.24.0
Description-Content-Type: text/markdown

# ❄️ snowflake-claude-code

[![PyPI](https://img.shields.io/pypi/v/snowflake-claude-code.svg)](https://pypi.org/project/snowflake-claude-code/)
[![CI](https://github.com/dylan-murray/snowflake-claude-code/actions/workflows/ci.yml/badge.svg)](https://github.com/dylan-murray/snowflake-claude-code/actions/workflows/ci.yml)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Run [Claude Code](https://claude.com/product/claude-code) against Claude models served by [Cortex](https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions) inside your Snowflake account, so prompts and responses never leave your Snowflake governance boundary.

```
Claude Code  →  FastAPI proxy (127.0.0.1:4000)  →  Snowflake Cortex Inference
```

The CLI authenticates to Snowflake (SSO or PAT), starts a local proxy that translates Anthropic Messages API calls to Cortex Inference calls (SSE streaming included), and launches Claude Code pointed at the proxy.

## ⚡ Quick start

```bash
uv tool install snowflake-claude-code
npm install -g @anthropic-ai/claude-code
snowflake-claude-code --account MYORG-MYACCOUNT --user me@company.com
```

Browser pops for Snowflake SSO, proxy spins up, Claude Code launches.

## 🔒 Why

**Your Claude Code session never talks to Anthropic.** Every prompt, file read, tool call, and model response goes over TLS to the same Snowflake endpoint your warehouse queries already use — governed by your existing Snowflake trust boundary, not a new third-party LLM vendor.

- 🚫 **No traffic to Anthropic.** The proxy binds to `127.0.0.1` only; the only outbound endpoint is your Snowflake account's API.
- 🛡️ **Snowflake IAM applies.** Role, warehouse, and network policy controls gate model access. Revoke Snowflake → revoke AI.
- 🔑 **Familiar auth.** Browser SSO flows through your existing IdP; PATs for headless.
- 📝 **Full audit trail.** Every call lands in `SNOWFLAKE.ACCOUNT_USAGE.CORTEX_REST_API_USAGE_HISTORY`.
- 🌍 **Data residency honored.** Inference runs in your account's region.
- 🧠 **No training on your data.** Per [Snowflake Cortex terms](https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions#data-usage).
- 💰 **Consolidated spend.** Cortex tokens roll up with your warehouse costs.
- ♻️ **Transparent re-auth.** Expired tokens trigger a silent refresh mid-session.

## 📦 Install

Requires Python 3.10+ and the [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI.

```bash
uv tool install snowflake-claude-code     # recommended
pipx install snowflake-claude-code        # or pipx
pip install snowflake-claude-code         # or pip
uvx snowflake-claude-code ...             # or run without installing
```

And Claude Code itself:

```bash
npm install -g @anthropic-ai/claude-code
```

## 🚀 Usage

```bash
snowflake-claude-code \
  --account MYORG-MYACCOUNT \
  --user me@company.com \
  --model opus
```

### Flags

| Flag | Default | Description |
|------|---------|-------------|
| `--account` | — | Snowflake account identifier |
| `--user` | — | Snowflake username (required) |
| `--model` | `sonnet` | Cortex model ID, or a family alias (`opus`, `sonnet`, `haiku`) |
| `--port` | `4000` | Local proxy port |
| `--token` | — | Snowflake PAT — pair with `--user` to skip browser SSO |
| `--list-models` | — | Print the Cortex models this account can reach, then exit |
| `--verbose`, `-v` | off | Debug logging |

### Environment variables

Any flag can also be provided via an env var — useful for shell profiles, CI, or devcontainers:

| Env var | Equivalent flag |
|---------|-----------------|
| `SNOWFLAKE_ACCOUNT` | `--account` |
| `SNOWFLAKE_USER` (or `SNOWFLAKE_USERNAME`) | `--user` |
| `SNOWFLAKE_MODEL` | `--model` |
| `SNOWFLAKE_PORT` | `--port` |
| `SNOWFLAKE_TOKEN` | `--token` |

```bash
export SNOWFLAKE_ACCOUNT=MYORG-MYACCOUNT
export SNOWFLAKE_USER=me@company.com
snowflake-claude-code
```

### Config file

Or persist them in `~/.snowflake-claude-code/config.toml`:

```toml
account = "MYORG-MYACCOUNT"
user = "me@company.com"
default_model = "sonnet"
port = 4000
# token = "pat-..."   # optional, skips SSO
```

Precedence: **CLI flags > env vars > config file > defaults.**

## 🤖 Supported models

Pass `--model` either a **family alias** or an explicit Cortex model ID.

| Value | Resolves to |
|-------|-------------|
| `sonnet` | Newest generally available Sonnet on your account (the default) |
| `opus` | Newest generally available Opus |
| `haiku` | Newest generally available Haiku |
| `claude-opus-5` (or any ID) | Used verbatim — including public-preview and non-Claude models |

Explicit IDs are passed through untouched, so a `--model` flag or `default_model`
pinned before aliases existed keeps selecting exactly the model it names.

Aliases resolve at startup from `SHOW CORTEX BASE MODELS`, so they track new
Cortex releases without an upgrade, and only ever pick a **GA** model — preview
models must be named explicitly. The query is filtered to models your role holds
grants on, needs no running warehouse, and costs no credits. If it fails, a
built-in last-known-good list is used instead.

`/v1/models` advertises whatever your account can actually reach, which is what
Claude Code's model picker shows. To see the same list from the terminal — and
what each alias resolves to on your account — run `snowflake-claude-code --list-models`.

Region availability still applies — a model listed for your account may need
[cross-region inference](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cross-region-inference)
to run. Non-Claude Cortex models work for plain chat (`--model mistral-large2`,
`--model llama3.1-70b`); tool-calling compatibility varies.

## 🔍 Verify traffic is hitting Snowflake

```sql
SELECT START_TIME, MODEL_NAME, TOKENS, USER_ID, INFERENCE_REGION
FROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_REST_API_USAGE_HISTORY
WHERE START_TIME >= CURRENT_DATE()
ORDER BY START_TIME DESC;
```

`ACCOUNT_USAGE` views lag 45 min–3 hours. For real-time, run with `--verbose`.

## 🏗️ Architecture

```
snowflake_claude_code/
├── cli.py        Parse config, start proxy, launch `claude` subprocess
├── proxy.py      FastAPI app: /v1/messages, /v1/models, /v1/health
├── translate.py  Anthropic ⇄ Cortex format translation + SSE adapter
├── models.py     Cortex model discovery + family alias resolution
├── auth.py       Snowflake connector + re-auth on 401
└── config.py     Layered config loader
```

The proxy binds to `127.0.0.1` only. The Snowflake token lives in process memory for the session lifetime and is cleared on exit.

## 🛠️ Development

```bash
git clone https://github.com/dylan-murray/snowflake-claude-code.git
cd snowflake-claude-code
uv sync --group dev

uv run pytest
uv run ruff check .
uv run ruff format .
```

CI runs on Python 3.10–3.14, against the locked dependencies, the lowest declared bounds, and the newest versions on PyPI.

## 📄 License

MIT — see [LICENSE](LICENSE).
