Skip to content
PKResources
Course outline

Agentic Engineering: the hands-on course · Module 5: Scaling up

Headless agents in scripts and CI

Most coding agents can run without a chat window: one prompt in, one result out. Here's how to turn that into scripts and CI jobs that open reviewable pull requests, not surprises.

Lesson 18 / 24 · ⏱ 8 min

Most coding agents have a non-interactive mode: you pass a prompt, it works, it exits with a result. No chat, no one watching.

That turns an agent into a building block. You can call it from a script, a scheduled job or a CI pipeline, for the chores nobody wants to do by hand.

What changes when nobody is watching

In a chat, you catch a bad direction after two messages. Headless, the agent runs to the end on its own. Everything you used to fix live has to be decided up front: the brief, the allowed actions, the checks and the output format.

  1. TriggerSchedule, label on an issue, failed build
  2. Fixed briefVersioned prompt file plus inputs
  3. Agent runIsolated runner, limited permissions
  4. ChecksThe same checks as a human PR
  5. Draft PRA human reviews and merges
The shape of every headless job I trust: the agent proposes, the pipeline verifies, a human decides.

Good first jobs

Start with work that is repetitive, well specified and easy to verify. The best candidates already have a clear pass or fail.

  • Dependency bumps that also fix what the bump broke, until the tests pass.
  • Failing lint or type errors after a rule gets stricter, in batches.
  • Triage notes on a new issue: likely files, a reproduction attempt, a suggested plan.
  • Doc drift: compare the API docs to the code and propose fixes.

Save “implement this feature from the ticket” for later. That job needs the human steering you learned in Module 3.

The brief is now a file

A headless prompt should live in the repo, reviewed like code. It needs even more structure than an interactive brief, because the agent can’t ask you anything.

Task: Upgrade the dependency named in DEP_NAME to the version in DEP_VERSION.

Do:
- Update the manifest and lockfile.
- Run the check command. Fix breakages caused by the upgrade only.
- Keep changes minimal. No refactors, no unrelated cleanups.

Stop and report instead of guessing if:
- A fix requires changing a public API.
- More than 10 files need edits.
- A test fails for a reason unrelated to the upgrade.

Output: a pull request description with what changed, what broke,
how you fixed it, and anything a reviewer should double-check.

Make it observable

A headless run that fails silently is worse than no automation. Keep the agent’s full transcript as a build artifact, cap its time and cost per run, and post a short summary where your team already looks.

✕ Fire and forget

  • –Prompt typed inline in the pipeline config
  • –Agent can push to main
  • –No time or cost cap
  • –Logs thrown away, just a green or red icon

✓ Boring and reliable

  • +Prompt versioned in the repo, reviewed in pull requests
  • +Agent opens a draft PR on its own branch
  • +Hard cap on run time and spend
  • +Full transcript kept, summary posted to the team

Check yourself

🧠 Headless agents

Score: 0 / 4

  1. 1. Which task is the best first headless job?

  2. 2. Why do headless briefs need explicit stop conditions?

  3. 3. Where should a headless job's output go?

  4. 4. A nightly agent job has been 'green' for weeks but nothing ever changes. What's missing?

Before you move on

✅ Key takeaways

0 / 4 completed