·5 min read
A publish step that never worked, because headless Claude has no Artifact tool
The "publish my brief to the web" feature in DailyBrief never worked, and nothing told me. The script asked a headless Claude CLI run to call the Artifact tool, and that tool does not exist in a headless session. The rewrite taught me something about how little I want a model to do when it only needs to carry a file.
- Project
- DailyBrief
- Date
- Oct 2026
- Stack
- PowerShell, Claude CLI, Claude Docs connector
- Commit
- 00388f5
The first version
DailyBrief writes a morning plan as JSON, and an opt-in script publishes a web copy of it. The first version of that script built an HTML page from briefs/<date>.json and then started the CLI with a prompt of one instruction: publish this file with the Artifact tool, to this URL, and stop. It limited the run to that tool and to 3 turns, using the cheapest model.
The comment I wrote in the rewrite states the cause plainly: the Artifact tool does not exist in a headless CLI session, which is why publishing never worked before. The script ran, the model replied, and nothing was published. Because the step runs detached after the brief is already readable, nobody was waiting on it, so nobody noticed.
Moving to a Claude Doc
The replacement target is one private Claude Doc, replaced each morning, reached through the claude.ai Claude Docs connector. A headless run can use connector tools if it is started with them allowed, so the shape stayed the same: a cheap run that carries a document somewhere. What changed is how much of the work the model gets to do.
My rule for the rewrite was that the model authors nothing. The system prompt for the run says it copies a prepared document into a doc exactly as instructed and never writes or changes the document text.
The script does the serializing
A small model re-escaping a page of markdown into a JSON argument is the place text gets mangled: quotes, backslashes, newlines. So the script does it:
$contentJson = ConvertTo-Json $md -Compress
$createArgs = (@{ kind = 'project'; create = @{ name = 'Daily Brief'; doc = @{ markdown = $md } } } |
ConvertTo-Json -Depth 6 -Compress)The prompt file then holds two procedures, create and update, in one file. The script extracts only the section for the mode it needs and fills in placeholders such as {{CREATE_CONTAINER}} and {{CONTENT_JSON}}. The prompt says to copy every argument character for character.
The markdown itself is built deterministically from the brief JSON. One detail came from reading the connector's syntax: the doc format has chip tokens that begin with <?claude, and text of mine containing that would be resolved as a chip that was never declared. The line helper in the script flattens newlines and rewrites that sequence:
function Line([string]$s) {
return (($s + '') -replace '\s*[
]+\s*', ' ' -replace '<\?claude', '<?').Trim()
}Updating without leaving half a document
The update procedure replaces the whole body. The prompt walks the model through reading the outline, noting the revision and the hash of each top-level block, then sending two ops in a fixed order: delete every block except the first, then replace the first with the new markdown. Deleting first and replacing a single block means no old list or table survives half-replaced. If the connector refuses with guard_mismatch or find_none, the model re-reads once and resends with fresh ids.
Distrust what comes back
The first run has to remember the new doc, or tomorrow would create a second one. The script asks the model for a small structured result, with published, doc, body and notices, and writes the doc link back into publish.json, keeping every other key the user wrote.
The part I added after watching a failure is the validation of body. A comment in the code says it: the model once wrote its whole explanation into body, which then broke every later update. Now only a value matching an id pattern is stored:
if ($newBody -notmatch '^[A-Za-z0-9][A-Za-z0-9._-]{3,63}$') {
if ($newBody) { Add-Content $log '[warn] model returned a body id that is not an id - ignored' }
$newBody = ''
}An empty body id is harmless, because the update procedure has a step that reads it from the doc when it is missing.
Notices from the update, such as a dropped_with note about the old blocks deleted on purpose, are logged as information and not treated as failures.
What I would carry over
When a model is the transport and not the author, take its freedom away in three places. Build the content in code. Serialize arguments in code. Validate what comes back in code before it touches persistent config. Each of these came from a way the previous design could fail without telling me.
I did not benchmark this against the old version, since the old version published nothing. What I can say is that the failure that mattered, a feature that silently did nothing, is now a logged warning when the model reports published as false or the run fails.
#claude-cli#powershell#automation#llm
Keep reading
Have a project in mind?