@bastani/atomic 0.9.0-alpha.2 → 0.9.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +7 -0
- package/dist/builtin/workflows/builtin/goal-ledger.ts +2 -0
- package/dist/builtin/workflows/builtin/goal-reports.ts +5 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +7 -3
- package/dist/builtin/workflows/builtin/goal-types.ts +2 -0
- package/dist/builtin/workflows/builtin/goal.d.ts +1 -0
- package/dist/builtin/workflows/builtin/goal.ts +2 -1
- package/dist/builtin/workflows/builtin/prompt-refinement.ts +102 -0
- package/dist/builtin/workflows/builtin/ralph-core.ts +6 -4
- package/dist/builtin/workflows/builtin/ralph-runner.ts +22 -24
- package/dist/builtin/workflows/builtin/ralph.d.ts +2 -0
- package/dist/builtin/workflows/builtin/ralph.ts +3 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +3 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +0 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/docs/workflows.md +775 -25
- package/package.json +2 -2
package/docs/workflows.md
CHANGED
|
@@ -43,12 +43,14 @@ Use a workflow when a task should be repeatable, inspectable, resumable, or spli
|
|
|
43
43
|
- [Direct One-Off Runs](#direct-one-off-runs)
|
|
44
44
|
- [Fast Inference for Workflow Stages](#fast-inference-for-workflow-stages)
|
|
45
45
|
- [Writing a Workflow](#writing-a-workflow)
|
|
46
|
+
- [Migrating from the `defineWorkflow()` Builder API](#migrating-from-the-defineworkflow-builder-api)
|
|
46
47
|
- [Workflow Primitives](#workflow-primitives)
|
|
47
48
|
- [Task and Stage Options](#task-and-stage-options)
|
|
48
49
|
- [Programmatic Usage](#programmatic-usage)
|
|
49
50
|
- [Context Engineering](#context-engineering)
|
|
50
51
|
- [Design Checklist](#design-checklist)
|
|
51
52
|
- [Common Mistakes](#common-mistakes)
|
|
53
|
+
- [Workflow Best Practices](#workflow-best-practices)
|
|
52
54
|
|
|
53
55
|
## Quick Start
|
|
54
56
|
|
|
@@ -156,7 +158,7 @@ For the builtin result tables below, `deep-research-codebase`, `goal`, and `ralp
|
|
|
156
158
|
|---|---|---|
|
|
157
159
|
| `deep-research-codebase` | Scout + research-history chain → parallel specialist waves → aggregator. Indexes the whole repo and synthesizes findings. | Broad or cross-cutting research before you decide what to change. Prefer `/skill:research-codebase` for one subsystem. |
|
|
158
160
|
| `goal` | Persisted goal ledger → bounded worker turns → receipts → three-reviewer gate → deterministic reducer → final report. | Small-to-medium scope changes when you can identify the work surface, state the exact outcome, and name the validation that proves it is done — for example tests, lint/typecheck, docs builds, or observable behavior. |
|
|
159
|
-
| `ralph` | Prompt-
|
|
161
|
+
| `ralph` | Prompt-refinement → research-prompt-refinement → codebase/online research → sub-agent orchestration → multi-model parallel review → optional final-stage PR handoff. | Larger migrations, broad refactors, and multi-package changes where you want Atomic to refine the prompt for clarity, transform it into a research question, research the codebase before implementing, delegate through sub-agents, review, iterate, and optionally allow only the final `pull-request` stage to attempt PR creation with `create_pr=true`. |
|
|
160
162
|
| `open-claude-design` | Design-system onboarding → reference import → HTML generation → impeccable-driven refinement → quality gate → rich HTML handoff. Renders a live `preview.html` you can iterate against (opens through `browser` when available). | UI, page, component, theme, or design-token work that benefits from generation + critique loops. |
|
|
161
163
|
|
|
162
164
|
### `deep-research-codebase`
|
|
@@ -223,7 +225,7 @@ Run examples:
|
|
|
223
225
|
/workflow goal objective="Fix the settings form validation bug; add/adjust the focused test and consider it done when invalid emails show the inline error without submitting"
|
|
224
226
|
```
|
|
225
227
|
|
|
226
|
-
`goal` creates an OS-temp `goal-ledger.json` artifact, renders goal-continuation context for each worker turn, writes each worker receipt to `work-turn-N.md`, and appends receipts, reviewer decisions, blockers, reducer decisions, and lifecycle events to the ledger. The objective is treated as user-provided data, not higher-priority instructions.
|
|
228
|
+
`goal` starts with a single `prompt-refinement` stage that invokes the `prompt-engineer` skill (`/skill:prompt-engineer`) to sharpen the raw objective into a clearer, more actionable form using the Workflow Best Practices prompt anatomy documented later in this guide; the refined objective becomes the operative one recorded in the ledger (the original is preserved as `original_objective` and shown in the final report when it differs). `goal` then creates an OS-temp `goal-ledger.json` artifact, renders goal-continuation context for each worker turn, writes each worker receipt to `work-turn-N.md`, and appends receipts, reviewer decisions, blockers, reducer decisions, and lifecycle events to the ledger. The objective is treated as user-provided data, not higher-priority instructions.
|
|
227
229
|
|
|
228
230
|
Write the `objective` like a compact acceptance spec. Say what should exist when the run is done, how you want testing handled, which command(s) or manual checks matter, and what outcome proves completion. The workflow is intentionally lean: it does not first generate an RFC or migration plan, so the developer-supplied objective is where scope, validation, and completion criteria belong.
|
|
229
231
|
|
|
@@ -237,7 +239,8 @@ Result fields:
|
|
|
237
239
|
| `status` | Final reducer status: `complete`, `blocked`, or `needs_human` (or `active` only if externally interrupted). |
|
|
238
240
|
| `approved` | Whether the reducer reached `complete`. |
|
|
239
241
|
| `goal_id` | Per-run goal identifier stored in the ledger. |
|
|
240
|
-
| `objective` | Normalized goal objective used by the run. |
|
|
242
|
+
| `objective` | Normalized goal objective used by the run (after the `prompt-refinement` stage refines the raw objective). |
|
|
243
|
+
| `original_objective` | The raw user-provided objective exactly as given, before `prompt-refinement`. Omitted when refinement left it unchanged. |
|
|
241
244
|
| `ledger_path` | OS-temp path to `goal-ledger.json`, including receipts, reviewer decisions, reducer decisions, blockers, and lifecycle events. |
|
|
242
245
|
| `turns_completed` | Worker/review turns completed. |
|
|
243
246
|
| `iterations_completed` | Same value as `turns_completed`, retained for status summaries. |
|
|
@@ -265,7 +268,7 @@ Run examples:
|
|
|
265
268
|
/workflow ralph prompt="Safely implement the API refactor" git_worktree_dir=../atomic-ralph-api-wt base_branch=main
|
|
266
269
|
```
|
|
267
270
|
|
|
268
|
-
Each `ralph`
|
|
271
|
+
Each `ralph` run starts with a single `prompt-refinement` stage that invokes the `prompt-engineer` skill (`/skill:prompt-engineer`) to sharpen the raw user prompt into a clearer, more actionable objective using the Workflow Best Practices prompt anatomy documented later in this guide; that refined prompt becomes the operative objective for research, orchestration, and review, while the original is surfaced as `original_prompt`. Each iteration then transforms the refined prompt with `/skill:prompt-engineer Transform the following refined user request into a codebase and online research question which can be thoroughly explored: ...` (`research-prompt-refinement`), researches that transformed question with `/skill:research-codebase ...`, and writes the findings under `research/`. The orchestrator treats that research artifact as its primary implementation context, initializes/updates an OS-temp implementation notes file while generating verifiable evidence for any claims it records in the notes and reviewer artifacts, delegates implementation through sub-agents, and asks three independent reviewers to inspect the patch directly against `base_branch`. The reviewer fan-out runs each reviewer on a different primary model family (with shared fallbacks) so the adversarial review gets cross-model coverage instead of three passes from one model. Ralph's orchestrator and reviewers are prompted to verify user-visible behavior end-to-end when practical, using `playwright-cli`-skilled subagents for web/frontend flows that may depend on backend/API behavior and tmux-skilled subagents for TUI or terminal-app scenarios. For UI-applicable or full-stack changes, the orchestrator runs a `playwright-cli` end-to-end QA pass and records a reviewable proof video (referenced in the implementation notes and surfaced as `qa_video_path`); when `create_pr=true`, the final `pull-request` stage attaches or links that video to the created PR/MR/review. If reviewers find issues, the next `research-prompt-refinement` and research stages receive the review artifact path so follow-up research can address unresolved findings, and research stages fork from prior research session data when available. The loop stops only when all three reviewers independently approve (each finds no issues) or `max_loops` is reached, so a P0–P3 finding from any single reviewer keeps Ralph iterating instead of being out-voted by a majority quorum. By default Ralph does not start the final `pull-request` stage, and `pr_report` is omitted. Prompt text alone does not opt in. Pass `create_pr=true` only when you explicitly want the final `pull-request` stage to inspect provider credentials and attempt provider-appropriate PR/MR/review creation, such as GitHub `gh`, Azure Repos `az repos pr create`, or Sapling/Phabricator tooling; Ralph's own PR-creation instructions live in that final stage.
|
|
269
272
|
|
|
270
273
|
Set `git_worktree_dir` when you want Ralph's worker stages isolated in a reusable Git worktree. Relative paths resolve from the invoking repository root, existing same-repository worktree roots are reused, and missing paths are created from `base_branch`. Ralph preserves the invoking repo-relative cwd inside the worktree, so launching from `repo/packages/api` with `git_worktree_dir=../repo-wt` runs stages from `../repo-wt/packages/api`.
|
|
271
274
|
|
|
@@ -285,6 +288,8 @@ Result fields:
|
|
|
285
288
|
| `iterations_completed` | Number of research/orchestrate/review loops completed. |
|
|
286
289
|
| `review_report` | Compact reference to the latest reviewer payload artifact. |
|
|
287
290
|
| `review_report_path` | JSON artifact path for the latest Ralph review round. |
|
|
291
|
+
| `original_prompt` | The raw user prompt exactly as provided, before the `prompt-refinement` stage. |
|
|
292
|
+
| `refined_prompt` | The clarity-refined prompt produced by the `prompt-refinement` stage and used as the operative objective for research, orchestration, and review. |
|
|
288
293
|
|
|
289
294
|
A typical end-to-end flow is `/skill:research-codebase` → `/skill:create-spec` → `/workflow goal objective="Implement the researched rate-limit behavior, run the focused tests, and finish when the documented burst behavior is validated"` when you can identify the work surface, state the exact outcome, and name the validation that proves it is done. Keep using `/workflow ralph` for larger migrations, broad refactors, and multi-package changes where you want Atomic to research first, delegate through sub-agents, review, iterate, and optionally allow only the final `pull-request` stage to attempt PR creation with `create_pr=true`.
|
|
290
295
|
|
|
@@ -1071,27 +1076,7 @@ Authoring basics:
|
|
|
1071
1076
|
- `outputs` declares typed outputs that parent workflows receive from `ctx.workflow(childWorkflow, ...)`.
|
|
1072
1077
|
- `run: async (ctx) => { ... }` defines the workflow body.
|
|
1073
1078
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
```diff
|
|
1077
|
-
-import { defineWorkflow, Type } from "@bastani/workflows";
|
|
1078
|
-
+import { workflow } from "@bastani/workflows";
|
|
1079
|
-
+import { Type } from "typebox";
|
|
1080
|
-
|
|
1081
|
-
-export default defineWorkflow("review-changes")
|
|
1082
|
-
- .description("Run two reviewers and synthesize findings.")
|
|
1083
|
-
- .input("target", Type.String())
|
|
1084
|
-
- .output("decision", Type.String())
|
|
1085
|
-
- .run(async (ctx) => ({ decision: await review(ctx) }))
|
|
1086
|
-
- .compile();
|
|
1087
|
-
+export default workflow({
|
|
1088
|
-
+ name: "review-changes",
|
|
1089
|
-
+ description: "Run two reviewers and synthesize findings.",
|
|
1090
|
-
+ inputs: { target: Type.String() },
|
|
1091
|
-
+ outputs: { decision: Type.String() },
|
|
1092
|
-
+ run: async (ctx) => ({ decision: await review(ctx) }),
|
|
1093
|
-
+});
|
|
1094
|
-
```
|
|
1079
|
+
Migrating an existing file from the removed `defineWorkflow(...).compile()` builder? See [Migrating from the `defineWorkflow()` Builder API](#migrating-from-the-defineworkflow-builder-api) for the full method-to-key mapping, a before/after walkthrough, and a conversion checklist.
|
|
1095
1080
|
|
|
1096
1081
|
`prompt` and `task` are aliases for task text. Prefer `prompt` inside authored workflow files because it mirrors lower-level `stage.prompt(...)`; `task` remains useful in direct tool calls and chain examples.
|
|
1097
1082
|
|
|
@@ -1503,6 +1488,121 @@ If a parent workflow exits through `ctx.exit(...)` while a child workflow is in
|
|
|
1503
1488
|
|
|
1504
1489
|
Continuation replay treats the parent child-workflow boundary as the durable checkpoint: a previously completed child boundary replays with the original exposed outputs and without re-running the child, while a child that failed or was interrupted before completion starts again from the beginning on continuation. If `ctx.exit(...)` wins while a completed boundary is being replayed but before replay finalization, the boundary is finalized as skipped and its preloaded child metadata is omitted from store, persistence, restore, and expanded graph views.
|
|
1505
1490
|
|
|
1491
|
+
## Migrating from the `defineWorkflow()` Builder API
|
|
1492
|
+
|
|
1493
|
+
The chained builder API — `defineWorkflow(name).description(...).input(...).output(...).worktreeFromInputs(...).run(...).compile()` — was removed in [#1457](https://github.com/bastani-inc/atomic/pull/1457). The single `workflow({ name?, description, inputs, outputs, run })` object form is now the only authoring door. There is no shim and no deprecation period: workflow files that still call `defineWorkflow(...).compile()` fail discovery with a module-load error until they are migrated.
|
|
1494
|
+
|
|
1495
|
+
This section is for workflow files written against the previous API. If you are authoring a new workflow, skip it and start from [Writing a Workflow](#writing-a-workflow).
|
|
1496
|
+
|
|
1497
|
+
### What changed
|
|
1498
|
+
|
|
1499
|
+
- `import { defineWorkflow, Type } from "@bastani/workflows"` → `workflow` now comes from `@bastani/workflows`, and `Type` comes from the `typebox` package directly. `@bastani/workflows` no longer re-exports `Type`. The `Static` and `TSchema` *type* exports are still re-exported from `@bastani/workflows`, so `import type { Static } from "@bastani/workflows"` keeps working — only the runtime `Type` builder moved.
|
|
1500
|
+
- The fluent builder chain became one object literal passed to `workflow({ ... })`.
|
|
1501
|
+
- `name` moved from the `defineWorkflow(name)` argument into the object. It is now **optional** — omit it and discovery derives the name from the filename (the recommended style used by the builtins and most examples), or keep it when you want the name to differ from the file's basename.
|
|
1502
|
+
- `outputs` is now **required**. Workflows that declared no outputs before must now pass `outputs: {}`.
|
|
1503
|
+
- `.compile()` is gone. `workflow({ ... })` returns the frozen, branded definition directly; `export default` it.
|
|
1504
|
+
- The imperative object-form `runWorkflow(...)` runner is also removed (it is a `never` placeholder that throws on access). Programmatic execution uses the exported `run(def, inputs)` helper or a registry — see [Programmatic Usage](#programmatic-usage).
|
|
1505
|
+
|
|
1506
|
+
### Builder method → object key
|
|
1507
|
+
|
|
1508
|
+
| Removed builder API | New `workflow({ ... })` key |
|
|
1509
|
+
| --- | --- |
|
|
1510
|
+
| `defineWorkflow("name")` argument | `name: "name"` (optional; derived from the filename when omitted) |
|
|
1511
|
+
| `.description(text)` | `description: text` |
|
|
1512
|
+
| `.input(key, schema)` (repeatable) | `inputs: { key: schema, ... }` |
|
|
1513
|
+
| `.output(key, schema)` (repeatable) | `outputs: { key: schema, ... }` (required, even if `{}`) |
|
|
1514
|
+
| `.worktreeFromInputs(binding)` | `worktreeFromInputs: binding` (binding shape unchanged) |
|
|
1515
|
+
| `.run(fn)` callback | `run: fn` |
|
|
1516
|
+
| `.compile()` terminal | delete — `workflow({ ... })` returns the definition |
|
|
1517
|
+
|
|
1518
|
+
`ctx` and every primitive (`ctx.task`, `ctx.chain`, `ctx.parallel`, `ctx.stage`, `ctx.workflow`, `ctx.exit`, `ctx.ui`) are unchanged, so workflow **bodies do not need rewriting** — only the authoring wrapper changes.
|
|
1519
|
+
|
|
1520
|
+
### Full before / after
|
|
1521
|
+
|
|
1522
|
+
Before (removed API):
|
|
1523
|
+
|
|
1524
|
+
```ts
|
|
1525
|
+
import { defineWorkflow, Type } from "@bastani/workflows";
|
|
1526
|
+
|
|
1527
|
+
export default defineWorkflow("review-changes")
|
|
1528
|
+
.description("Run two reviewers in parallel and synthesize a decision.")
|
|
1529
|
+
.input("target", Type.String({ description: "Path or change target to review." }))
|
|
1530
|
+
.input("base_branch", Type.String({ default: "origin/main" }))
|
|
1531
|
+
.output("decision", Type.String())
|
|
1532
|
+
.output("concerns", Type.Optional(Type.Array(Type.String())))
|
|
1533
|
+
.worktreeFromInputs({ baseBranch: "base_branch" })
|
|
1534
|
+
.run(async (ctx) => {
|
|
1535
|
+
const target = String(ctx.inputs.target);
|
|
1536
|
+
const [quality, runtime] = await ctx.parallel(
|
|
1537
|
+
[
|
|
1538
|
+
{ name: "quality", prompt: `Review quality of ${target}` },
|
|
1539
|
+
{ name: "runtime", prompt: `Review runtime behavior of ${target}` },
|
|
1540
|
+
],
|
|
1541
|
+
{ concurrency: 2 },
|
|
1542
|
+
);
|
|
1543
|
+
return { decision: `${quality.text}\n${runtime.text}`, concerns: [] };
|
|
1544
|
+
})
|
|
1545
|
+
.compile();
|
|
1546
|
+
```
|
|
1547
|
+
|
|
1548
|
+
After (current API):
|
|
1549
|
+
|
|
1550
|
+
```ts
|
|
1551
|
+
import { workflow } from "@bastani/workflows";
|
|
1552
|
+
import { Type } from "typebox";
|
|
1553
|
+
|
|
1554
|
+
export default workflow({
|
|
1555
|
+
name: "review-changes", // optional — omit to derive from filename
|
|
1556
|
+
description: "Run two reviewers in parallel and synthesize a decision.",
|
|
1557
|
+
inputs: {
|
|
1558
|
+
target: Type.String({ description: "Path or change target to review." }),
|
|
1559
|
+
base_branch: Type.String({ default: "origin/main" }),
|
|
1560
|
+
},
|
|
1561
|
+
outputs: {
|
|
1562
|
+
decision: Type.String(),
|
|
1563
|
+
concerns: Type.Optional(Type.Array(Type.String())),
|
|
1564
|
+
},
|
|
1565
|
+
worktreeFromInputs: { baseBranch: "base_branch" },
|
|
1566
|
+
run: async (ctx) => {
|
|
1567
|
+
const target = String(ctx.inputs.target);
|
|
1568
|
+
const [quality, runtime] = await ctx.parallel(
|
|
1569
|
+
[
|
|
1570
|
+
{ name: "quality", prompt: `Review quality of ${target}` },
|
|
1571
|
+
{ name: "runtime", prompt: `Review runtime behavior of ${target}` },
|
|
1572
|
+
],
|
|
1573
|
+
{ concurrency: 2 },
|
|
1574
|
+
);
|
|
1575
|
+
return { decision: `${quality.text}\n${runtime.text}`, concerns: [] };
|
|
1576
|
+
},
|
|
1577
|
+
});
|
|
1578
|
+
```
|
|
1579
|
+
|
|
1580
|
+
### Conversion checklist
|
|
1581
|
+
|
|
1582
|
+
For each `.atomic/workflows/*.ts` (or workflow-package) file:
|
|
1583
|
+
|
|
1584
|
+
1. Swap the import to `import { workflow } from "@bastani/workflows"` and add `import { Type } from "typebox"`. Drop `defineWorkflow` from the `@bastani/workflows` import. `import type { Static, TSchema }` can stay on the `@bastani/workflows` import if you use those types.
|
|
1585
|
+
2. Replace `defineWorkflow("<name>")` with `workflow({`. You may keep `name: "<name>"` or drop the key entirely to derive the name from the filename.
|
|
1586
|
+
3. Move `.description("<text>")` to a `description: "<text>",` property.
|
|
1587
|
+
4. Collect every `.input(key, schema)` into one `inputs: { key: schema, ... },` map.
|
|
1588
|
+
5. Collect every `.output(key, schema)` into one `outputs: { key: schema, ... },` map. If there were no `.output(...)` calls, add `outputs: {},` — it is now required.
|
|
1589
|
+
6. Move `.worktreeFromInputs(binding)` to a `worktreeFromInputs: binding,` property (same binding shape, unchanged).
|
|
1590
|
+
7. Move the `.run(fn)` callback to a `run: fn,` property; the body stays byte-for-byte the same.
|
|
1591
|
+
8. Delete the trailing `.compile()`, close the object with `})`, and keep `export default`.
|
|
1592
|
+
9. Run `/workflow reload` (or restart Atomic) and `/workflow list` to confirm the file loads. Because `ctx` and its primitives are unchanged, stage behavior, graph layout, resume/kill, and human-input prompts are unaffected.
|
|
1593
|
+
|
|
1594
|
+
### Gotchas
|
|
1595
|
+
|
|
1596
|
+
- **`outputs` is required.** The old `.output(...)` calls were optional, and a workflow with none compiled fine. The new object form throws `workflow: outputs must be a schema map` when `outputs` is missing, so declare `outputs: {}` for outputless workflows.
|
|
1597
|
+
- **`Type` is no longer re-exported.** `import { Type } from "@bastani/workflows"` fails type-checking; import it from `typebox` instead. (`Static` and `TSchema` *types* are still re-exported from `@bastani/workflows`, so those imports do not need to change.)
|
|
1598
|
+
- **`.compile()` does not exist.** Leaving it produces a runtime `TypeError`; `workflow({ ... })` already returns the frozen, branded definition.
|
|
1599
|
+
- **`name` is derived from the filename when omitted.** `review-changes.ts` becomes the `review-changes` workflow, so an explicit `name` is only needed when it should differ from the basename.
|
|
1600
|
+
- **No hand-rolled definitions.** Objects carrying `__piWorkflow: true` that you construct by hand are rejected by discovery and by `ctx.workflow(...)`. Only definitions minted by `workflow({ ... })` are accepted.
|
|
1601
|
+
- **The imperative `runWorkflow` runner is gone.** It is now a `never` placeholder that throws on access; use the exported `run(def, inputs)` helper or a registry for programmatic execution.
|
|
1602
|
+
- **Keep `outputs` inline for the strictest type checking.** The old builder enforced no-extra-output keys through a `NoExtraOutputs` generic on `.run(fn)`; the object form re-creates that check for inline `outputs` maps, but cannot recover output keys when a schema map is widened or built up before being passed to `workflow({ ... })`. Keep the `outputs` literal inline so the declared-key check stays exact.
|
|
1603
|
+
|
|
1604
|
+
Everything else — stage primitives, `ctx.inputs` typing, runtime validation, DAG inference, MCP scoping, resume/kill, worktree binding, model fallback, and the `/workflow` tool contract — is unchanged.
|
|
1605
|
+
|
|
1506
1606
|
## Workflow Primitives
|
|
1507
1607
|
|
|
1508
1608
|
Prefer high-level primitives because they create tracked graph nodes, provide consistent handoff semantics, and keep workflow definitions easier to read.
|
|
@@ -1904,3 +2004,653 @@ Good workflows are information-flow systems, not just prompt sequences. Keep sta
|
|
|
1904
2004
|
- Do not write stage prompts that depend on hidden workflow-wide awareness; make each model stage locally scoped and self-described.
|
|
1905
2005
|
- Do not parse model gate decisions from ad-hoc prose with regular expressions; configure `schema` on a focused workflow item and consume `result.structured`.
|
|
1906
2006
|
- Return compact structured decisions and save large artifacts to files; artifact handoffs should still use files when the next stage does not need the whole payload in context.
|
|
2007
|
+
|
|
2008
|
+
## Workflow Best Practices
|
|
2009
|
+
|
|
2010
|
+
This is the playbook I use to get consistently better results from coding agents and workflow systems.
|
|
2011
|
+
|
|
2012
|
+
The core idea is simple: do not treat an agent like a magic box. Treat it like a capable engineering partner that needs a clear objective, tight scope, explicit validation, and occasional steering.
|
|
2013
|
+
|
|
2014
|
+
Most weak agent runs fail for predictable reasons: the goal is vague, the scope is too broad, validation is missing, or the agent keeps following the wrong signal. This playbook is about avoiding those failure modes.
|
|
2015
|
+
|
|
2016
|
+
The examples below are synthetic and intentionally generic. Replace placeholders like `[component]`, `[test command]`, and `[workflow]` with your own project details.
|
|
2017
|
+
|
|
2018
|
+
---
|
|
2019
|
+
|
|
2020
|
+
### The core loop
|
|
2021
|
+
|
|
2022
|
+
The workflow pattern I rely on most often is:
|
|
2023
|
+
|
|
2024
|
+
```text
|
|
2025
|
+
Objective -> Scope -> Done criteria -> Run -> Inspect -> Steer -> Validate -> Summarize
|
|
2026
|
+
```
|
|
2027
|
+
|
|
2028
|
+
In practice, that means:
|
|
2029
|
+
|
|
2030
|
+
1. Define the end state.
|
|
2031
|
+
2. Constrain the blast radius.
|
|
2032
|
+
3. State what counts as done.
|
|
2033
|
+
4. Let the agent or workflow work.
|
|
2034
|
+
5. Inspect status before reading details.
|
|
2035
|
+
6. Steer only when the run is off track, blocked, or missing criteria.
|
|
2036
|
+
7. Require evidence before accepting the result.
|
|
2037
|
+
8. Ask for a summary, handoff, or next-step plan.
|
|
2038
|
+
|
|
2039
|
+
A good workflow prompt does not just say what to try. It says what success looks like.
|
|
2040
|
+
|
|
2041
|
+
---
|
|
2042
|
+
|
|
2043
|
+
### Prompt anatomy
|
|
2044
|
+
|
|
2045
|
+
A strong workflow prompt usually has these parts:
|
|
2046
|
+
|
|
2047
|
+
#### Objective
|
|
2048
|
+
|
|
2049
|
+
What should be true when the work is complete?
|
|
2050
|
+
|
|
2051
|
+
```text
|
|
2052
|
+
Implement `[specific behavior]` in `[component]`.
|
|
2053
|
+
```
|
|
2054
|
+
|
|
2055
|
+
#### Context
|
|
2056
|
+
|
|
2057
|
+
What does the agent need to know before acting?
|
|
2058
|
+
|
|
2059
|
+
```text
|
|
2060
|
+
This is needed because `[reason]`. The relevant code likely lives near `[area]`.
|
|
2061
|
+
```
|
|
2062
|
+
|
|
2063
|
+
#### Scope
|
|
2064
|
+
|
|
2065
|
+
What is the agent allowed to change?
|
|
2066
|
+
|
|
2067
|
+
```text
|
|
2068
|
+
Only touch files directly required for `[behavior]`.
|
|
2069
|
+
```
|
|
2070
|
+
|
|
2071
|
+
#### Non-goals
|
|
2072
|
+
|
|
2073
|
+
What should the agent avoid?
|
|
2074
|
+
|
|
2075
|
+
```text
|
|
2076
|
+
Do not redesign `[subsystem]`, refactor unrelated code, or change public behavior outside `[case]`.
|
|
2077
|
+
```
|
|
2078
|
+
|
|
2079
|
+
#### Done criteria
|
|
2080
|
+
|
|
2081
|
+
How will we know the work is complete?
|
|
2082
|
+
|
|
2083
|
+
```text
|
|
2084
|
+
Done means:
|
|
2085
|
+
- `[new behavior]` works.
|
|
2086
|
+
- `[existing behavior]` is unchanged.
|
|
2087
|
+
- `[test command]` passes.
|
|
2088
|
+
- The final response includes changed files, validation results, and remaining risks.
|
|
2089
|
+
```
|
|
2090
|
+
|
|
2091
|
+
#### Stop conditions
|
|
2092
|
+
|
|
2093
|
+
When should the agent stop and ask instead of guessing?
|
|
2094
|
+
|
|
2095
|
+
```text
|
|
2096
|
+
If this requires changing `[public API/security behavior/data migration]`, stop and ask first.
|
|
2097
|
+
```
|
|
2098
|
+
|
|
2099
|
+
---
|
|
2100
|
+
|
|
2101
|
+
### Core principles
|
|
2102
|
+
|
|
2103
|
+
#### 1. Start with the end state
|
|
2104
|
+
|
|
2105
|
+
I try to describe what should be true at the end, not just what the agent should investigate.
|
|
2106
|
+
|
|
2107
|
+
Bad:
|
|
2108
|
+
|
|
2109
|
+
```text
|
|
2110
|
+
Look into the login issue.
|
|
2111
|
+
```
|
|
2112
|
+
|
|
2113
|
+
Better:
|
|
2114
|
+
|
|
2115
|
+
```text
|
|
2116
|
+
Fix the login redirect regression. Done means users who sign in from `[page]` return to `[expected destination]`, and `[test command]` passes.
|
|
2117
|
+
```
|
|
2118
|
+
|
|
2119
|
+
#### 2. Keep scope tight
|
|
2120
|
+
|
|
2121
|
+
Agents are often tempted to clean up nearby code. Sometimes that is useful, but most workflow runs should be bounded.
|
|
2122
|
+
|
|
2123
|
+
Use phrases like:
|
|
2124
|
+
|
|
2125
|
+
- `Only touch files required for this behavior.`
|
|
2126
|
+
- `Do not refactor unrelated code.`
|
|
2127
|
+
- `Preserve existing behavior for [case].`
|
|
2128
|
+
- `Make the smallest correct change.`
|
|
2129
|
+
|
|
2130
|
+
#### 3. Separate implementation from validation
|
|
2131
|
+
|
|
2132
|
+
A change is not done because the agent says it is done. It is done when the relevant evidence supports it.
|
|
2133
|
+
|
|
2134
|
+
That evidence can be:
|
|
2135
|
+
|
|
2136
|
+
- a targeted test,
|
|
2137
|
+
- a broader regression test,
|
|
2138
|
+
- a smoke command,
|
|
2139
|
+
- a typecheck or lint command,
|
|
2140
|
+
- a structured output contract check,
|
|
2141
|
+
- or a clear manual verification step.
|
|
2142
|
+
|
|
2143
|
+
#### 4. Prefer evidence over speculation
|
|
2144
|
+
|
|
2145
|
+
When something fails, I steer the agent back to the observable signal: the error, failing test, log line, user behavior, or broken contract.
|
|
2146
|
+
|
|
2147
|
+
```text
|
|
2148
|
+
Treat the failing assertion as the source of truth. Do not guess from nearby code alone.
|
|
2149
|
+
```
|
|
2150
|
+
|
|
2151
|
+
#### 5. Use staged thinking
|
|
2152
|
+
|
|
2153
|
+
For ambiguous work, I usually separate the flow into stages:
|
|
2154
|
+
|
|
2155
|
+
```text
|
|
2156
|
+
Investigate -> identify root cause -> propose fix -> implement -> validate -> summarize
|
|
2157
|
+
```
|
|
2158
|
+
|
|
2159
|
+
If the cause is not clear, I do not want the agent making broad changes just to see what happens.
|
|
2160
|
+
|
|
2161
|
+
#### 6. Steer, do not micromanage
|
|
2162
|
+
|
|
2163
|
+
The best steering messages are short and corrective. They add constraints, redirect attention, or provide a decision.
|
|
2164
|
+
|
|
2165
|
+
You usually do not need to rewrite the whole prompt. You need to say what changed.
|
|
2166
|
+
|
|
2167
|
+
#### 7. Treat failed validation as the next task
|
|
2168
|
+
|
|
2169
|
+
A failed test is not a footnote. It becomes the next objective.
|
|
2170
|
+
|
|
2171
|
+
```text
|
|
2172
|
+
Validation failed on `[command]`. Treat that as the source of truth. Fix the root cause only, rerun the failing check, then report the result.
|
|
2173
|
+
```
|
|
2174
|
+
|
|
2175
|
+
#### 8. Interrupt stale or wrong work
|
|
2176
|
+
|
|
2177
|
+
If a run is solving the wrong problem, based on outdated assumptions, or duplicating another run, stop it. Letting it continue usually creates more cleanup later.
|
|
2178
|
+
|
|
2179
|
+
#### 9. Inspect at the right level
|
|
2180
|
+
|
|
2181
|
+
For long-running workflows, I do not start by reading every log. I check:
|
|
2182
|
+
|
|
2183
|
+
1. overall status,
|
|
2184
|
+
2. current stage,
|
|
2185
|
+
3. blocker or failure reason,
|
|
2186
|
+
4. relevant stage details only if needed.
|
|
2187
|
+
|
|
2188
|
+
#### 10. Ask for synthesis before handoff
|
|
2189
|
+
|
|
2190
|
+
Before switching from investigation to implementation, or from implementation to review, I often ask for a concise synthesis:
|
|
2191
|
+
|
|
2192
|
+
```text
|
|
2193
|
+
Summarize root cause, proposed fix, files involved, validation plan, and remaining risks.
|
|
2194
|
+
```
|
|
2195
|
+
|
|
2196
|
+
---
|
|
2197
|
+
|
|
2198
|
+
### Common workflow patterns
|
|
2199
|
+
|
|
2200
|
+
#### Scoped implementation sprint
|
|
2201
|
+
|
|
2202
|
+
**Use when:** You have a clear feature, bug fix, or issue to delegate.
|
|
2203
|
+
|
|
2204
|
+
**Prompt shape:**
|
|
2205
|
+
|
|
2206
|
+
```text
|
|
2207
|
+
Implement `[feature]` in `[component]`. Only touch files directly needed for this behavior. Done means the new behavior works, existing behavior is unchanged, and `[test command]` passes.
|
|
2208
|
+
```
|
|
2209
|
+
|
|
2210
|
+
**Why it works:** The agent gets autonomy, but the objective and blast radius are bounded.
|
|
2211
|
+
|
|
2212
|
+
**Validation:** Run the most relevant targeted check first, then a broader nearby check if the change is risky.
|
|
2213
|
+
|
|
2214
|
+
---
|
|
2215
|
+
|
|
2216
|
+
#### Regression repair loop
|
|
2217
|
+
|
|
2218
|
+
**Use when:** CI, tests, typecheck, lint, or smoke validation fails.
|
|
2219
|
+
|
|
2220
|
+
**Prompt shape:**
|
|
2221
|
+
|
|
2222
|
+
```text
|
|
2223
|
+
Fix the failing `[test suite]` regression. Treat the failure output as the source of truth. Do not refactor unrelated code. Done means the failing test passes and no nearby tests regress.
|
|
2224
|
+
```
|
|
2225
|
+
|
|
2226
|
+
**Why it works:** It anchors the run to observable evidence instead of speculation.
|
|
2227
|
+
|
|
2228
|
+
**Validation:** Reproduce the failure, fix the root cause, rerun the failing check, then run a nearby or broader check.
|
|
2229
|
+
|
|
2230
|
+
---
|
|
2231
|
+
|
|
2232
|
+
#### Workflow or tooling smoke test
|
|
2233
|
+
|
|
2234
|
+
**Use when:** You changed a workflow definition, prompt contract, structured output, CLI behavior, or developer tool.
|
|
2235
|
+
|
|
2236
|
+
**Prompt shape:**
|
|
2237
|
+
|
|
2238
|
+
```text
|
|
2239
|
+
Validate `[workflow/tool]` after the change. Run a minimal smoke case, confirm required outputs are present, and report whether it can be invoked with expected inputs.
|
|
2240
|
+
```
|
|
2241
|
+
|
|
2242
|
+
**Why it works:** Workflow and tooling changes often fail at integration boundaries. A small smoke case catches those failures early.
|
|
2243
|
+
|
|
2244
|
+
**Validation:** Reload or rerun the tool, check the output shape, and report contract mismatches.
|
|
2245
|
+
|
|
2246
|
+
---
|
|
2247
|
+
|
|
2248
|
+
#### Human-in-the-loop checkpoint
|
|
2249
|
+
|
|
2250
|
+
**Use when:** The workflow might need a product decision, API decision, migration choice, or risky approval.
|
|
2251
|
+
|
|
2252
|
+
**Prompt shape:**
|
|
2253
|
+
|
|
2254
|
+
```text
|
|
2255
|
+
If blocked, ask before changing public API behavior. Otherwise proceed with the smallest compatible fix.
|
|
2256
|
+
```
|
|
2257
|
+
|
|
2258
|
+
**Why it works:** The agent keeps moving where it can, but does not guess on high-impact decisions.
|
|
2259
|
+
|
|
2260
|
+
**Validation:** Confirm the decision is reflected in the final behavior and summary.
|
|
2261
|
+
|
|
2262
|
+
---
|
|
2263
|
+
|
|
2264
|
+
#### Release gate
|
|
2265
|
+
|
|
2266
|
+
**Use when:** Preparing a release, version bump, changelog, publish step, migration, or deployment-adjacent task.
|
|
2267
|
+
|
|
2268
|
+
**Prompt shape:**
|
|
2269
|
+
|
|
2270
|
+
```text
|
|
2271
|
+
Prepare a `[release kind]` release for `[version]`. Do not publish unless validation passes. Report the exact checks performed and any unresolved blockers.
|
|
2272
|
+
```
|
|
2273
|
+
|
|
2274
|
+
**Why it works:** Release work needs explicit gates and stop conditions.
|
|
2275
|
+
|
|
2276
|
+
**Validation:** Require changelog review, tests, build/package checks, and a clear publish/no-publish decision.
|
|
2277
|
+
|
|
2278
|
+
---
|
|
2279
|
+
|
|
2280
|
+
#### Monitor-and-steer long run
|
|
2281
|
+
|
|
2282
|
+
**Use when:** A workflow runs asynchronously, has multiple stages, or may need supervision.
|
|
2283
|
+
|
|
2284
|
+
**Prompt shape:**
|
|
2285
|
+
|
|
2286
|
+
```text
|
|
2287
|
+
Show the current stage and blocker. If implementation is complete, summarize validation status and remaining risks.
|
|
2288
|
+
```
|
|
2289
|
+
|
|
2290
|
+
**Why it works:** It avoids both blind trust and excessive log-reading.
|
|
2291
|
+
|
|
2292
|
+
**Validation:** Inspect status first, then stages, then only the relevant details.
|
|
2293
|
+
|
|
2294
|
+
---
|
|
2295
|
+
|
|
2296
|
+
#### Investigate before implementing
|
|
2297
|
+
|
|
2298
|
+
**Use when:** A bug or request is ambiguous.
|
|
2299
|
+
|
|
2300
|
+
**Prompt shape:**
|
|
2301
|
+
|
|
2302
|
+
```text
|
|
2303
|
+
Investigate `[bug]`, identify root cause, and propose the smallest fix. Do not implement until the cause is clear.
|
|
2304
|
+
```
|
|
2305
|
+
|
|
2306
|
+
**Why it works:** It prevents the agent from making changes before it understands the failure mode.
|
|
2307
|
+
|
|
2308
|
+
**Validation:** Ask for a reproduction, root-cause explanation, proposed fix, and test plan before implementation.
|
|
2309
|
+
|
|
2310
|
+
---
|
|
2311
|
+
|
|
2312
|
+
### Steering patterns
|
|
2313
|
+
|
|
2314
|
+
#### Tighten scope
|
|
2315
|
+
|
|
2316
|
+
**Signal:** The agent starts expanding into adjacent cleanup, unrelated files, or broad refactors.
|
|
2317
|
+
|
|
2318
|
+
**Steer:**
|
|
2319
|
+
|
|
2320
|
+
```text
|
|
2321
|
+
Narrow this to `[specific behavior]` in `[component]`. Do not refactor unrelated code or change `[adjacent area]`. Done means `[specific acceptance criteria]`.
|
|
2322
|
+
```
|
|
2323
|
+
|
|
2324
|
+
**Why:** Prevents risky changes and keeps the run reviewable.
|
|
2325
|
+
|
|
2326
|
+
---
|
|
2327
|
+
|
|
2328
|
+
#### Add missing done criteria
|
|
2329
|
+
|
|
2330
|
+
**Signal:** The agent has a plan, but no clear finish line.
|
|
2331
|
+
|
|
2332
|
+
**Steer:**
|
|
2333
|
+
|
|
2334
|
+
```text
|
|
2335
|
+
Use these done criteria:
|
|
2336
|
+
1. `[behavior]` works.
|
|
2337
|
+
2. `[regression]` remains unchanged.
|
|
2338
|
+
3. `[test command]` passes.
|
|
2339
|
+
4. Report files changed and validation results.
|
|
2340
|
+
```
|
|
2341
|
+
|
|
2342
|
+
**Why:** Makes completion verifiable.
|
|
2343
|
+
|
|
2344
|
+
---
|
|
2345
|
+
|
|
2346
|
+
#### Redirect an off-track stage
|
|
2347
|
+
|
|
2348
|
+
**Signal:** The workflow is investigating the wrong area or solving the wrong problem.
|
|
2349
|
+
|
|
2350
|
+
**Steer:**
|
|
2351
|
+
|
|
2352
|
+
```text
|
|
2353
|
+
Stop pursuing `[wrong direction]`. The relevant signal is `[error/test/user behavior]`. Re-focus on `[target area]` and continue from there.
|
|
2354
|
+
```
|
|
2355
|
+
|
|
2356
|
+
**Why:** Saves time and prevents wrong assumptions from compounding.
|
|
2357
|
+
|
|
2358
|
+
---
|
|
2359
|
+
|
|
2360
|
+
#### Respond to a blocked prompt
|
|
2361
|
+
|
|
2362
|
+
**Signal:** The workflow asks for approval, a choice, or clarification.
|
|
2363
|
+
|
|
2364
|
+
**Steer:**
|
|
2365
|
+
|
|
2366
|
+
```text
|
|
2367
|
+
Choose `[option]`. Continue only if `[condition]`; otherwise stop and report the blocker.
|
|
2368
|
+
```
|
|
2369
|
+
|
|
2370
|
+
**Why:** Keeps the workflow unblocked without adding ambiguity.
|
|
2371
|
+
|
|
2372
|
+
---
|
|
2373
|
+
|
|
2374
|
+
#### Turn failed validation into the next task
|
|
2375
|
+
|
|
2376
|
+
**Signal:** Tests, typecheck, lint, build, or smoke checks fail.
|
|
2377
|
+
|
|
2378
|
+
**Steer:**
|
|
2379
|
+
|
|
2380
|
+
```text
|
|
2381
|
+
Validation failed on `[command]`. Treat that as the source of truth. Fix the root cause only, rerun the failing check, then report the result.
|
|
2382
|
+
```
|
|
2383
|
+
|
|
2384
|
+
**Why:** Prevents accepting partially working output.
|
|
2385
|
+
|
|
2386
|
+
---
|
|
2387
|
+
|
|
2388
|
+
#### Ask for synthesis
|
|
2389
|
+
|
|
2390
|
+
**Signal:** The workflow has gathered information, but the next action is unclear.
|
|
2391
|
+
|
|
2392
|
+
**Steer:**
|
|
2393
|
+
|
|
2394
|
+
```text
|
|
2395
|
+
Synthesize the current findings into: root cause, proposed fix, files likely involved, validation plan, and remaining risks.
|
|
2396
|
+
```
|
|
2397
|
+
|
|
2398
|
+
**Why:** Converts exploration into a usable plan.
|
|
2399
|
+
|
|
2400
|
+
---
|
|
2401
|
+
|
|
2402
|
+
#### Pause, kill, or rerun
|
|
2403
|
+
|
|
2404
|
+
**Signal:** A run is stale, duplicated, superseded, or based on outdated assumptions.
|
|
2405
|
+
|
|
2406
|
+
**Steer:**
|
|
2407
|
+
|
|
2408
|
+
```text
|
|
2409
|
+
Pause this run; it has been superseded by `[new context]`. Resume only with `[updated objective]`, or stop and summarize current state.
|
|
2410
|
+
```
|
|
2411
|
+
|
|
2412
|
+
**Why:** Avoids conflicting changes and wasted work.
|
|
2413
|
+
|
|
2414
|
+
---
|
|
2415
|
+
|
|
2416
|
+
### Copy-paste templates
|
|
2417
|
+
|
|
2418
|
+
#### Start a workflow
|
|
2419
|
+
|
|
2420
|
+
```text
|
|
2421
|
+
Objective:
|
|
2422
|
+
Implement/fix `[specific behavior]` in `[component]`.
|
|
2423
|
+
|
|
2424
|
+
Context:
|
|
2425
|
+
`[short context about why this matters or where to look]`
|
|
2426
|
+
|
|
2427
|
+
Scope:
|
|
2428
|
+
- Only touch files required for `[behavior]`.
|
|
2429
|
+
- Do not refactor unrelated code.
|
|
2430
|
+
- Preserve existing behavior for `[existing case]`.
|
|
2431
|
+
|
|
2432
|
+
Done criteria:
|
|
2433
|
+
- `[new behavior]` works.
|
|
2434
|
+
- `[regression case]` still works.
|
|
2435
|
+
- `[test command]` passes.
|
|
2436
|
+
- Report changed files, validation results, and any risks.
|
|
2437
|
+
|
|
2438
|
+
Stop conditions:
|
|
2439
|
+
- If this requires `[risky decision]`, stop and ask first.
|
|
2440
|
+
```
|
|
2441
|
+
|
|
2442
|
+
#### Tighten scope
|
|
2443
|
+
|
|
2444
|
+
```text
|
|
2445
|
+
Tighten scope to `[specific target]`.
|
|
2446
|
+
|
|
2447
|
+
Do not work on:
|
|
2448
|
+
- `[excluded area 1]`
|
|
2449
|
+
- `[excluded area 2]`
|
|
2450
|
+
- broad cleanup or unrelated refactors
|
|
2451
|
+
|
|
2452
|
+
Continue only on the path needed to satisfy:
|
|
2453
|
+
`[acceptance criterion]`.
|
|
2454
|
+
```
|
|
2455
|
+
|
|
2456
|
+
#### Add acceptance criteria
|
|
2457
|
+
|
|
2458
|
+
```text
|
|
2459
|
+
Add these acceptance criteria before continuing:
|
|
2460
|
+
|
|
2461
|
+
1. User can `[action]`.
|
|
2462
|
+
2. System handles `[edge case]`.
|
|
2463
|
+
3. Existing behavior `[existing behavior]` is unchanged.
|
|
2464
|
+
4. `[test command]` passes.
|
|
2465
|
+
5. Final response includes validation evidence.
|
|
2466
|
+
```
|
|
2467
|
+
|
|
2468
|
+
#### Redirect a stage
|
|
2469
|
+
|
|
2470
|
+
```text
|
|
2471
|
+
This stage is off track.
|
|
2472
|
+
|
|
2473
|
+
Stop investigating `[wrong area]`.
|
|
2474
|
+
The relevant signal is `[error/output/requirement]`.
|
|
2475
|
+
Refocus on `[correct area]`.
|
|
2476
|
+
|
|
2477
|
+
Next:
|
|
2478
|
+
1. Reproduce or inspect `[signal]`.
|
|
2479
|
+
2. Identify root cause.
|
|
2480
|
+
3. Make the smallest fix.
|
|
2481
|
+
4. Run `[validation command]`.
|
|
2482
|
+
```
|
|
2483
|
+
|
|
2484
|
+
#### Handle failed validation
|
|
2485
|
+
|
|
2486
|
+
```text
|
|
2487
|
+
Validation failed:
|
|
2488
|
+
|
|
2489
|
+
Command:
|
|
2490
|
+
`[command]`
|
|
2491
|
+
|
|
2492
|
+
Failure:
|
|
2493
|
+
`[short sanitized failure summary]`
|
|
2494
|
+
|
|
2495
|
+
Treat this as the source of truth.
|
|
2496
|
+
Fix only the root cause.
|
|
2497
|
+
Rerun the failing command.
|
|
2498
|
+
If it still fails, summarize the blocker and stop.
|
|
2499
|
+
```
|
|
2500
|
+
|
|
2501
|
+
#### Ask for synthesis
|
|
2502
|
+
|
|
2503
|
+
```text
|
|
2504
|
+
Synthesize current progress into:
|
|
2505
|
+
|
|
2506
|
+
- What was attempted
|
|
2507
|
+
- What changed
|
|
2508
|
+
- What evidence supports the result
|
|
2509
|
+
- What remains uncertain
|
|
2510
|
+
- Recommended next steps
|
|
2511
|
+
- Exact validation commands run
|
|
2512
|
+
```
|
|
2513
|
+
|
|
2514
|
+
#### Turn findings into implementation steps
|
|
2515
|
+
|
|
2516
|
+
```text
|
|
2517
|
+
Convert the findings into an implementation plan:
|
|
2518
|
+
|
|
2519
|
+
1. Files/components to change
|
|
2520
|
+
2. Order of changes
|
|
2521
|
+
3. Tests to add or update
|
|
2522
|
+
4. Validation commands
|
|
2523
|
+
5. Risks or edge cases
|
|
2524
|
+
6. Stop conditions
|
|
2525
|
+
```
|
|
2526
|
+
|
|
2527
|
+
#### Prepare a release gate
|
|
2528
|
+
|
|
2529
|
+
```text
|
|
2530
|
+
Prepare `[version]` as a `[release kind]` release.
|
|
2531
|
+
|
|
2532
|
+
Requirements:
|
|
2533
|
+
- Verify changelog entries are complete.
|
|
2534
|
+
- Run `[test command]`.
|
|
2535
|
+
- Run `[build/package command]`.
|
|
2536
|
+
- Do not publish unless all validation passes.
|
|
2537
|
+
- If any gate fails, stop and report blockers.
|
|
2538
|
+
|
|
2539
|
+
Final response should include:
|
|
2540
|
+
- Version
|
|
2541
|
+
- Checks run
|
|
2542
|
+
- Results
|
|
2543
|
+
- Files changed
|
|
2544
|
+
- Publish readiness
|
|
2545
|
+
```
|
|
2546
|
+
|
|
2547
|
+
---
|
|
2548
|
+
|
|
2549
|
+
### Concrete examples
|
|
2550
|
+
|
|
2551
|
+
#### Example 1: Fixing a failing test
|
|
2552
|
+
|
|
2553
|
+
**Scenario:** A package has one failing unit test after a recent change.
|
|
2554
|
+
|
|
2555
|
+
**Initial objective:**
|
|
2556
|
+
|
|
2557
|
+
```text
|
|
2558
|
+
Fix the failing `[unit test]`. Do not rewrite the module. Done means the test passes and nearby tests still pass.
|
|
2559
|
+
```
|
|
2560
|
+
|
|
2561
|
+
**Steering message:**
|
|
2562
|
+
|
|
2563
|
+
```text
|
|
2564
|
+
Stop exploring unrelated failures. Focus only on the assertion mismatch in `[test file]`.
|
|
2565
|
+
```
|
|
2566
|
+
|
|
2567
|
+
**Validation:** Run `[targeted test command]`, then `[nearby test command]`.
|
|
2568
|
+
|
|
2569
|
+
**Outcome:** Small fix applied, regression test passes, and the workflow reports exact commands and results.
|
|
2570
|
+
|
|
2571
|
+
---
|
|
2572
|
+
|
|
2573
|
+
#### Example 2: Repairing a workflow definition
|
|
2574
|
+
|
|
2575
|
+
**Scenario:** A custom workflow no longer returns the expected structured output.
|
|
2576
|
+
|
|
2577
|
+
**Initial objective:**
|
|
2578
|
+
|
|
2579
|
+
```text
|
|
2580
|
+
Validate `[workflow]` and fix its output contract. Done means the smoke run returns `[required fields]`.
|
|
2581
|
+
```
|
|
2582
|
+
|
|
2583
|
+
**Steering message:**
|
|
2584
|
+
|
|
2585
|
+
```text
|
|
2586
|
+
Treat the missing output field as the root issue. Do not change unrelated stage prompts.
|
|
2587
|
+
```
|
|
2588
|
+
|
|
2589
|
+
**Validation:** Reload workflow, run minimal smoke input, inspect structured result.
|
|
2590
|
+
|
|
2591
|
+
**Outcome:** Contract fixed, smoke test passes, and the workflow can be reused safely.
|
|
2592
|
+
|
|
2593
|
+
---
|
|
2594
|
+
|
|
2595
|
+
#### Example 3: Investigating before implementing
|
|
2596
|
+
|
|
2597
|
+
**Scenario:** A user-reported bug is ambiguous.
|
|
2598
|
+
|
|
2599
|
+
**Initial objective:**
|
|
2600
|
+
|
|
2601
|
+
```text
|
|
2602
|
+
Investigate `[bug]`, identify root cause, and propose the smallest fix. Do not implement until the cause is clear.
|
|
2603
|
+
```
|
|
2604
|
+
|
|
2605
|
+
**Steering message:**
|
|
2606
|
+
|
|
2607
|
+
```text
|
|
2608
|
+
Synthesize findings first: root cause, affected path, proposed fix, and validation plan.
|
|
2609
|
+
```
|
|
2610
|
+
|
|
2611
|
+
**Validation:** Add or run a reproduction test before changing code.
|
|
2612
|
+
|
|
2613
|
+
**Outcome:** Clear implementation plan produced, then delegated as a scoped fix.
|
|
2614
|
+
|
|
2615
|
+
---
|
|
2616
|
+
|
|
2617
|
+
### Anti-patterns
|
|
2618
|
+
|
|
2619
|
+
| Anti-pattern | Better approach |
|
|
2620
|
+
| --- | --- |
|
|
2621
|
+
| `Fix this.` | `Fix [specific failure]; done means [test command] passes.` |
|
|
2622
|
+
| No validation step | Require tests, smoke checks, typecheck, or explicit manual verification. |
|
|
2623
|
+
| Broad refactors | Constrain the run to the files needed for the objective. |
|
|
2624
|
+
| Letting a wrong stage continue | Redirect or interrupt as soon as the agent follows the wrong signal. |
|
|
2625
|
+
| Accepting unverified summaries | Ask for changed files, commands run, results, and remaining risks. |
|
|
2626
|
+
| Mixing investigation and implementation too early | Ask for root cause and proposed fix before code changes. |
|
|
2627
|
+
| Ignoring blocked stages | Answer directly with one decision and any constraints. |
|
|
2628
|
+
| Continuing stale runs | Pause, kill, or rerun with updated context. |
|
|
2629
|
+
| Reading every log | Inspect status, then stages, then only relevant details. |
|
|
2630
|
+
| Publishing without gates | Require release validation and explicit stop conditions. |
|
|
2631
|
+
|
|
2632
|
+
---
|
|
2633
|
+
|
|
2634
|
+
### Quick reference
|
|
2635
|
+
|
|
2636
|
+
Before starting a workflow, include:
|
|
2637
|
+
|
|
2638
|
+
- [ ] Objective
|
|
2639
|
+
- [ ] Context
|
|
2640
|
+
- [ ] Scope
|
|
2641
|
+
- [ ] Non-goals
|
|
2642
|
+
- [ ] Done criteria
|
|
2643
|
+
- [ ] Validation command
|
|
2644
|
+
- [ ] Reporting requirements
|
|
2645
|
+
- [ ] Stop conditions
|
|
2646
|
+
|
|
2647
|
+
Before accepting a workflow result, ask:
|
|
2648
|
+
|
|
2649
|
+
- [ ] What changed?
|
|
2650
|
+
- [ ] Why was this the right fix?
|
|
2651
|
+
- [ ] What evidence supports it?
|
|
2652
|
+
- [ ] Which commands were run?
|
|
2653
|
+
- [ ] What still might be risky?
|
|
2654
|
+
- [ ] Is anything blocked or unresolved?
|
|
2655
|
+
|
|
2656
|
+
The better the prompt defines the game, the better the agent can play it.
|