Use when handing the user a report or artifact path and a clickable localhost or tailnet link should be provided, or when the user asks how to configure, inspect, stop, or restart the server.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Artifact Server?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/home-dev-lab-artifact-server)
---
name: artifact-server
user-invocable: true
description: >-
Use when handing the user a report or artifact path and a clickable localhost or tailnet link
should be provided, or when the user asks how to configure, inspect, stop, or restart the server.
argument-hint: "[absolute-file-path]"
---
# Artifact server
The artifact server turns registered local files into clickable links. A persistent monitor for
each Claude session starts or attaches to one per-user server, keeps that session registered even
while idle, and restarts a server that stops while the registration is live. It is enabled by
default; disable the `artifact_server` plugin option in Claude Code settings, or use the
`WT_ARTIFACT_SERVER=0` environment fallback when that option is absent.
A one-line SessionStart notice gives the link command only after probing a live server; otherwise it
reports status unknown without suggesting a link that may be dead.
The user-facing plugin options are `artifact_server`, `artifact_server_roots`,
`artifact_server_port`, `artifact_server_idle_grace_s`, and `artifact_server_deny`. A plugin option
wins over its corresponding `WT_ARTIFACT_SERVER*` environment fallback; an absent option and env
value use the defaults below. Option lists are comma- or newline-separated. The legacy roots env
fallback remains platform-path-delimited.
## Roots and links
When `artifact_server_roots` and `WT_ARTIFACT_SERVER_ROOTS` are unset, the monitor registers the current project's existing
`.claude/reports` and `.claude/worktrees` directories. The project is the session cwd's Git root, or
the cwd when it is not in a repository. Their mounts are `<project>-reports` and
`<project>-worktrees`; projects with the same basename receive stable short hash suffixes. The home
directory is never the default.
Configure several roots with the platform's path delimiter (`:` on POSIX, `;` on Windows). An entry
is `name=path`, or a bare path named from its basename. Names must be unique:
```bash
export WT_ARTIFACT_SERVER_ROOTS="reports=/work/project/.claude/reports:/work/shared/artifacts"
```
Files mount at `/<name>/...`. Different sessions can register different roots; the server serves
their deduplicated union. Each monitor owns its registration and removes it when that session exits.
There is no HTTP registration or other network control endpoint.
Never hand the user a file path: give the complete URL from the helper. The remote URL works from
any tailnet device; `localhost` only on the server machine. To hand a link over, run `url` with
`--remote`. Only when it exits 3 and its stderr says the server has no remote URL, run it without
`--remote` and hand over what it prints; when stderr says it printed the local URL, say the link
works only on this machine. The helper picks the longest matching root and exits 3 outside all
roots:
```bash
node "${CLAUDE_PLUGIN_ROOT}/bin/wt-artifact-server.mjs" url "/absolute/path/to/report.md" --remote
node "${CLAUDE_PLUGIN_ROOT}/bin/wt-artifact-server.mjs" url "/absolute/path/to/report.md"
```
On exit 3, stderr names the reason: the one the server recorded when there is no remote URL, or the
path problem. Use `--local` to force localhost for tools on this host (Playwright, curl); it cannot
be combined with `--remote`. Under WSL with Tailscale on Windows, only a Tailscale
Serve route reaches the server, so a missing route means no tailnet URL, and the reason gives the
command that creates it.
Add `--check` to fetch the printed URL. Read stdout for the URL alone and stderr for
`check: reachable`, `check: unreachable` or `check: unverified` with its reason; the exit code is 0,
4 or 5. When the printed URL is remote, the fetch runs on the host where Tailscale runs (through
PowerShell when that is Windows), not from a peer; with `--local` or a local fallback, it targets
the local URL. Restart the server after creating a Serve route: detection runs at startup only. In
a normal shell, replace `${CLAUDE_PLUGIN_ROOT}` with the installed plugin root.
The deliverable is the single file's complete URL, not the root index. Index browsing is only a
local convenience and does not survive every path-mounted proxy: in particular, a trailing slash on
a Tailscale Serve mount root such as `/artifacts/` routes to the upstream root handler rather than
this server. Never construct or hand over such a mount-root link. Root-relative links in rendered
Markdown, such as `[other](/report.md)`, also target the domain root under a path mount because the
server cannot infer the proxy-owned prefix; artifact authors must use document-relative links.
## Adding diagrams
Use `interactive` for a trusted HTML report you authored that needs both page scripts and
browser page/annotation tools. Put `<!-- wt-artifact-server: interactive -->` on its first line,
entirely within the first 256 bytes. For anything you did not author, keep raw mode. Interactive
mode has no sandbox: it permits inline and same-origin scripts, including **any file served by
the server**, while blocking connections, forms, objects, base changes, and framing.
This copy-ready command writes an HTML example with one inline Mermaid bundle, one initializer,
and a diagram. Set `CLAUDE_PLUGIN_ROOT` to the installed plugin directory in a normal shell.
The pinned bundle and its MIT license live under `skills/artifact-server/assets/mermaid/`;
if that directory contains placeholders, follow its `VERSION` instructions first.
```bash
node --input-type=module <<'NODE'
import { readFileSync, writeFileSync } from 'node:fs'
import path from 'node:path'
const bundle = readFileSync(path.join(process.env.CLAUDE_PLUGIN_ROOT,
'skills/artifact-server/assets/mermaid/mermaid.min.js'), 'utf8')
writeFileSync('diagram.html', `<!-- wt-artifact-server: interactive -->
<!doctype html><html><head><meta charset="utf-8"><title>Report diagram</title></head><body>
<pre class="mermaid">flowchart LR
Draft --> Review --> Published
</pre>
<script>${bundle.replace(/<\/script/gi, '<\\/script')}</script>
<script>mermaid.initialize({ startOnLoad: true, theme: 'neutral', securityLevel: 'strict' });</script>
</body></html>`)
NODE
```
For Markdown, use an info string of exactly `mermaid`:
````markdown
# Report diagram
The review flow:
```mermaid
flowchart LR
Draft --> Review --> Published
```
````
The server escapes the diagram source, loads its own pinned Mermaid build (never a CDN), and
uses strict Mermaid security with the neutral theme. Only Markdown with a Mermaid fence enables
scripts: the policy admits same-origin scripts (`'self'`) and the fixed initializer's hash, and
the page carries no other script, because rendered Markdown escapes HTML. The script URL is
relative, so it works directly and behind a path-mounted proxy such as `tailscale serve`
under `/artifacts`. The path segment `__wt-artifact-server` belongs to the server at any depth:
a root file or folder of that name is never served. A Mermaid example quoted inside a longer or
`~~~` fence stays text. Other Markdown remains script-free.
`'self'` spans every registered root on the origin: an interactive HTML page can load a script
from another root. Mark a page interactive only when you trust every root served beside it.
## Lifecycle
The default port is stable for the OS user in the 48000-48999 range. Set the
`artifact_server_port` option, or its `WT_ARTIFACT_SERVER_PORT` fallback, to override the first candidate. Discovery probes every candidate for the
service identity and current OS uid before choosing a free port. A foreign listener causes fallback
through up to 20 ports, and concurrent starts resolve through kernel bind contention.
The server uses an owner-only mode-0700 state directory under:
`$XDG_STATE_HOME/wt-artifact-server` when set, otherwise `~/.local/state/wt-artifact-server` on
Linux, `~/Library/Application Support/wt-artifact-server` on macOS, or
`%LOCALAPPDATA%\wt-artifact-server` on Windows. It refuses a directory owned by another uid or
writable by group/others. Each monitor atomically writes one mode-0600 `registrations/*.json` file
containing its PID, roots, deny policy, and start time. `server.json` is also mode 0600 and records
the real port, local and remote URLs, pinned roots, PID, version, and start time. The server runs
with this state directory as its working directory, so it never holds the project or worktree of the
session that started it (Windows cannot delete a live process's working directory).
The server checks registration PIDs with `process.kill(pid, 0)` every two seconds. An idle live
session keeps it alive. Clean removal of the last registration stops it immediately; a dead
monitor's registration is ignored and removed after a 10-minute grace, configurable with
`artifact_server_idle_grace_s` or its `WT_ARTIFACT_SERVER_IDLE_GRACE_S` fallback. A newer plugin never replaces an older running server
automatically; its monitor prints one restart notice.
Human-only operator commands are:
```bash
node "${CLAUDE_PLUGIN_ROOT}/bin/wt-artifact-server.mjs" status
node "${CLAUDE_PLUGIN_ROOT}/bin/wt-artifact-server.mjs" stop
node "${CLAUDE_PLUGIN_ROOT}/bin/wt-artifact-server.mjs" restart
```
`stop` and `restart` refuse while sessions are registered, and fail closed if the uid, count, or
process identity cannot be verified. Add `--force` to override the registration refusal. On Linux,
the command line must contain `wt-artifact-server.mjs`, listener launch evidence must match discovery,
and the boot ID and process start ticks must match the recorded birth identity immediately before
signalling. Missing discovery is unknown, and restart refuses to spawn. Unavailable birth identity
(currently including macOS and Windows) refuses even with `--force`; older servers without a recorded
birth identity require manual shutdown. Concurrent stop/restart commands share a `control.d` claim;
after a controller crashes, confirm no control command remains and remove that empty directory before
retrying. These controls are CLI-only and are not agent tools.
## Tailscale
The server always binds `127.0.0.1`. If `tailscale ip -4` detects a local Tailscale address, it also
binds that address and accepts the machine's MagicDNS name from `tailscale status --json`. On WSL,
if `tailscale` is unavailable, detection asks PowerShell to resolve `tailscale.exe` and converts that
returned path with `wslpath`; no Windows install directory is assumed. Any resolved command ending in
`.exe` counts as Windows Tailscale outside Windows, including a configured binary; a wrapper script
that delegates to Windows Tailscale cannot be recognised, so configure the `.exe` path itself. Discovery distinguishes a
successful lookup with no tailnet IP from an unavailable lookup, while local serving remains usable.
The server never configures Tailscale Serve.
Detection is a precondition for proxied access, not an optional convenience. Every Serve request
presents the MagicDNS Host, and that name enters the server's Host allow-list only when detection
finds it. A `421 Misdirected Request` therefore means the presented Host was not detected and admitted;
inspect Tailscale detection and server status before debugging the proxy, DNS, or firewall.
The direct remote URL is `http://<tailscale-ip>:<port>`. Function Hooks `Link` requires HTTPS; an
operator can configure the tailnet-only proxy manually:
```bash
tailscale serve --bg --https=443 http://127.0.0.1:<port>
```
When an exact proxy mapping is detected, the printed remote URL keeps its HTTPS hostname,
non-default port, and mount path. Ambiguous tables or mappings to another backend fall back to the direct IP URL rather
than composing a plausible but wrong HTTPS link. Never use `tailscale funnel`, which would expose
the server publicly.
There is no password, token, cookie, or authentication beyond Tailscale membership. Every device on
the tailnet that can reach the server can read every allowed file under every registered root. The
per-user derived port separates local users' discovery, but it does not protect files readable over
the tailnet.
## Serving security
- Only `GET` and `HEAD` are accepted. Host is restricted to localhost, loopback, the detected
Tailscale IP, and detected MagicDNS name. No CORS permission is sent.
- Every path is checked lexically and by realpath. Traversal and symlinks escaping a root receive
403. Roots are canonicalized only when first observed and pinned; replacing a root with a symlink
makes it unavailable until a new session registers it.
- The default case-insensitive deny list blocks `.git`, `.env*`, `*.pem`, `*.key`, `id_rsa*`,
`id_ed25519*`, `credentials*`, and `*.secret*`. `artifact_server_deny`, or its
`WT_ARTIFACT_SERVER_DENY` fallback, adds patterns. Only the test/internal env-only knob
`WT_ARTIFACT_SERVER_ALLOW_UNSAFE_DENYLIST=1` replaces the defaults. The other test-only knobs,
`WT_ARTIFACT_SERVER_REGISTRATION_POLL_MS` and `WT_ARTIFACT_SERVER_TAILSCALE_BINARY` (a pinned
`tailscale` executable for hermetic probes; PATH stays the default), are also env-only. Policy is per registration and
is checked against canonical path segments plus the root basename, so benign symlink aliases do
not bypass it.
- Markdown raw HTML is escaped. `.txt`, `.log`, and `.json` are escaped. HTML is unchanged and
sandboxed without scripts by default. An HTML file whose first non-whitespace content is the
visible `<!-- wt-artifact-server: rich -->` marker opts into inline scripts, still without
same-origin authority, network connections, or external images. The marker travels inside the
file; an extension can be lost on rename, while a sibling policy file can drift away. Rich mode
narrows blast radius but does not make the artifact trusted: opening it still runs unreviewed code
the owner chose to open. Raw SVG and unknown content retain the no-script sandbox; generated
Markdown without Mermaid fences and indexes use a strict no-script CSP.
- For HTML documents the owner reviews and annotates in Orca, put
`<!-- wt-artifact-server: annotatable -->` before any non-whitespace content. Like the rich
marker, it is case-insensitive and must fit entirely within the first 256 bytes. Annotatable
mode keeps the server's real origin (no CSP sandbox), so browser annotation tools can access
the document, but it never runs page scripts: `script-src 'none'` blocks them. Network
connections, forms, base-URL changes, and framing are blocked; inline styles and same-origin
or data images are allowed. For script-free expand/collapse interactivity, use native
`<details><summary>More</summary>...</details>` elements. This mode does not enable rich scripts.
- Health reports service version and OS uid. UID and Linux command-line checks prevent cross-user
attachment and accidental stale-PID signalling; they are not cryptographic attestation against a
malicious process running as the same user. There is no rate limit or file-size limit.