Agent Engineering / Skills & Reusable Procedures
Structure multi-step workflows inside skills
Routing
Section titled “Routing”- MUST make
SKILL.mda router when a skill handles more than one kind of task: a short decision list (“Uploading a document? →workflows/upload.md. Deleting? →workflows/delete.md”) and nothing the router itself does not need. - MUST give each workflow its own file when workflows are long or branch, kept one level deep from
SKILL.md(for exampleworkflows/*.md,references/*.md). Deeply chained references are often only partly read. - MUST state, in each branch of the router, exactly which file to read and when, so the agent loads one workflow, not all of them.
Writing a workflow
Section titled “Writing a workflow”-
MUST write each workflow as numbered, sequential steps, each with its action, its input, its output, and how to tell it succeeded.
-
MUST start long workflows with a checklist the agent copies into its working notes or task list and ticks off, so it does not skip steps — especially validation steps.
-
MUST match how prescriptive each step is to how fragile it is:
Step is Write it as Judgement with several valid approaches (review, summarise) Plain guidance and criteria A preferred pattern with some variation Template, pseudocode or a parameterised script Fragile, order-dependent or destructive (migrate, delete, file a record) An exact command to run unchanged: “Run bun scripts/migrate.ts --verify --backup. Do not change the command.” -
MUST say whether a script is to be run (the usual case; only its output enters context) or read as a reference for its logic.
Feedback loops and gates
Section titled “Feedback loops and gates”- MUST add a validate → fix → repeat loop after any step whose output can be checked (a validator script, schema, test, or a checklist file), and proceed only when validation passes.
- MUST use plan → validate → execute → verify for batch, destructive or high-stakes steps: the agent writes the intended changes to a plan file (for example
changes.json), a script validates it, a person approves it where the action cannot be undone, then the agent executes and verifies. - MUST make validation errors specific and actionable (“Tag
Finance/Tax/2025not in taxonomy; nearest:Finance/Tax/FY2025”), so the fix step has something to act on. - SHOULD write intermediate results to files (plans, mappings, extracted fields) so they can be checked, diffed and re-run without repeating earlier steps.
- SHOULD end every workflow with a verification step against the original request and a short report: what was done, what was checked, what was skipped (BP-0002).
Maintaining
Section titled “Maintaining”- SHOULD add a table of contents to any workflow or reference file over about 100 lines.
- SHOULD test each workflow on real tasks, including a run where validation fails, and record changes to workflows in the skill’s change log (BP-0018).
When to apply
Section titled “When to apply”Any skill whose job takes more than a few steps, has more than one task type, or includes steps that change or delete things.
Examples
Section titled “Examples”records-manager/├── SKILL.md # router: which workflow for which task├── workflows/│ ├── upload.md # checklist + steps + validate loop│ ├── retag.md│ └── delete.md # plan → validate → approve → execute → verify├── references/│ └── taxonomy.md # read when choosing tags└── scripts/ ├── validate_tags.ts # run; prints specific errors └── plan_delete.ts # run; writes delete-plan.jsonSKILL.md router:
## Choose the workflow- Uploading or filing a document → read `workflows/upload.md`- Changing tags on existing documents → read `workflows/retag.md`- Deleting or applying retention → read `workflows/delete.md` (never delete without its approval step)workflows/delete.md (excerpt):
Copy this checklist and tick it off:- [ ] 1. Find candidates: run `bun scripts/plan_delete.ts --query "<q>"` → writes `delete-plan.json`- [ ] 2. Validate: run `bun scripts/validate_plan.ts delete-plan.json`; fix and repeat until it passes- [ ] 3. Show the plan to the user; stop until they approve- [ ] 4. Execute: run `bun scripts/apply_plan.ts delete-plan.json` (do not change the command)- [ ] 5. Verify: run `bun scripts/verify_plan.ts delete-plan.json`; report what was deletedAnti-patterns
Section titled “Anti-patterns”- One
SKILL.mdholding every workflow, loaded in full for every task. - “Validate the output” with no validator, criteria or stop condition.
- Destructive steps the agent may improvise (“delete the old records”).
- Workflows that chain references three files deep.
- Validators that only say “invalid”.
Checklist
Section titled “Checklist”-
SKILL.mdroutes to one workflow per task type, one level deep - Numbered steps with outputs and success checks; copyable checklist
- Prescriptiveness matched to fragility; run-vs-read stated for scripts
- Validate-fix-repeat after checkable steps; plan-validate-execute for risky ones
- Specific validation errors; intermediate results in files
- Final verification and report; workflows tested including failures