·5 min read
Stripping claude -p down, then planning with Haiku first
A background job that talks to a model should cost close to nothing when it has nothing to say. DailyBrief's did not. Before a single word of my digest reached the model, every headless call was already paying for a full interactive coding session: the CLI's own system prompt, every tool schema, every MCP server and skill from my personal config, my CLAUDE.md and my hooks. A comment I left in the code puts it at about 30k tokens per turn.
Worse, my setup leaked into the output. A terse-style hook of mine started shaping the prose of the morning briefing. On Oct 26 I fixed both problems, and then went after the one run that cost the most.
- Project
- DailyBrief
- Date
- Oct 2026
- Stack
- PowerShell 5.1, Claude Code CLI
- Commit
- 360d660, 1dc9e1a
What broke
Nothing crashed. The bill and the prose were the problem. The old calls were claude -p with a prompt on stdin, which is a full Claude Code session. For a pipeline that makes many small calls a day (checks, briefs, questions, feature ideas), the fixed overhead was large next to a small digest. And because a session loads user settings, the hooks I had configured for my own terminal ran inside an unattended background job and bent its output.
The execute run was the expensive one. It is the only run with Bash and Edit, and a comment in the old script says why --max-turns was the real cost ceiling: each turn can read files and run commands, so it costs much more than a check.
What the code showed
The header of the new core/claude-run.ps1 lists what a plain call carries and the flag that removes each part. The central block of the argument list is short:
'-p',
'--model', $Model,
'--setting-sources', '""',
'--strict-mcp-config', '--mcp-config', (Get-EmptyMcpConfig),
'--disable-slash-commands',
'--no-session-persistence',
'--system-prompt', (ConvertTo-NativeArg $System),
'--max-turns', [string]$MaxTurns,
'--output-format', 'json'An empty --setting-sources means no user or project settings, so no hooks and no plugins. A strict MCP config pointing at an empty file means no servers. --system-prompt replaces the CLI's own. Tools are off with --tools "" unless the caller names some, and --json-schema makes the CLI validate structured output. The header notes one deliberate omission: --bare would have been leaner still, but it only accepts an API key and would break subscription auth.
Plain claude -p
Stripped session
Two PowerShell 5.1 problems came with it. Native arguments are passed without escaping embedded double quotes, so a helper does it before the schema reaches the CLI. And when the launcher is a .cmd, PowerShell hands the arguments through cmd.exe, which re-parses the escaped quotes in --json-schema. Get-ClaudeExe goes around it by resolving the real claude.exe behind the launcher.
The fix
Commit 360d660 (Oct 2026) added the runner, and the same day the briefs, questions, ideas and per-project checks moved onto it. Then 1dc9e1a (Oct 2026) rebuilt the execute run, using the header comment to say what changed:
# 1. plan - haiku, Read/Glob/Grep only: a concrete file-level plan
# 2. implement - sonnet, edit tools, the plan inlined, 25 turns (was 40,
# most of which went to re-exploring the project)The old run spent most of its 40 turns finding files. So the plan call, on the cheaper model, with read-only tools and a 12 turn cap, returns a structured list of files, steps and risks. The implement call then gets that plan inlined in its prompt, along with Bash and Edit and a schema for its report.
- 01
Plan with Haiku
Read, Glob, Grep only, up to 12 turns, structured plan
- 02
Inline the plan
files, steps and risks go into the implement prompt
- 03
Implement with Sonnet
Bash and Edit, 25 turns instead of 40
- 04
Guard
script notes a branch switch or a new commit and reports it
Splitting the work created three small problems that I had to handle in the same commit. The usage page read token counts from the last result line in the log, so two calls would have been billed as one. A Write-UsageTotal function sums both calls into a single line. If the plan call returns nothing usable, the run does not fail: it logs it and tells the implement step to find the files itself. And since the lean runner loads no settings, there is no permission allowlist to lean on, so the script passes --dangerously-skip-permissions with exactly the tools named, and its working directory is the project folder. Afterwards it compares HEAD and the branch before and after. If the model made a commit anyway, the script reports it and never reverts it.
What I would do differently
I wrote the numbers down only as code comments, "about 1.2k instead of about 30k" and "25 turns, was 40". I believe them, but a comment is not a measurement. I would log the input tokens of the first turn of every call type and show them on the usage page, so the saving is a chart I can read and not a sentence I wrote once.
I would also split the execute run from the start. The signal was in the old comment already: the turns were the cost, and the turns went to exploration. A cheap read-only pass is the obvious shape for exploration, and I paid for forty Sonnet turns before I drew it that way.
Where this fits
This is the cost half of DailyBrief's design: scripts gather, a small model call decides, a script applies the result. The full DailyBrief case study shows the digest, the lockfile that lets parallel runs share the board, and why code execution is the one deliberate exception.
See the pipeline this runner serves, and the guard rails around the one run that edits code.
Read the full case study#claude-cli#powershell#ai#cost
Keep reading
Have a project in mind?