Prompts as code and scheduled reports for AI agents

How to register a prompt as a file in the repository, run it on a schedule, choose the model by the kind of work and publish each report to one stable link.

Prompts as code means keeping each prompt as a versioned file in the repository, with its schedule, model and owner declared, so that it runs as written every time. A scheduled report is the simplest use: the same prompt runs at the same hour, and its result goes to one stable link with the earlier versions kept behind it.

My essays call these files registered prompts. Prompts as code is the common name for the same practice.

What prompts as code means

Most people get a report from an AI assistant the way they get one from a colleague: somebody remembers to ask. The answer depends on who asked and on what that person remembered to include. The next week the format is different and the numbers cannot be compared.

A registered prompt removes that dependence. The prompt is a file with an identifier, a history and an owner, and a change to the question is a change that somebody reviews.

I work on an AI agent that runs in production for a higher-education group. The project needed the same questions, asked the same way at the same time, with answers that could be compared week over week.

How a registered prompt works

The file has a short header and a body. The header declares the identifier, the cadence with its cron expression and time zone, the model and the effort level, the audience, the sources the prompt may read, the output file, the destination, the contract that fixes intention and format, and the owner, who is a person.

The body says what to measure, in what order and how to write. Two rules do most of the work.

  • Measure, do not remember. Every number comes from a live system and states its time window. A source that did not answer is reported as missing, never as zero.
  • Write the note and stop. The prompt never publishes on its own. A person reads the note first.

An earlier experiment with one long prompt for a coding agent left me two pieces of advice that apply here. End the prompt with the deliverable you expect. Say what has to be verified, so the agent does not declare the work finished too early.

How to run a prompt on a schedule

Claude Code offers two mechanisms. A /loop handles what repeats inside one session. A scheduled task handles the real cadence, such as twice a week at the end of the day. The task opens the prompt file and runs it as written.

Each run writes a new file with the version number incremented. A published version is never edited. The next version is published instead.

At the time of the essay, the project had no machine that was always on, so a person triggered the run and reviewed the note. When that machine exists, the run and the publication become automatic, and the review moves to comments on the published page.

Which model to use for a scheduled prompt

Not every report deserves the most expensive model. The rule in that practice follows the kind of work.

  • Programmatic or agentic action. The prompt runs tests, measures live systems, writes notes or publishes. It runs on Opus at high or maximum effort.
  • Documenting or inspecting without taking action. Sonnet at high effort.
  • Complex, uncertain or urgent work. The best model available, at high effort.

This choice keeps the routine cheap enough to run twice a week.

When to register a prompt and when a loop is enough

These rules are general advice drawn from the practice.

  • If the same question has to be asked the same way more than once, register the prompt.
  • If the work repeats only inside one session, a loop is enough.
  • If the work has to happen on fixed days at a fixed hour, use a scheduled task.
  • If the work starts when something changes, such as a new ticket, it needs a monitor and not a schedule.

In Prompting the Architecture I separate two mechanisms: a monitor asks whether a change requires a response, and a loop asks whether there is useful work to do. "Always find something to do" is a poor policy for a loop, because it turns spare capacity into unnecessary changes.

How to version the prompts of a production agent

The same idea applies to the prompts inside an agent, with a stricter review. An agent is a language model wrapped in prompts, tools and business rules. Change any of them and its behavior moves.

In the evaluation harness I built for that higher-education group, which serves 700,000+ students, golden cases are versioned in the repository next to the code they test. A change to behavior and the change to its expectations arrive in the same pull request. An evaluation gate runs in the pipeline and can say no.

So a person reviews the note of a report prompt, and a gate decides on a change to an agent prompt. The guide on agentic workflow integrity covers how to keep the evaluated version and the deployed version the same.

How to set up a scheduled report step by step

  1. Choose one report that people already ask for by hand.
  2. Write its contract: what it is for, who reads it and its format.
  3. Create the prompt file in the repository, with the header described above.
  4. Write the body: what to measure, in what order and how to write.
  5. Run it by hand twice so the format settles.
  6. Choose the model and the effort level by the kind of work.
  7. Schedule it, with the cron expression and the time zone in the header.
  8. Publish each version to one stable page after a person reads it.
  9. Add a row to the routine registry.

How to publish a report to one link and keep its versions

Each report has exactly one page. In the practice I describe, that page lives in Notion. Its body is replaced with the current version. A header says which version this is, which window it covers, when it was updated and which prompt produced it. Earlier versions sit underneath as sub-pages. The link in the bookmarks of every reader never changes.

