buildAutoBootstrapPrompt is the bootstrap prompt for a headless, unattended run. It differs from the interactive prompt in two load- bearing ways: (1) there is no human, so the session must NOT use AskUserQuestion or wait for input — it proceeds on best judgment; and (2) the session is responsible f
(slug, kind, playbookSlug string)
| 298 | } |
| 299 | |
| 300 | // buildAutoBootstrapPrompt is the bootstrap prompt for a headless, |
| 301 | // unattended run. It differs from the interactive prompt in two load- |
| 302 | // bearing ways: (1) there is no human, so the session must NOT use |
| 303 | // AskUserQuestion or wait for input — it proceeds on best judgment; and |
| 304 | // (2) the session is responsible for closing itself out via `flow done` |
| 305 | // when the brief's acceptance criteria are met. |
| 306 | func buildAutoBootstrapPrompt(slug, kind, playbookSlug string) string { |
| 307 | showStep := "2. Run: flow show task. Read the file at the brief: path AND every file under updates:. Files under other: are on-demand references." |
| 308 | if kind == "playbook_run" { |
| 309 | showStep = fmt.Sprintf( |
| 310 | "2. Run: flow show playbook %s for context, then flow show task. Read the run brief at the brief: path (it is a frozen snapshot — your authoritative instructions) AND every file under updates:. Do NOT edit the run brief.", |
| 311 | playbookSlug, |
| 312 | ) |
| 313 | } |
| 314 | |
| 315 | return fmt.Sprintf( |
| 316 | "You are an AUTONOMOUS, headless execution session for flow task %s. NO HUMAN IS WATCHING and there is no terminal to prompt. Work end to end on your own and then close yourself out.\n\n"+ |
| 317 | "Bootstrap (do these in order before any work):\n"+ |
| 318 | "1. Invoke the flow skill via the Skill tool — it governs workflows, the bootstrap contract, KB discipline, and scope-creep detection.\n"+ |
| 319 | showStep+"\n"+ |
| 320 | "3. If a project is listed on the task, run: flow show project <slug> and read its brief + updates.\n"+ |
| 321 | "4. Read CLAUDE.md in your work_dir and any nested CLAUDE.md under subtrees you will modify — they override the brief.\n\n"+ |
| 322 | "Operating rules for autonomous mode:\n"+ |
| 323 | "- Do NOT use AskUserQuestion and do NOT wait for user input — there is no one to answer. Where the interactive workflow would ask, decide using best engineering judgment and proceed. Resolve any deferred/unclear brief sections yourself rather than stopping.\n"+ |
| 324 | "- Follow the repo's conventions (build/test commands, TDD if the repo expects it). Verify your work by running the tests before considering the task complete.\n"+ |
| 325 | "- Be conservative with irreversible or outward-facing actions: do NOT push branches, open PRs, deploy, or message anyone unless the brief EXPLICITLY authorizes it. Make and verify the local changes; leave publishing to the user.\n"+ |
| 326 | "- Your objective is to reach a state where you can run `flow done`. PERSIST toward it. Keep going through transient errors, and before declaring a blocker, EXHAUST reasonable avenues: try alternative approaches, re-read the brief and CLAUDE.md, search the codebase, retry flaky steps. Only stop as a LAST RESORT — when you have genuinely tried everything and truly cannot proceed without a human decision or external access you do not have. If you must stop, write a precise progress note to the task's updates/ directory stating exactly what is blocking and what you already tried, and exit WITHOUT marking the task done (it will surface as a failed autonomous run).\n\n"+ |
| 327 | "Closing out:\n"+ |
| 328 | "- When the brief's \"Done when\" criteria are met and your changes are verified, run: flow done %s. That flips the task to done and triggers the close-out sweep (KB + project update) — it is how this autonomous run is recorded as successful. Do this yourself; no human will.\n", |
no outgoing calls