Headless in cron and CI
Queue ideas overnight and find their questions waiting in the morning, answer from anywhere and let a schedule pick it up, post a digest of what needs you, and check your factory repo in CI.
Verification: the scripts were run on the twin (with GW_RUNNER=scripted). Real cron, real headless claude -p stages and GitHub Actions were not run (details at the bottom).
The headless runner runs each stage as claude -p under your own Claude Code login, with no terminal UI. That makes Greenware schedulable: nothing in a play needs you until it asks a question or reaches a gate, so a machine can do all the waiting.
The scripts this page uses are in examples/automation/.
The pattern: queue at night, decide in the morning
After a week of client calls you have a list of asks. Write them down as you hear them, one per line:
# examples/ideas/ideas.txt: <client>|<raw idea>
acme|lookalikes off last 45 days of closed-won, routed to AEs
acme|route inbound demo requests to the right AE in under 5 minutes; existing accounts go to their owner, Gmail signups still get a path
kestrel|score our TAM on fit and engagement, tier 1-3, and ping the owner when an account is promoted to tier 1
Queue them without running anything:
bash examples/automation/queue-ideas.sh examples/ideas/ideas.txt
Each line becomes gw idea <client> "<idea>" --no-run, a play in ready. A client with no pinned workspace is refused and named (not queued: orbitly | …), so a typo in a client id doesn’t vanish.
At 06:00, cron runs advance-plays.sh, which is gw run with the headless runner: every ready play goes through Decompose and Clarify, one at a time, until it needs you. By the time you sit down, every play has its reading and its questions waiting:
== waiting on a human:
acme/lookalikes-off-last-45-days-of-closed-01 waiting_human 2 questions waiting for you
acme/route-inbound-demo-requests-to-the-right-01 waiting_human 2 questions waiting for you
kestrel/score-our-tam-on-fit-and-engagement-tier-01 waiting_human 2 questions waiting for you
Answer now, run later
gw answer, gw approve, gw reject, gw accept and gw reopen run the next stages right away by default, which ties up your terminal for minutes. Add --no-run and the play is left ready for the next scheduled run:
gw answer acme/lookalikes-off-last-45-days-of-closed-01 --defaults --no-run
# acme/lookalikes-off-last-45-days-of-closed-01 Clarify · ready · All questions answered
The next advance-plays.sh takes it through Research, Spec and Plan to Gate A. Approve with --no-run and the run after that takes it through Build, Verify and Audit to Gate B. You decide in seconds; the machine does the hours.
gw run with a herdr factory opens Herdr tabs instead of running stages. That’s why the script sets GW_RUNNER=headless (overridable). The environment variable wins over factory.yaml, so one factory can be driven from Herdr by day and headless by night.
The cron entries
# Weekdays 06:00: overnight ideas get their questions by morning.
0 6 * * 1-5 GW_HOME=$HOME/factory bash $HOME/factory/tools/advance-plays.sh
# Every 2 hours in working hours: pick up what you answered or approved with --no-run.
0 8-18/2 * * 1-5 GW_HOME=$HOME/factory bash $HOME/factory/tools/advance-plays.sh
# Weekdays 09:00: a digest of what's waiting on you.
0 9 * * 1-5 GW_HOME=$HOME/factory SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXX/YYY/ZZZ bash $HOME/factory/tools/inbox-digest.sh
What advance-plays.sh takes care of:
GW_HOMEis required. Cron has no working directory to find the factory from.PATH. Cron’s is minimal, so the script adds~/.local/binand~/.bun/bin, where the installer putsgw, Bun and the Clay CLI. Make sureclaudeis on thatPATHtoo.- One run at a time. A stage can take many minutes, and two drivers must never run the same play. The script holds a
flockand skips if the last run is still going. - Logs go to
$GW_HOME/.greenware/logs/, which the factory’s.gitignorealready covers.
The inbox digest
GW_HOME=~/factory bash examples/automation/inbox-digest.sh
Greenware: 7 play(s) waiting on you
• acme/lookalikes-off-last-45-days-of-closed-01 · clarify · waiting_human · 0h · 2 questions waiting for you
• acme/when-a-champion-from-a-paying-customer-01 · clarify · waiting_human · 0h · 2 questions waiting for you
…
It reads gw status --json (every play’s state), keeps the statuses that need a person (waiting_human, gate, manual, blocked), and sorts them oldest first by updatedAt. With SLACK_WEBHOOK_URL set to your own incoming webhook, it posts the same text there. It sends play ids, stages and status messages, never artifacts or client data. Read the status messages before you point it at a channel others can see: they name clients.
What the machine needs
The machine that runs cron must hold the factory folder itself, not a clone of its repo. Play state (state.json) and approvals are signed with the factory’s secret, .greenware/secret, which is gitignored and must stay out of git. A clone without it can list plays but refuses to run them:
$ gw show acme/lookalikes-01 # in a fresh clone of the factory repo
gw: acme/lookalikes-01: state.json was modified outside the engine (signature mismatch); refusing to run it
This is deliberate: stage agents can write files in their play folder, so the engine refuses any record it didn’t sign. To move a factory to a new machine, copy .greenware/secret across yourself, over a secure channel, and never through the repo. A clone that ran gw first has already made a secret of its own. Replace it with the original.
The machine also needs each client’s Clay login (clients/<id>/.clay/, gitignored) and a signed-in Claude Code for the user cron runs as.
CI for your factory repo
Your factory repo is your audit trail, so check it on every push. examples/automation/factory-check.yml is a GitHub Actions workflow that:
- Installs a pinned
gw.curl -fsSL greenware.sh | sh -s -- v0.8.0, withGREENWARE_SKIP_CLAUDE,GREENWARE_SKIP_HERDR,GREENWARE_SKIP_CLAY,GREENWARE_NO_STARTandGREENWARE_NO_PROFILEset, so it installs only the CLI. - Loads every factory file.
gw statusfails iffactory.yamlor anystate.jsondoesn’t parse. Thengw client standardsandgw client decisionsfor each client. A hand edit that breaks a file fails the push, not next morning’s cron. - Runs a twin smoke play in a temp factory, so you know the pinned release works end to end before you upgrade the real machine.
It can’t run your real plays (no secret, no Clay logins, no Claude Code login), and it shouldn’t.
Failure modes
| What you see | What it means | What to do |
|---|---|---|
| Cron ran but nothing moved | No play was ready: everything was waiting on you |
Check the digest; that’s the expected state most of the time |
No factory yet in the cron log |
GW_HOME unset or wrong |
Set it in the crontab line |
claude: command not found in the log |
Cron’s PATH |
Add Claude Code’s folder to PATH in the script |
another advance-plays run holds …; skipping |
The last run is still going | Expected; it runs again next slot |
state.json was modified outside the engine (signature mismatch) |
A clone without the original secret, or a hand edit of state.json |
Run from the factory’s own machine; never hand-edit play state |
factory.yaml in … is invalid: [ |
A hand edit broke the schema; v0.7.0 cut the message at its first line; v0.8.0 prints the failing path | Check the field you changed against examples/factory/*.yaml |
Verification
Run on the twin (isolated factory, gw on PATH through a shim to this checkout): queue-ideas.sh examples/ideas/ideas.txt queued 7 plays and named the 2 for an unpinned client; GW_RUNNER=scripted advance-plays.sh ran every ready play to Clarify and logged the waiting list to .greenware/logs/; inbox-digest.sh printed the digest above; gw answer … --defaults --no-run left the play ready and the next advance-plays.sh took it to Gate A; gw approve --gate A --no-run then advance-plays.sh took it to Gate B. The CI file’s two check steps were run locally as shell: the factory-files step passed on a copy of the factory without .greenware/, and the twin smoke step ended with jq -e reporting true. A copy without the secret refused gw show with the signature-mismatch error, and a broken runner: value made gw status exit 1.
Not run: real cron, headless claude -p stages, a Slack post, the installer inside GitHub Actions.