Sub topic 1
What Headless Means and Why Scheduled Jobs Need It
Prerequisites
Assume you can use a Linux or macOS shell, run an interactive coding agent, use basic Git, and read process exit codes.
Headless execution
A headless agent runs without a person at the terminal. It cannot wait for approval, ask which file to edit, or request a login. The command must provide the prompt, tools, permissions, credentials, and success conditions in advance.
An interactive session is useful for exploration. A scheduled run needs predictable inputs and outputs:
flowchart TD
A[Scheduler starts job] --> B[Headless agent reads prompt]
B --> C[Agent uses pre-approved tools]
C --> D[Validate result]
D --> E[Create reviewable output]caption: How a scheduled headless run works alt: A flow from a scheduler to an agent, through validation, to reviewable output.
Choosing a scheduler
| Scheduler | Best fit | Important behavior |
|---|---|---|
| cron | Simple jobs on one Unix host | Minimal environment; local time zone |
| systemd timer | Managed Linux services | Logs, dependencies, timeouts, and missed-run behavior |
| CI schedule | Repository automation | Temporary workers, platform logs, and built-in permissions |
Choose the simplest scheduler that gives you the controls you need. CI is often convenient for pull requests. A systemd timer fits a long-lived server. Cron is small and widely available.
The scheduler environment
A command that works in your shell may fail because schedulers usually provide a different PATH, working directory, user, home directory, and time zone. Set important values explicitly. Use absolute paths, change to the repository directory, and write logs to a known location.
Prompts that do not need questions
A self-contained prompt names the repository, task, allowed scope, checks to run, output format, and stopping conditions. It should tell the agent what to do when no change is needed. Avoid instructions such as “ask me what you prefer.”
Inspect the current repository. Update only files under src/.
Run the existing test command. Do not change dependencies.
If tests pass, report status and changed files as JSON.
If the task is unsafe or ambiguous, stop with status "blocked".Least-privilege tools
Pre-approve only the tools required for the task. A documentation agent may need read access but no write access. A maintenance agent may need to edit a branch but should not receive production credentials. Store secrets in the scheduler or CI secret store, not in the prompt or repository.
> callout note > Treat repository content as untrusted input. A file can contain instructions that attempt to expand the agent’s scope. >
Exercise
Why should a scheduled agent use absolute paths and an explicit working directory?
Show answer
The scheduler may use a different PATH and start the process outside the repository.