claude-artifact-cli 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claude_artifact_cli-0.2.0/PKG-INFO +424 -0
- claude_artifact_cli-0.2.0/README.md +394 -0
- claude_artifact_cli-0.2.0/src/claude_artifact_cli/__init__.py +1 -0
- claude_artifact_cli-0.2.0/src/claude_artifact_cli/api.py +560 -0
- claude_artifact_cli-0.2.0/src/claude_artifact_cli/cli.py +693 -0
- claude_artifact_cli-0.1.0/PKG-INFO +0 -273
- claude_artifact_cli-0.1.0/README.md +0 -243
- claude_artifact_cli-0.1.0/src/claude_artifact_cli/__init__.py +0 -1
- claude_artifact_cli-0.1.0/src/claude_artifact_cli/api.py +0 -324
- claude_artifact_cli-0.1.0/src/claude_artifact_cli/cli.py +0 -255
- {claude_artifact_cli-0.1.0 → claude_artifact_cli-0.2.0}/.gitignore +0 -0
- {claude_artifact_cli-0.1.0 → claude_artifact_cli-0.2.0}/LICENSE +0 -0
- {claude_artifact_cli-0.1.0 → claude_artifact_cli-0.2.0}/pyproject.toml +0 -0
- {claude_artifact_cli-0.1.0 → claude_artifact_cli-0.2.0}/src/claude_artifact_cli/__main__.py +0 -0
- {claude_artifact_cli-0.1.0 → claude_artifact_cli-0.2.0}/src/claude_artifact_cli/auth.py +0 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: claude-artifact-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Publish, update, list and inspect Claude Artifacts from the terminal, using the Claude Code login already on your machine.
|
|
5
|
+
Project-URL: Homepage, https://github.com/nikships/claude-artifact-cli
|
|
6
|
+
Project-URL: Repository, https://github.com/nikships/claude-artifact-cli
|
|
7
|
+
Project-URL: Issues, https://github.com/nikships/claude-artifact-cli/issues
|
|
8
|
+
Project-URL: Releases, https://github.com/nikships/claude-artifact-cli/releases
|
|
9
|
+
Author-email: Nik <nik.anand.1998@gmail.com>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agent-skill,ai,anthropic,artifacts,automation,claude,claude-artifacts,claude-code,cli,command-line,developer-tools,html,llm,publish,terminal
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
26
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
27
|
+
Classifier: Topic :: Utilities
|
|
28
|
+
Requires-Python: >=3.10
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
<div align="center">
|
|
32
|
+
|
|
33
|
+
<img src="https://raw.githubusercontent.com/nikships/claude-artifact-cli/main/assets/header.png" alt="claude-artifact-cli: publish Claude Artifacts from your terminal" width="100%" />
|
|
34
|
+
|
|
35
|
+
# claude-artifact-cli
|
|
36
|
+
|
|
37
|
+
Publish, update, pull, list and inspect Claude Artifacts from the terminal, using the Claude Code login already on your machine.
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/claude-artifact-cli/)
|
|
40
|
+
[](https://pypi.org/project/claude-artifact-cli/)
|
|
41
|
+
[](https://github.com/nikships/claude-artifact-cli/actions)
|
|
42
|
+
[](https://github.com/nikships/claude-artifact-cli/blob/main/LICENSE)
|
|
43
|
+
[](https://github.com/nikships/claude-artifact-cli/stargazers)
|
|
44
|
+
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
## What is this?
|
|
48
|
+
|
|
49
|
+
`claude-artifact` publishes an HTML page (plus any CSS, JS and images it uses) as a [Claude Artifact](https://claude.ai/code/artifacts) and prints the link, and pulls an artifact's files back down to edit and republish. It talks to the same API the Claude Code `Artifact` tool uses and reuses the claude.ai login from `claude /login`. No API key, no config file, no dependencies beyond Python 3.10+.
|
|
50
|
+
|
|
51
|
+
Use it where the built-in tool can't reach: other coding agents (Droid, Codex, Cursor, OpenCode), subagents, shell scripts, Makefiles, git hooks and CI jobs.
|
|
52
|
+
|
|
53
|
+
> [!NOTE]
|
|
54
|
+
> Unofficial and not affiliated with Anthropic. It uses a private, undocumented API that can change or break without notice.
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uv tool install claude-artifact-cli # or: pipx install claude-artifact-cli
|
|
60
|
+
claude-artifact whoami # confirms the Claude Code login works
|
|
61
|
+
claude-artifact publish report.html --favicon 📊
|
|
62
|
+
# https://claude.ai/code/artifact/1c5586a4-acec-4266-a9aa-03dfa0912b43
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Run it once without installing:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
uvx --from claude-artifact-cli claude-artifact publish report.html
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Commands
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
claude-artifact publish FILE|DIR [options] publish or update an artifact
|
|
75
|
+
claude-artifact pull SLUG_OR_URL [DIR] [--force] [-q]
|
|
76
|
+
download the artifact's files into DIR
|
|
77
|
+
claude-artifact status [PATH] [--slug S | --url U]
|
|
78
|
+
compare local files with what's live
|
|
79
|
+
claude-artifact list [--scope mine|shared|all] [--limit N]
|
|
80
|
+
claude-artifact read SLUG_OR_URL [-o FILE] metadata + published file manifest
|
|
81
|
+
claude-artifact read SLUG_OR_URL --path P [--path P ... --out-dir DIR]
|
|
82
|
+
a published file's exact bytes
|
|
83
|
+
claude-artifact whoami check that auth works
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The URL goes to stdout and progress goes to stderr, so `URL=$(claude-artifact publish page.html -q)` captures only the link. Add `--json` to `publish`, `status`, `list` or `read` for raw output. Exit codes: `0` success, `1` API error, `2` auth error, `3` version conflict (HTTP 409), `130` interrupted.
|
|
87
|
+
|
|
88
|
+
Wherever a command takes a slug or URL (`SLUG_OR_URL`, `--slug`, `--url`), it accepts any of:
|
|
89
|
+
|
|
90
|
+
- `https://claude.ai/code/artifact/<uuid>`
|
|
91
|
+
- `https://claude.ai/artifact/<short id>`, the form claude.ai and Claude Code's Artifact tool show
|
|
92
|
+
- a bare UUID or a bare short id
|
|
93
|
+
|
|
94
|
+
### publish
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# new artifact; the title comes from the page's <title>
|
|
98
|
+
claude-artifact publish dashboard.html --favicon 📊 --description "Q3 numbers"
|
|
99
|
+
|
|
100
|
+
# update in place, same URL; published files you don't pass are kept
|
|
101
|
+
claude-artifact publish dashboard.html --url https://claude.ai/code/artifact/<slug>
|
|
102
|
+
claude-artifact publish dashboard.html --slug <slug>
|
|
103
|
+
|
|
104
|
+
# update, and make these files the whole artifact (anything else is removed)
|
|
105
|
+
claude-artifact publish dashboard.html --slug <slug> --mode replace --file app.css
|
|
106
|
+
|
|
107
|
+
# multi-file page
|
|
108
|
+
claude-artifact publish index.html \
|
|
109
|
+
--root ./site \
|
|
110
|
+
--file app.css --file app.js --file img/logo.png
|
|
111
|
+
|
|
112
|
+
# rename a file's published path, and drop one
|
|
113
|
+
claude-artifact publish index.html --slug <slug> \
|
|
114
|
+
--file styles.css=src/main.css \
|
|
115
|
+
--remove old.js
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Option | Meaning |
|
|
119
|
+
|--------|---------|
|
|
120
|
+
| `--slug`, `--url` | Update this artifact. Without one, a publish creates a new artifact (a directory with `.artifact.json` updates its own). |
|
|
121
|
+
| `--title` | Defaults to the page's `<title>`, else the file or directory name (for a typed directory, the title saved in `.artifact.json`). |
|
|
122
|
+
| `--favicon` | Emoji for the tab. Set it on a first publish. |
|
|
123
|
+
| `--description` | One-sentence subtitle. |
|
|
124
|
+
| `--icon`, `--label` | Generic icon word; short name for this publish. |
|
|
125
|
+
| `--file PUB[=SRC]` | Supporting file. Without `=`, published and source paths match. Repeatable. Not allowed with a directory. |
|
|
126
|
+
| `--root` | Base directory for `--file` sources. Published paths are unchanged. Not allowed with a directory. |
|
|
127
|
+
| `--remove PATH` | Delete a published file. Needs an existing artifact and patch mode; with no `--mode`, `--remove` uses patch. |
|
|
128
|
+
| `--mode patch\|replace` | `patch` overlays the manifest onto the base version, so published files you don't pass are kept. Default when updating a page. `replace` makes the manifest the whole artifact, so any published file you leave out is removed. Default for a new artifact and for the first publish of a directory. A directory with `.artifact.json` patches (see below). |
|
|
129
|
+
| `--base-version` | The version this publish was made against. If a newer version is live, the publish is refused with exit code `3`. Defaults to the version in a directory's `.artifact.json` (when publishing to the slug saved there). Without one, patch uses the live version and replace is not checked, so a concurrent publish goes undetected. |
|
|
130
|
+
| `--force` | Publish even if a newer version is live, discarding it. |
|
|
131
|
+
| `-q`, `--quiet` | Print only the URL. |
|
|
132
|
+
|
|
133
|
+
`--json` prints the deploy response with the artifact `url` added: `{"url", "slug", "version", …}`.
|
|
134
|
+
|
|
135
|
+
### Publish a directory
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
claude-artifact publish ./site --favicon 📊 # new artifact; writes ./site/.artifact.json
|
|
139
|
+
claude-artifact publish ./site # later: updates the same artifact
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Publishes every file under the directory, recursively, skipping dotfiles and dot-directories. `index.html` is required at the top level (except for a typed artifact, below); symlinks are refused. The first publish of a directory replaces: the directory is the whole artifact. Once `.artifact.json` lists its files, `publish DIR` patches: it sends the directory's files and removes the ones deleted locally since the last pull or publish, leaving files the directory never held (dot paths, a type's files) alone. `--mode replace` forces a full replace.
|
|
143
|
+
|
|
144
|
+
After each successful publish (and each `pull`) the CLI writes `DIR/.artifact.json`:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"slug": "…",
|
|
149
|
+
"url": "https://claude.ai/code/artifact/…",
|
|
150
|
+
"version": "…",
|
|
151
|
+
"title": "…",
|
|
152
|
+
"files": { "index.html": "<sha256>", "app.css": "<sha256>" }
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`files` maps each published path to the sha256 of what was published or pulled; `pull` uses it as the merge base. It is never published (dotfile). The next `publish DIR` updates that slug without `--slug` and sends the saved version as the base version, so if someone else published in between, the publish fails with exit code `3` instead of overwriting their version. Commit it or ignore it as you prefer.
|
|
157
|
+
|
|
158
|
+
**Typed artifacts.** An artifact made from an Artifact type (Slides, Design, …) holds files the type supplies, `index.html` among them. They stay fixed and `pull` leaves them out, marking the directory `"typed": true` in `.artifact.json`. `publish DIR` on a typed directory patches only the artifact's own files: no `index.html` is needed, a local `index.html` is refused, `--mode replace` is refused, and a file deleted locally since the last pull or publish is removed from the artifact. Start from `pull`; the directory must be linked to the artifact.
|
|
159
|
+
|
|
160
|
+
### pull
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
claude-artifact pull <slug-or-url> # into ./<slug>
|
|
164
|
+
claude-artifact pull <slug-or-url> ./site
|
|
165
|
+
claude-artifact publish ./site # after editing: same artifact, pulled version as base
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Downloads the live version's files into `DIR` (default: a directory named after the slug), writes `DIR/.artifact.json`, and prints `DIR` on stdout. stderr reports the version, files written and removed, local edits kept, and files left out: those the artifact's type supplies, and dot paths such as `.well-known/…`, which directories never hold (`read --path` still fetches them). `-q` silences it.
|
|
169
|
+
|
|
170
|
+
Pulling into a directory already linked to the same artifact merges file by file against the hashes in `.artifact.json`:
|
|
171
|
+
|
|
172
|
+
| Local | Live | Result |
|
|
173
|
+
|-------|------|--------|
|
|
174
|
+
| unchanged | changed | live version written |
|
|
175
|
+
| changed | unchanged | local edit kept |
|
|
176
|
+
| unchanged | deleted | file removed, with any directory left empty |
|
|
177
|
+
| untracked | not published | kept |
|
|
178
|
+
| changed | changed | conflict |
|
|
179
|
+
|
|
180
|
+
A file added or deleted counts as changed.
|
|
181
|
+
|
|
182
|
+
A conflict lists the files and writes nothing. To resolve it, copy your versions of those files out of the directory, pull again with `--force` (it takes the live version of conflicting files and still keeps your other edits), merge your changes back in, and publish. Or pull into another directory to compare by hand. A non-empty directory that isn't linked to this artifact is refused unless `--force`, which writes the artifact's files over it and leaves other files alone.
|
|
183
|
+
|
|
184
|
+
### status
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
claude-artifact status # current directory, slug from .artifact.json
|
|
188
|
+
claude-artifact status ./site
|
|
189
|
+
claude-artifact status page.html --slug <slug> # compares page.html with the published index.html only
|
|
190
|
+
claude-artifact status ./site --json
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
https://claude.ai/code/artifact/<slug>
|
|
195
|
+
live version 1789541006-9f63
|
|
196
|
+
base version 1789540112-04aa (someone published since - merge first)
|
|
197
|
+
same app.css
|
|
198
|
+
local-only img/new.png
|
|
199
|
+
changed index.html
|
|
200
|
+
remote-only old.js
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Compares the sha256 of each local file with the published manifest; for older artifacts whose manifest has no sha256, it fetches the file to compare. Files an Artifact type supplies, and dot paths, are ignored: directories never hold them. The base version line appears only for a directory with `.artifact.json`, and reads `(up to date)` when it matches the live version. When anything differs, stderr suggests `merge the live version in: claude-artifact pull <slug> DIR` for a linked directory, else `live copy: claude-artifact pull <slug> <another-dir>`. `--json` prints `{"slug", "url", "live", "base", "behind", "files": [{"state", "path"}]}`. `PATH` defaults to `.`; `--slug`/`--url` override `.artifact.json`.
|
|
204
|
+
|
|
205
|
+
On exit code `3` from `publish`:
|
|
206
|
+
|
|
207
|
+
- **Directory:** `claude-artifact pull <slug> DIR` merges the live version in, resolve any conflicts, then `claude-artifact publish DIR`.
|
|
208
|
+
- **Page:** compare with `status`, merge the live changes by hand, then publish again with `--base-version <live>`.
|
|
209
|
+
|
|
210
|
+
Either way, `--force` publishes anyway and discards the other version.
|
|
211
|
+
|
|
212
|
+
### list and read
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
claude-artifact list --scope shared
|
|
216
|
+
claude-artifact read <slug-or-url> # title, version, role, file manifest
|
|
217
|
+
claude-artifact read <slug> -o meta.json # also save the metadata JSON
|
|
218
|
+
|
|
219
|
+
claude-artifact read <slug> --path index.html > index.html # one file's exact bytes
|
|
220
|
+
claude-artifact read <slug> --path index.html --path app.css --out-dir ./out # saves, prints the paths
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
`read` returns metadata, paths, sizes, content types and sha256 hashes. Short-lived tokens in responses (`assetToken`, `subscriptionToken`, and `__frame_t=` on `list` thumbnail URLs) are replaced with `[redacted]` before they reach stdout or `-o`.
|
|
224
|
+
|
|
225
|
+
`read --path P` prints the published file's exact bytes to stdout instead, checked against the manifest's sha256. Repeat `--path` with `--out-dir DIR` to save several files under `DIR` at their published paths; it prints each saved path. `--path` doesn't combine with `--json` or `-o`, more than one `--path` needs `--out-dir`, and `--out-dir` needs `--path`.
|
|
226
|
+
|
|
227
|
+
Never WebFetch or curl a `claude.ai` artifact URL: it is a login-walled app shell and returns no page content.
|
|
228
|
+
|
|
229
|
+
## Auth
|
|
230
|
+
|
|
231
|
+
The token is looked up in this order:
|
|
232
|
+
|
|
233
|
+
1. `--token`
|
|
234
|
+
2. `$CLAUDE_ARTIFACT_TOKEN`, then `$CLAUDE_CODE_ARTIFACTS_API_TOKEN`
|
|
235
|
+
3. macOS Keychain, generic password service `Claude Code-credentials`
|
|
236
|
+
4. `~/.claude/.credentials.json`
|
|
237
|
+
|
|
238
|
+
It must be the **claude.ai OAuth token** from `claude /login`. The artifacts routes reject an `ANTHROPIC_API_KEY` with a 401. The token is short-lived; Claude Code refreshes it on launch and this tool re-reads it on every run, so there is nothing to rotate. `whoami` shows only the token's length and last few characters.
|
|
239
|
+
|
|
240
|
+
## Agent skill
|
|
241
|
+
|
|
242
|
+
[`skills/claude-artifact-cli/SKILL.md`](skills/claude-artifact-cli/SKILL.md) teaches any coding agent (Droid, Codex, Cursor, OpenCode, Claude Code subagents) when and how to use the CLI. Install it in the shared agent skills directory:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
mkdir -p ~/.agents/skills/claude-artifact-cli
|
|
246
|
+
curl -fsSL https://raw.githubusercontent.com/nikships/claude-artifact-cli/main/skills/claude-artifact-cli/SKILL.md \
|
|
247
|
+
-o ~/.agents/skills/claude-artifact-cli/SKILL.md
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Troubleshooting
|
|
251
|
+
|
|
252
|
+
| Symptom | Cause |
|
|
253
|
+
|---------|-------|
|
|
254
|
+
| `401 unauthorized` | An API key instead of the OAuth token, or an expired login. Start Claude Code once or run `claude /login`. |
|
|
255
|
+
| `removing a file needs --mode patch` | `--remove` with `--mode replace`. In replace mode, leave the file out instead. |
|
|
256
|
+
| `removing a file needs --slug/--url` | `--remove` on a new artifact. |
|
|
257
|
+
| `404 … isn't yours to update` | Wrong slug, deleted artifact, or another org. |
|
|
258
|
+
| `HTTP 409: a newer version (live version …)`, exit code `3` | Someone published since your base version. For a directory, `claude-artifact pull <slug> DIR`, resolve conflicts, `publish DIR`. For a page, `status`, merge, republish with `--base-version <live>`. Or pass `--force`. |
|
|
259
|
+
| `not a valid artifact slug or URL` | Not one of the accepted forms (see [Commands](#commands)). |
|
|
260
|
+
| CSS, JS or images gone after an update | Published with `--mode replace` (or with 0.1.x, where replace was the default) without passing them. Republish them. |
|
|
261
|
+
| `no index.html in DIR` | A directory publish needs `index.html` at its top level. For an artifact made from a type, `pull` it into the directory first. |
|
|
262
|
+
| `… is a symlink; copy the file in instead` | Directory publishes and pulls refuse symlinks. |
|
|
263
|
+
| `changed both locally and in the live version:` | `pull` conflict; nothing was written. Resolve as under [pull](#pull). |
|
|
264
|
+
| `… is not empty and was not pulled from or published to this artifact` | `pull` into an unrelated directory. Pick another, or pass `--force`. |
|
|
265
|
+
| `… exists and is not a directory` | `pull` target is a file. |
|
|
266
|
+
| `… is a symlink; refusing to write through it` | A symlink on the path of a file being written. Remove it. |
|
|
267
|
+
| `… is not a clean relative path`, `refusing to write unsafe path` | A published path with `..`, an empty segment, a backslash, `%` or a control character. The CLI won't read or write it. |
|
|
268
|
+
| `version … was published while reading …` | A publish landed mid-read. Run the command again. |
|
|
269
|
+
| `… doesn't match its published sha256` | The bytes read don't match the manifest. Run the command again. |
|
|
270
|
+
| `no file '…' in version …` | Not a published path. `claude-artifact read <slug>` lists them. |
|
|
271
|
+
| `this login can't read the artifact's files (the server issued no asset token …)` | No read access to the bytes, e.g. a public artifact from another organization. |
|
|
272
|
+
| `--path writes file bytes; it doesn't combine with --json or -o` | Drop `--json`/`-o`; use `--out-dir` to save. |
|
|
273
|
+
| `more than one --path needs --out-dir`, `--out-dir goes with --path` | As stated. |
|
|
274
|
+
| `an artifact made from a type can only be patched` | `--mode replace` on a typed directory. Leave `--mode` off. |
|
|
275
|
+
| `…/index.html belongs to the artifact's type and can't be published; remove it` | A typed directory holds an `index.html`. Delete it. |
|
|
276
|
+
| `429 … daily publish cap` | Plan limit. Resets at UTC midnight. |
|
|
277
|
+
|
|
278
|
+
## The protocol
|
|
279
|
+
|
|
280
|
+
Reverse-engineered from the Claude Code CLI v2.1.273 binary and checked against v2.1.287, where artifacts are called *frames*. API calls go to `api.anthropic.com`, even though the artifact is served from `claude.ai`; file bytes come from a per-artifact content host.
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
POST /api/frame/deploy/direct publish
|
|
284
|
+
POST /api/frame/deploy/prepare content-hash preflight (bodies over ~15 MB)
|
|
285
|
+
POST /api/frame/upload stage blobs the preflight asked for
|
|
286
|
+
GET /api/frame/{slug}?via=model_read boot: metadata, file manifest, assetToken
|
|
287
|
+
GET /api/frame/read/{slug} ownership / sharing status
|
|
288
|
+
GET /api/frame/frames?limit=N list
|
|
289
|
+
|
|
290
|
+
GET https://{slug}.frame.claudeusercontent.com/_f/{ver}/_src/{path}?__frame_t=<assetToken>
|
|
291
|
+
published source bytes (see Reading files)
|
|
292
|
+
GET https://{slug}.frame.claudeusercontent.com/_f/{ver}/{path}?__frame_t=<assetToken>
|
|
293
|
+
served copy
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Headers on `api.anthropic.com` calls:
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
Authorization: Bearer <claude.ai OAuth access token>
|
|
300
|
+
anthropic-beta: oauth-2025-04-20
|
|
301
|
+
Accept: application/json, application/vnd.ant.frame-refusal+json
|
|
302
|
+
X-Frame-CP: go
|
|
303
|
+
X-Frame-Surface: code
|
|
304
|
+
X-Frame-Platform: cli
|
|
305
|
+
X-Frame-Client-Version: 2.1.287
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Only `Authorization` and `anthropic-beta` are load-bearing.
|
|
309
|
+
|
|
310
|
+
### Deploy body
|
|
311
|
+
|
|
312
|
+
```jsonc
|
|
313
|
+
{
|
|
314
|
+
"slug": "…", // omit to create a new artifact
|
|
315
|
+
"title": "My Page",
|
|
316
|
+
"favicon": "📊",
|
|
317
|
+
"description": "…",
|
|
318
|
+
"mode": "replace", // or "patch" (requires baseVersion)
|
|
319
|
+
"baseVersion": "1789541006-9f63", // refused with 409 if a newer version is live
|
|
320
|
+
"force": true, // publish anyway
|
|
321
|
+
"manifest": {
|
|
322
|
+
"index.html": { "content": "<!doctype html>…", "contentType": "text/html" },
|
|
323
|
+
"logo.png": { "sha256": "<64 hex>", "contentType": "image/png" },
|
|
324
|
+
"old.js": null
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
A manifest value with `content` inlines the file; one with `sha256` references a blob already staged via `/upload`; `null` deletes that path (patch mode only).
|
|
330
|
+
|
|
331
|
+
**Wire encoding.** These content types go as raw UTF-8 strings; everything else is base64: `text/html`, `text/css`, `text/plain`, `text/markdown`, `text/csv`, `text/javascript`, `application/javascript`, `application/json`, `application/manifest+json`, `application/xml`, `text/xml`, `image/svg+xml`.
|
|
332
|
+
|
|
333
|
+
Response: `{"slug", "version", "read", "shared", "kind"}`. The page lives at `https://claude.ai/code/artifact/<slug>`.
|
|
334
|
+
|
|
335
|
+
**Modes and conflicts.** `replace` makes the manifest the whole artifact; `patch` overlays it onto `baseVersion`, keeping paths it doesn't name. Both modes honor `baseVersion`: if the live version is newer, the deploy is refused with
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
HTTP 409
|
|
339
|
+
{"conflict": true, "live": "<live version>", …}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
`patch` requires a `baseVersion`; when the caller has none, the CLI reads the live `ver` from `GET /api/frame/{slug}?via=model_read` and uses that, which cannot detect a concurrent publish. The CLI exits `3` on a 409.
|
|
343
|
+
|
|
344
|
+
### Large publishes
|
|
345
|
+
|
|
346
|
+
Over ~15 MB inline, the client switches to `prepare` → `upload` → `deploy`. `prepare` takes `{slug?, shas:[…]}` and answers `{slug, missing:[…]}`. The missing blobs go to `/upload` in batches of at most 15 MB, and the final deploy references them by `sha256`: the hex sha256 of the raw file bytes.
|
|
347
|
+
|
|
348
|
+
### Reading files
|
|
349
|
+
|
|
350
|
+
The boot, `GET /api/frame/{slug}?via=model_read`, returns `ver`, the `files` manifest (`path`, `size`, `contentType`, `sha256`) and a short-lived `assetToken`. Bytes come from the content host `https://{slug}.frame.claudeusercontent.com`:
|
|
351
|
+
|
|
352
|
+
- `GET /_f/{ver}/_src/{path}?__frame_t=<assetToken>` is the stored source, byte-identical to what was published. It works for an owner, writer, commenter or reader. Claude Code skips it only for an artifact shared in from outside the organization (boot `mode: "external"`) when `perm.role` isn't `writer`; the CLI does the same.
|
|
353
|
+
- `GET /_f/{ver}/{path}?__frame_t=<assetToken>` is the served copy, the fallback when `_src` doesn't answer 200. It is identical to the source for every file except the page, which is served at `/_f/{ver}/`. The served page has the frame runtime injected between `<!-- frame-runtime -->` and `<!-- /frame-runtime -->`, and may end with a `<script type="application/json" id="__frame_comments__">` trailer. Stripping both restores the source exactly.
|
|
354
|
+
- Send no `Authorization` header to the content host; the asset token in the query is the only credential. Send a non-default `User-Agent`: the CDN rejects Python-urllib's default with Cloudflare `error code: 1010` (HTTP 403).
|
|
355
|
+
- A missing file is `404`. A missing or expired token is `403`; the CLI boots again once for a fresh token, and fails if a new version went live in between. Redirects aren't followed.
|
|
356
|
+
- Path segments are percent-encoded. The CLI refuses paths with `..`, empty segments, backslashes, `%` or control characters.
|
|
357
|
+
- The CLI verifies every file against the manifest's `sha256`. Manifests of older artifacts lack `sha256`; `status` fetches those files to compare.
|
|
358
|
+
- Manifest entries with `src: {slug, ver}` belong to the Artifact type the artifact was made from, `index.html` included. They aren't the artifact's own files: `pull` and `status` skip them, and a typed publish patches around them.
|
|
359
|
+
|
|
360
|
+
The `assetToken` is redacted from every output and never written to disk.
|
|
361
|
+
|
|
362
|
+
### Artifact URLs
|
|
363
|
+
|
|
364
|
+
`https://claude.ai/code/artifact/<uuid>` carries the slug, a UUID. `https://claude.ai/artifact/<short id>` carries the same UUID as base58 (Bitcoin alphabet). The CLI decodes either, and accepts a bare UUID or short id.
|
|
365
|
+
|
|
366
|
+
### Not supported
|
|
367
|
+
|
|
368
|
+
- **Delete and pin.** Both go through a relay-only route that isn't reachable on the direct path. Use `/artifacts` in Claude Code, or claude.ai.
|
|
369
|
+
- **Capabilities.** Runtime capability declarations (`capabilities`, `contract`) are accepted by the API but not exposed as flags.
|
|
370
|
+
- **Comments, watching, thumbnails.**
|
|
371
|
+
|
|
372
|
+
## Project Structure
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
.github/
|
|
376
|
+
└── workflows/
|
|
377
|
+
└── publish.yml lint, tests, auto-version, PyPI publish, GitHub release
|
|
378
|
+
assets/
|
|
379
|
+
└── header.png
|
|
380
|
+
skills/
|
|
381
|
+
└── claude-artifact-cli/
|
|
382
|
+
└── SKILL.md agent skill
|
|
383
|
+
src/
|
|
384
|
+
└── claude_artifact_cli/
|
|
385
|
+
├── __init__.py version
|
|
386
|
+
├── __main__.py python -m claude_artifact_cli
|
|
387
|
+
├── api.py frame API client
|
|
388
|
+
├── auth.py token lookup
|
|
389
|
+
└── cli.py argparse entry point
|
|
390
|
+
tests/ unit tests (offline; transport mocked)
|
|
391
|
+
AGENTS.md
|
|
392
|
+
LICENSE
|
|
393
|
+
README.md
|
|
394
|
+
pyproject.toml
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## Documentation
|
|
398
|
+
|
|
399
|
+
| Resource | Description |
|
|
400
|
+
|----------|-------------|
|
|
401
|
+
| [SKILL.md](skills/claude-artifact-cli/SKILL.md) | Agent skill: when to use the CLI and how |
|
|
402
|
+
| [AGENTS.md](AGENTS.md) | Constraints and commands for coding agents working in this repo |
|
|
403
|
+
| [publish.yml](.github/workflows/publish.yml) | CI and release pipeline |
|
|
404
|
+
| [The protocol](#the-protocol) | Endpoints, headers, deploy body and file reads |
|
|
405
|
+
|
|
406
|
+
## Contributing
|
|
407
|
+
|
|
408
|
+
Issues and pull requests are welcome. Keep the package dependency-free and run `uvx ruff check .` and `PYTHONPATH=src python -m unittest discover -s tests -v` before pushing. Every merge to `main` that touches `src/` or `pyproject.toml` is released to PyPI automatically with a patch bump.
|
|
409
|
+
|
|
410
|
+
<a href="https://github.com/nikships/claude-artifact-cli/graphs/contributors">
|
|
411
|
+
<img src="https://contrib.rocks/image?repo=nikships/claude-artifact-cli" />
|
|
412
|
+
</a>
|
|
413
|
+
|
|
414
|
+
## License
|
|
415
|
+
|
|
416
|
+
[Apache-2.0](LICENSE)
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
<div align="center">
|
|
421
|
+
|
|
422
|
+
[](https://star-history.com/#nikships/claude-artifact-cli&Date)
|
|
423
|
+
|
|
424
|
+
</div>
|