Day 7, 30 minutes · advanced
Why it matters
The job is done when the client runs it without you, not when it works on your laptop. Until now every run of orderdesk started with you at the keyboard. You typed the prompt, you approved the steps, you read the result. Today Tomas, Kettlebrook's own engineer, takes the repository over. He needs a run that starts from a script, does only what it is allowed to do, and tells him what it cost.
That means three things to settle before you leave. Where the run lives and what it may touch. What one run costs and where a budget stops it. And a runbook short enough that someone else can follow it cold, without calling you.
At the end of this lesson the day 6 eval (the fixed set of test cases that scores every draft) runs with nobody at the keyboard and writes its result to a file. You have noted the cost of one run, set a budget, written a one-page runbook, and restarted the run from that runbook in a fresh terminal.
Two ways to run without a chat window
Headless is the everyday word for an agent started from a script or a pipeline, with no chat window. In this course we call it an unattended run. You give the tool one prompt and a set of permissions. It works through the agent loop on its own and exits with a code your script can check.
The second route is an agent SDK: the same loop as a library inside the client's own software. The client's code calls the agent, passes it the task and the permissions, and reads the result, much as it would call any other library. It fits when the agent is one step inside a larger product. For one fixed job on a schedule, a script is easier to read and to hand over, so this lesson uses a script.
Where it runs
Pick the place before you write the command:
- a pipeline job, when the run belongs to a change in the repository
- a scheduled job, when it runs at a fixed time
- a small service, when the client's software starts it
Wherever it runs, apply your security list from day 5: least privilege, no secrets in logs, a person approves every write, and a record of every action. Credentials come from the environment or the job's secret store, never from the script or the repository.
Keep the run narrow for one more reason. It reads the drafts in evals/drafts/, and text an agent reads can try to give it orders (prompt injection). A run that may write only one file can do little harm when that happens.
The steps
- Write the script. In
orderdesk/, createrun_eval.sh(on Windows,run_eval.ps1). It starts your agent with this one task:
Run python evals/run.py. Write the pass rate and the ids of the failing cases to evals/last_run.md. Change no other file.
This task is small on purpose. evals/run.py calls no model, so a plain scheduled job could run it without an agent. We use it because it is a safe way to practise what every unattended run needs: narrow permissions, a result you can check and a known cost. On a real job the run you hand over does the model work itself. It drafts the replies, through the client's own model call or through an agent started the way you start this one, and this eval is the check that runs after it.
- Limit the run to three things: run that one command, read files in the repository, write
evals/last_run.md. Get as close to that as your tool's flags allow. Where the tool only offers a limit for the whole workspace, write that down. It is a finding for the client, not a mistake of yours. - Run it with nobody at the keyboard. Start the script and do not touch the terminal until it exits. A run that stops to wait for an answer is not unattended yet.
- Check the evidence: the exit code, the content of
evals/last_run.md, andgit status. The agent should have changed that one file and nothing else, apart from the output file your script itself writes. - Note the cost of one run, set a budget, and write
RUNBOOK.md. The sections below say how. - Test the runbook cold.
Pick your tool below for the exact commands.
What one run costs
Four things drive the cost: the text that goes in (instructions, files read, command output), the text that comes out, how often it runs, and which model does the work. A run every weekday is about twenty runs a month, so measure one run and multiply.
A token is a small piece of text. Models count and bill their input and output in tokens. The tools report cost in different units. Some give an estimated money figure, some give token counts, some give credits on an account page, and some give nothing per run. Write down what yours reports and where you read it. Do not turn tokens into money with a rate you guessed. Take the rate from the client's own price list or contract.
Budget and alert
Set two limits where your tool has them. A cap per run, so one run that loops cannot run away. A limit on the account, so a schedule that runs too often stops. Add an alert if the tool or the billing page offers one. Where there is no alert, say so in the runbook and name who checks the usage page, and how often.
The runbook
Keep RUNBOOK.md to one page, with these headings:
Start
Stop
Update
What a failure looks like
Acceptance test (the day 6 eval)
Cost of one run and the budget
Owner (Tomas)
- Start: the exact command, and the environment variables it needs, by name only.
- Stop: how to cancel a run that is going, and how to switch off the schedule.
- Update: how to update the tool, and that the eval runs again after every update.
- What a failure looks like: a non-zero exit code, a missing or old
evals/last_run.md, a run that waits for an answer, a pass rate lower than the last one. - Acceptance test: the day 6 eval. A change to the prompt or the tool is accepted when the pass rate does not drop.
- Cost of one run and the budget: your figure, its unit, where it came from, and the limits you set.
- Owner: Tomas, by name. A runbook without an owner belongs to nobody.
If the page is not enough, the solution is too complicated to hand over yet.
Test it cold
Open a fresh terminal with no shell history, or ask a colleague. Follow only what the runbook says and restart the run. Every time you reach for something that is not written down, add it to the runbook and start again. On a real job, also do the exit test: a client engineer runs it, breaks it and fixes it while you only watch.
In a chat tool
The four chat products have a scheduled feature, though not every one is offered in the Netherlands, and none was shown to run a script in a repository. So in a chat product you build the reporting end. Schedule this prompt with the latest result pasted under it, note what the schedule may and may not do, and use the coding tool tab of the same vendor for the run itself:
Every weekday at 8:00, read the eval result I saved and write a three-line summary: the pass rate, the failing cases, what changed since the last run. Do not send anything.
How the tools compare
- Claude Code: non-interactive mode, with a permission mode, allow rules per command and per file, a turn cap and a cost cap. The JSON output carries an estimated cost.
- OpenAI Codex: non-interactive mode (
codex exec) with a sandbox for the whole workspace. Token counts in the JSON events, no per-run budget flag. - Gemini CLI: headless mode, with token counts in the JSON stats. No money figure and no spending cap found.
- Cursor: print mode of the Cursor CLI, with a project permission file. No cost field in the output, usage on the dashboard.
- GitHub Copilot CLI: programmatic mode with allow rules and a soft cap in AI credits. Usage on the billing page.
Deeper dive
Today's actions
Ticks are not saved without an accountDo it in your tool
Claude
- Paste the prompt below in a Claude conversation and paste the text of your latest
evals/last_run.md(orevals/scores.mdfrom day 6) under its last line. Answer Claude's questions, review the proposed task name, schedule and instructions, and click Schedule.Every weekday at 8:00, read the eval result I saved and write a three-line summary: the pass rate, the failing cases, what changed since the last run. Do not send anything. The eval result I saved (pasted from evals/last_run.md or evals/scores.md): - Click Scheduled in the left sidebar instead if your screen still shows separate Chat and Cowork options (Cowork is Claude for agentic work beyond coding). Then click New task, choose Set up manually, fill in the name, prompt, approval mode and frequency on weekdays, and click Save.
- Click Scheduled in the left sidebar and run the task once on demand. Check that the summary names the pass rate and the failing cases from the text you pasted. When a new result lands, edit the task's instructions there and paste the new text.
- Write down what the task may use: your connected tools, skills, plugins, web research and saved files. Switch off connectors it does not need, and set any connector tool that can write to Always ask.
- Use the Claude Code tab of this lesson for the run itself (the eval script, the result file and a cost cap). There
claude -pruns Claude Code with no chat window and exits with code 0 on success.
Note: We found no page that shows a chat scheduled task running a repository's eval script, and no steps for saving a file to your Claude account, so the result goes in the prompt. A tool set to Always ask can leave a run waiting for your answer, or the run finishes without it. Scheduled tasks run remotely, also while your computer sleeps. Chat usage shows under Settings > Usage. We found no per-run cost report or budget alert in chat. An admin controls access with the Cowork admin toggle.
Paid planScheduled tasks are on all paid plans (Pro, Max, Ultra, Team and Enterprise), not on Free. On web and mobile, Team is in beta and Enterprise needs an owner to switch it on.
ChatGPT
- Open Scheduled in the sidebar of ChatGPT on the web and select New task. If Scheduled does not appear in the desktop app, use ChatGPT on the web.
- Enter the prompt below and paste the text of your latest
evals/last_run.md(orevals/scores.mdfrom day 6) under its last line. A task made in a project cannot read that project's files, so the result goes into the task itself.Every weekday at 8:00, read the eval result I saved and write a three-line summary: the pass rate, the failing cases, what changed since the last run. Do not send anything. The eval result I saved (pasted from evals/last_run.md or evals/scores.md): - Choose when it runs: every weekday at 8:00. On Free you get a time window such as morning instead of an exact time, and at most one recurring run a day.
- Go to Settings > Notifications and select Push, Email, or both, so you see each run.
- Write down what it may do: read, summarise and use connected apps. A step that sends a message or changes external data may need approval, and then the task pauses. It cannot work in a folder on your computer.
- Use the OpenAI Codex tab of this lesson for the run itself. There
codex execruns Codex from a script, in a read-only sandbox unless you allow more. - Edit the task under Scheduled when a new result lands, and paste the new text. Pause or delete the task there when you are done testing.
Note: OpenAI's plan table says scheduled tasks are not on Free, while the help article gives Free users one recurring task at most once a day. Check your own plan before you count on it. Active tasks: 3 on Free and Go, 5 on Plus. A run uses your plan's usage allowance or workspace credits, even when it posts no update. We found no per-run cost figure.
Gemini
- Go to gemini.google.com on a computer and sign in with a personal Google account, or a work or school account on a qualifying Google Workspace edition. Your Gemini history must be on.
- Paste the prompt below, paste the text of your latest
evals/last_run.md(orevals/scores.mdfrom day 6) under its last line, and click Submit. The prompt itself says when and how often it runs.Every weekday at 8:00, read the eval result I saved and write a three-line summary: the pass rate, the failing cases, what changed since the last run. Do not send anything. The eval result I saved (pasted from evals/last_run.md or evals/scores.md): - Open Scheduled in the sidebar and check that the schedule is listed. You manage it there.
- Write down what it may do: Gemini prepares the content in advance, so fast-changing data is not the latest, and you can have up to 10 active schedules. We found no page that shows a schedule running a script.
- Use the Gemini CLI tab of this lesson for the run itself if you have a company licence or a paid API key. Without one, this tab ends at the schedule: the notes say where Google sends individuals.
Note: For work inside a repository Google now sends individuals to Antigravity CLI, which has a headless mode (agy -p). This course has no checked steps for it. The Gemini CLI tab of this lesson only works with a company licence or a paid API key. Tasks and their schedules are not offered in the EEA. The chat schedules page names no country, and no page confirms the Netherlands. We found no per-run cost report in the Gemini app.
Paid planNot confirmed in the Netherlands. Check that Scheduled shows in your sidebar before you pay for a plan. Google's feature table ticks Scheduled actions for Google AI Plus, Pro and Ultra.
Microsoft Copilot
- Go to Copilot Chat on the web or in the desktop app and sign in with your work or school Microsoft 365 account. Scheduled tasks are not yet in Teams, Outlook or mobile.
- Send the prompt below with the text of your latest
evals/last_run.md(orevals/scores.mdfrom day 6) pasted under its last line.Every weekday at 8:00, read the eval result I saved and write a three-line summary: the pass rate, the failing cases, what changed since the last run. Do not send anything. The eval result I saved (pasted from evals/last_run.md or evals/scores.md): - Hover over the prompt you sent and select Schedule this.
- Select when the prompt runs and how often (every weekday at 8:00), then select Save.
- Select the Task icon in the left side bar header of the Copilot app, then the Scheduled tab. Use Run now once to test it. Edit Schedule, Pause and Delete are there too.
- Write down what it may do: a scheduled task runs a prompt. We found no page that shows it running a script, writing a file or taking a permission list. For the run itself use the GitHub Copilot tab of this lesson.
Note: For the part that needs a repository this course sends you to the GitHub Copilot tab. That pairing is our choice, not a Microsoft statement. Microsoft's own route is the Code tab, which is a preview. Its Automations run on a schedule, but only on your device. On a personal account the Code tab is offered only in the United States and Canada. We found no per-run cost report or alert for scheduled tasks.
Paid planWork or school account. Microsoft's page says a Microsoft Copilot licence is required for Scheduled tasks.
Claude Code
- Create
run_eval.shinorderdesk/with the command below. On Windows put the same line inrun_eval.ps1. The command is put together from flags that are each documented, not copied from one page example.claude -p "Run python evals/run.py. Write the pass rate and the ids of the failing cases to evals/last_run.md. Change no other file." --permission-mode dontAsk --allowedTools "Bash(python evals/run.py)" "Read" "Edit(./evals/last_run.md)" --output-format json --max-turns 10 --max-budget-usd 1 > run_output.json - Read what the flags allow. In
dontAskmode anything not pre-approved is denied, so the run may run that one command, read files and writeevals/last_run.md. File writes need anEdit(path)rule: aWrite(path)rule with a path does not match. - Keep the Bash rule identical to the command in the prompt. If your machine needs
python3, change both, or the command is denied. - For a job where browser login is not possible, run
claude setup-tokenonce on a machine with a browser, approve access and copy the token it prints. Store it asCLAUDE_CODE_OAUTH_TOKENin the job's secret store, never in the script or the repository. - Run the script and leave the keyboard. Exit code 0 means the run worked, non-zero that it failed. Check
evals/last_run.md, and rungit status: the agent should have changed only that file (your shell wroterun_output.json). - Open
run_output.jsonand copytotal_cost_usdinto your runbook as the cost of one run. It is an estimate made on your machine and can differ from the bill. - Set an account limit. On Pro, Max or Ultra run
/usage-credits, which opens Settings > Usage with your monthly spend limit. On Team and Enterprise an admin sets spend limits. On a Console account use workspace spend limits. - Write the command, the variable name, the two caps and the cost estimate into
RUNBOOK.md. Then open a fresh terminal and restart the run from the runbook alone.
Note: The 10 turns and the 1 US dollar in the command are examples: use the cap you agreed. --max-budget-usd stops at an estimated spend, and spend can pass the cap. On Pro, Max and Ultra usage is included, so the cost figure is not your bill. The Agent SDK runs the same loop as a Python or TypeScript library (claude-agent-sdk), signs in with ANTHROPIC_API_KEY, and its cost figure is an estimate too. On native Windows the Bash sandbox does not run.
Paid planNeeds a paid Claude plan (Pro, Max, Ultra, Team or Enterprise) or a Claude Console account. The Free plan does not include Claude Code.
OpenAI Codex
- Create
run_eval.shinorderdesk/with the command below (Codex needs a Git repository). On Windows put the same line inrun_eval.ps1.codex exec --sandbox workspace-write --json -o run_message.md "Run python evals/run.py. Write the pass rate and the ids of the failing cases to evals/last_run.md. Change no other file." > run_output.jsonl - Know the limit:
workspace-writelets the run edit files anywhere in the workspace, with the network off. We found no Codex rule per file, so "change no other file" rests on the prompt and on your check afterwards. - Use
--sandbox workspace-writeon its own. Do not add--approve-for-me, which conflicts with--sandbox, and keepdanger-full-accessfor an isolated CI runner or container. - Use an API key in CI and set
CODEX_API_KEYon that one command only, never as a job-level environment variable in a job that runs repository code. On GitHub Actions the Codex GitHub Action keeps the key away from your steps. - Run the script from a fresh terminal. Check
evals/last_run.md, rungit status, and read the final message that-osaved inrun_message.md. - Open
run_output.jsonl, find theturn.completedline and copyinput_tokens,cached_input_tokens,output_tokensandreasoning_output_tokensinto your runbook. The pricing page lists credit rates per million tokens for each model. - Check usage at chatgpt.com/codex/settings/usage. Then set the limit your plan offers: monthly credit limits under Workspace settings > Billing on Business, or a spend alert and a hard spend limit for an API key.
Note: There is no per-run budget flag on codex exec and no ready money figure: the cost comes from the token counts. The Codex CLI has no built-in schedule, so start the script from cron or CI. Scheduled tasks in the desktop app need the computer on and the app running when they use local files. Usage limits depend on your plan. A workspace admin can switch local Codex off.
Paid planThe Codex CLI and codex exec need ChatGPT Plus, Pro, Business, Enterprise or Edu, or an API key billed at API rates. A free route for the CLI is not confirmed.
Gemini CLI
- Set
GEMINI_API_KEY(or the Vertex AI variables) in the job's environment, never in the script. A headless run uses cached sign-in when there is one. - Create
run_eval.shinorderdesk/with the line below (on Windows,run_eval.ps1). Your script runs the eval, and a short Python step saves the full JSON torun_output.jsonand the summary toevals/last_run.md. The agent only reads.python evals/run.py | gemini -p "This is the output of python evals/run.py. Write the pass rate and the ids of the failing cases as a short Markdown note. Change no file." --output-format json | python -c "import json, sys; d = json.load(sys.stdin); open('run_output.json', 'w').write(json.dumps(d, indent=2)); open('evals/last_run.md', 'w').write(d['response'])" - Leave
--approval-modeatdefault. Most write tools then need confirmation, and a headless run cannot ask: a rule that would ask is treated as deny. Do not useyolohere unless the sandbox (-s) is on. - Run the script from a fresh terminal. If it stops with
FatalUntrustedWorkspaceError, the folder is not trusted: add--skip-trustto thegeminiline. - Open
run_output.jsonand copy the token usage from itsstatsobject into your runbook. Turn it into money yourself with the price list of the place where the key was bought. - Put the failure signs in
RUNBOOK.md. In this pipeline ageminifailure shows up as a JSON error from the Python step. Run thegeminipart alone to see its own exit code: 0 is success, 1, 42 and 53 are failures. Under Update writegemini update.
Note: Google now sends individuals to Antigravity CLI, a different product. This course has no checked steps for it. This tab differs on purpose: your script writes the file, so the agent needs no write permission. The pages read show no money cost report, no spending cap, no SDK and no schedule of its own for Gemini CLI: start the script from a CI job or your own scheduler.
Paid planNeeds a company Gemini Code Assist Standard or Enterprise licence, or a paid Gemini API or Vertex AI key. Free and Google AI Pro or Ultra sign-in stopped on 18 June 2026.
Cursor
- Install the Cursor CLI with the command below. On Windows PowerShell run
irm 'https://cursor.com/install?win32=true' | iexinstead. Check the install withagent --version.curl https://cursor.com/install -fsS | bash - Run
agent loginonce, or create a key under Cursor Dashboard > API Keys and set it asCURSOR_API_KEYin the environment. In a pipeline keep the key in the CI secret store. - Open the global CLI config,
~/.cursor/cli-config.json(Windows:$env:USERPROFILE\.cursor\cli-config.json). IfapprovalModeisunrestricted, print mode runs every action without approval: set it toallowlist. - Create
.cursor/cli.jsoninorderdesk/with the content below. Print mode already runs edits inside the workspace, so the deny rules do the limiting. Deny rules win over allow rules.{ "permissions": { "allow": ["Shell(python)"], "deny": ["Shell(rm)", "Read(.env*)", "Write(data/**)", "Write(prompts/**)", "Write(evals/drafts/**)"] } } - Create
run_eval.sh(on Windows,run_eval.ps1) with the command below. Leave out--force, so only allowed actions run.agent -p --output-format text "Run python evals/run.py. Write the pass rate and the ids of the failing cases to evals/last_run.md. Change no other file." > run_output.txt - Run the script from a fresh terminal. Check which actions were rejected: a rejection means the rules work, or are too tight. Run
git statusto check that the agent changed onlyevals/last_run.md. - Note your usage under Usage at grok.com/dashboard before and after one run, because the output has no cost field. Cursor's help page sends usage and billing for The X Subscription to grok.com. On a legacy plan use the Spending tab at cursor.com/dashboard/spending.
- Set a limit before it goes live: at grok.com/dashboard/billing, under Additional usage credits, find Monthly additional usage limit and click Edit.
Note: Cursor's pages do not say which plans include the CLI. Check your own plan before you count on it. Shell(python) allows every python command, and every file that is not denied stays writable, so git status is your check. Individual plans have no spend alerts, and the limit is not enforced at once, so usage can briefly pass it. We did not read the grok.com pages themselves. A team admin can turn on Disable CLI headless mode, and then agent -p exits with an error.
GitHub Copilot
- Create a fine-grained personal access token: under Resource owner select your personal account, under Permissions select the Account tab, click Add permissions, select Copilot Requests and click Generate token.
- Store it as
COPILOT_GITHUB_TOKENin the job's secret store or your shell session, never in the repository or the script. Classic personal access tokens do not work for the CLI. - Create
run_eval.shinorderdesk/(on Windows,run_eval.ps1) with the command below.copilot -p "Run python evals/run.py. Write the pass rate and the ids of the failing cases to evals/last_run.md. Change no other file." -s --no-ask-user --allow-tool='shell(python:*), write' --max-ai-credits 30 --secret-env-vars=COPILOT_GITHUB_TOKEN --share=./run_transcript.md - Read what it allows: python commands and file writes. Requests that still need approval are denied. The pages show no per-file form of
write, so check the result. 30 AI credits is the lowest cap, good for testing. - Run the script from a fresh terminal. The exit code only signals an interrupted or empty run, so check
evals/last_run.mdandgit status, and readrun_transcript.md. - Open github.com/settings/billing and note the usage for that day as the cost of the run (1 AI credit is $0.01). Then set a budget under Budgets and alerts with New budget.
- Schedule it from outside the CLI: cron, Task Scheduler on Windows, or a GitHub Actions workflow with a
scheduletrigger that runsnpm install -g @github/copilotand then your script.
Note: --max-ai-credits is a soft limit in public preview: at 90% the next model call answers without tools. GitHub's pages disagree on whether it counts per session or per response; for one -p run that is the same. We found no line that prints the cost of a -p run. /every and /after have a conflicting status, so use an external scheduler. An organisation can switch the CLI off by policy.
Create a free account to save your progress
Free, and no payment details. Your ticks and finished lessons are kept, on every device.
Create a free account I already have an accountCreate a free account to save your progress. Sign in or sign up