Agent skill
evolving-workflow
Templates for building parallel AI agent workflows in MoonBit. Includes patterns for simple fan-out processing and multi-phase orchestration with automatic retry and validation.
Install this agent skill to your Project
npx add-skill https://github.com/moonbit-community/codex-sdk/tree/main/skills/evolving-workflow
SKILL.md
Evolving Workflow
Templates for building parallel AI agent workflows using the Codex SDK.
Templates
| Template | Pattern | Description |
|---|---|---|
| parallel_tasks | Fan-out | Process items in parallel with bounded concurrency |
| multi_phase | Fan-out → Sequential → Fan-out | Three-phase workflow with intermediate planning |
Project Structure
your_workflow/
├── main.mbt # Orchestration (usually unchanged)
├── moon.pkg.json
└── app/
├── job.mbt # TaskHandle lifecycle (customize this)
├── args.mbt # CLI parsing
└── moon.pkg.json
main.mbt: Orchestration
The main file orchestrates: initialize → spawn parallel agents → summarize results.
async fn main {
let config = @app.initialize() catch { ... }
let codex = @codex.Codex::new()
let results = @shared.for_all_tasks(
config.items,
async fn(idx, _) {
let handle = config.task_start(idx)
try {
let thread = codex.start_thread(...)
@async.retry(@async.RetryMethod::Immediate, fn() {
let prompt = handle.prompt()
let response = thread.run(prompt)
handle.validate(response.final_response)
handle.finish()
}, max_retry=3)
} catch { e => handle.error(e) }
},
parallelism=config.parallelism,
)
config.summarize(results)
}
For multi-phase, the pattern chains three phases: summarize (fan-out) → plan (sequential) → process (fan-out).
Customization
Edit app/job.mbt to customize:
| Function | What to change |
|---|---|
discover_items() |
How to find targets to process |
read_item_content() |
What data to load for prompts |
prompt() |
Your task instructions |
validate() |
Success criteria (raise to retry) |
finish() |
How to save results |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
codex-parallel-subagents
[DEPRECATED] Run multiple AI agent threads in parallel with bounded concurrency. Use evolving-workflow instead.
mbt-wasip1-tools
Build small MoonBit WASIp1 CLI tools using the peter-jerry-ye/wasi library, focused on simple read/write tasks (echo, cat, wc, simple file ops). Use when creating or updating CLI examples, scripts, or skills for this repo.
portable-safe-skills
Create portable, safe Codex skills focused on file or I/O operations under WASIp1 constraints. Use when authoring skills that must be portable across environments and avoid unsafe assumptions about paths, preopens, or stdio.
obsidian-vault
Search, create, and manage notes in the Obsidian vault with wikilinks and index notes. Use when user wants to find, create, or organize notes in Obsidian.
setup-pre-commit
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
handoff
Compact the current conversation into a handoff document for another agent to pick up.
Didn't find tool you were looking for?