Next to the pages sits a small database, the routine registry. It has one row per routine, with its state, its cadence, its current version, its last and next run and its owner.

What goes wrong with scheduled prompts

  • A missing source becomes a zero. The source did not answer and the report prints a number anyway.
  • The prompt publishes what nobody read. A note that goes out unread carries its errors to every reader at once.
  • The routine stops quietly. The registry holds the next run, so a monitor can see the gap.
  • An instruction is taken for a control. A prompt expresses the intended behavior. Permissions and review requirements cannot depend on an agent remembering to respect them.

A worked example: a work cut twice a week

One of the registered reports in that project is the work cut. Part of its header reads like this:

id: prompt-work-cut
cadence: Tuesday and Thursday, 17:30 local time
cron: 30 17 * * 2,4
timezone: America/Mexico_City
model: Opus
effort: xhigh
sources: Azure DevOps (PRs, builds), Jira (tickets), test center (verdicts, bugs), previous cuts
destination: the stable Notion page, published after a human reads it
owner: a person

The report says what landed, what is still open and who has the next action, in numbered blocks.

On Tuesday at the end of the day the prompt runs as written. The model is Opus because the prompt measures live systems and decides what belongs in the report. The output is a new file with the next version number. A person reads the note. Then the body of the stable page is replaced with it, and the previous cut stays underneath as a sub-page.

Two other reports run the same way: what is blocking the project, and a full status once a week.

What these sources show and what they do not

  • The practice comes from one project. The essay gives no measurement of time saved or of the quality of the reports.
  • At the time of the essay, a person triggered each run. Automatic runs and automatic publication are described as the next stage.
  • The model rule names the models available when the essay was written. Keep the criterion, not the names.
  • The schedule ran in Claude Code and the destination was Notion. The sources test no other combination.
  • The evaluation gate in the case study covers changes to a production agent. It does not test report prompts.
  • The list of failures follows from the rules of the practice. The essay does not report an incident for each item.

Where to go next

Common questions

What does prompts as code mean?

It means that a prompt is kept as a file in the repository, with its purpose, schedule, model and owner written in a short header. The file is versioned and reviewed like the rest of the code. I call such a file a registered prompt, and prompts as code is the common name for the same practice.

How do I schedule a prompt to run every week?

Write the cadence, the cron expression and the time zone in the header of the prompt file. In Claude Code, a loop covers what repeats inside one session, and a scheduled task covers the real cadence. The task opens the file and runs it as written, and each run writes a new file with the next version number.

Which model should a scheduled report use?

Choose it by the kind of work the prompt does. In the practice I describe, a prompt that acts, such as running tests, measuring live systems or publishing, runs on Opus at high or maximum effort. A prompt that only documents or inspects runs on Sonnet at high effort. Complex, uncertain or urgent work gets the best model available.

Should a scheduled prompt publish its report automatically?

Not at first. A registered prompt writes the note and stops, and a person reads it before it is published. Automatic publication comes later, when a machine that is always on exists, and the review then moves to comments on the published page.

How do I know that a scheduled report stopped running?

Keep a routine registry: one row per routine with its state, its cadence, its last run and its next run. A monitor can read that table and tell what should be running and what stopped quietly. Without it, a missing report is noticed only when somebody looks for it.

Work and evidence

Evaluation gates for a multi-agent education system (opens in a new tab)

My contribution: Built the evaluation harness, calibrated LLM judging, isolated case state and environment-specific evaluation gates.

What this supports: The public account describes golden cases as code, a calibrated LLM judge and the evaluation harness around them, on a Google Cloud agent stack.

What it does not establish: The figure of 700,000+ students describes the population served by the system. It does not measure simultaneous users, requests per second or personal ownership of the whole platform. Client code and data remain private.

Source reviewed:

From Traceability to Justifiability (opens in a new tab)

My contribution: Authored a public preprint on accountability structures in agentic software engineering, with code and study records linked from the research index.

What this supports: Research on binding evaluated behavior to deployed behavior and checking the evidence behind promotion.

What it does not establish: A preprint with a dated public-material study; not a certification of any production system.

Source reviewed:

The Agent Graph Runtime (opens in a new tab)

My contribution: Authored the runtime model separating graph construction, qualification, admission, execution and evidence.

What this supports: A published conceptual model for reasoning about executable identity and workflow lifecycle.

What it does not establish: A model and reference representation, not a throughput or reliability guarantee.

Source reviewed:

Technical guides