Cook: A Simple CLI for Orchestrating AI Code Workflows

Hacker News introduces Cook, a CLI tool for managing workflow loops with AI like Claude Code, boosting automation in daily coding and enhancing developer productivity.

Cook: A Simple CLI for Orchestrating AI Code Workflows

Overview of Cook

Hacker News recently featured Cook, a CLI tool created by developer RJ Corwin, designed to simplify workflows for AI-driven code generation. It uses tokens to orchestrate tasks with models like Claude Code, Codex, and OpenCode, including work prompts, loop operators for iterations, and composition for parallel execution. This approach helps automate code changes efficiently, with support for up to several iterations and branching logic, as detailed in the original post.

How Cook Works

Cook breaks down complex AI-assisted workflows into basic building blocks. At its core, it parses three types of tokens: "work" for a single prompt that triggers an agent call, loop operators for repetition and review, and composition operators for running parallel tasks.

For instance, the "work" token handles a basic prompt, like cook "Add dark mode", which executes one AI call. Loop operators add control flow. The xN operator repeats work sequentially, passing output from one run to the next. A command like cook "Add dark mode" x3 runs the prompt three times in a row, allowing the AI to build on its previous results. This is useful for refining code iteratively.

The "review" operator introduces a quality gate. After work completes, it prompts a reviewer to check the output and decide whether to iterate or stop. For example: cook "Add dark mode" review 5 performs the work, then up to five review cycles, where each cycle might involve a gate prompt like "DONE if WCAG AA, else ITERATE." You can customize agents per step, such as cook "Add dark mode" review --work-agent codex --review-agent claude, which specifies different models for work and review phases.

Composition operators enable parallel processing. The vN or "race N" token runs multiple instances in isolated Git worktrees and resolves them. A simple example is cook "Add dark mode" v3 "least code wins", which executes three parallel versions and picks the one with the fewest lines of code. Operators chain left to right, so cook "Add dark mode" x3 review v3 first repeats the work three times with reviews, then races those results.

The "ralph" operator manages task lists, wrapping everything in an outer gate. For projects defined in a file like plan.md, cook "Work on next task in plan.md" ralph 5 "DONE if all tasks complete, else NEXT" advances through tasks, resetting iterations as needed. This setup ensures tasks progress only when they pass internal checks.

Overall, Cook's syntax is straightforward and composable, relying on your local Git setup for isolation, which minimizes conflicts during parallel runs.

Benefits for AI Automation in Development

For developers like me working on AI automation, Cook streamlines code generation tasks without reinventing the wheel. It integrates well with existing tools, letting you specify agents from providers like OpenAI or Anthropic, such as

openai-nodeopenai
View on GitHub →
for Node.js integrations.

One key advantage is handling iterations automatically, which saves time on repetitive fixes. In web development projects using React or Next.js, I can use Cook to prototype features quickly, like generating UI components with loops for refinement. The parallel composition feature also speeds up experimentation, allowing me to test variations and select the best outcome based on criteria.

However, it's not without trade-offs. Cook depends on specific AI models, so if you're using something like

claudeanthropic
View on GitHub →
, compatibility might vary, potentially limiting flexibility. There's also a learning curve for mastering the token syntax, and it could introduce complexity in shared repositories due to its use of Git worktrees. Despite this, I think it's a solid addition for Python or Rails projects involving AI, as it reduces boilerplate code for workflow management.

In practice, the ability to chain operators makes it versatile for tasks beyond code, like data processing in Node.js scripts. But weigh the pros against setup requirements, as it might not suit simple one-off uses.

Potential Drawbacks and Considerations

While Cook offers clear utility, certain aspects could hinder adoption. For starters, its reliance on external AI APIs means you're at the mercy of their availability and costs, which can escalate with frequent iterations.

From a technical standpoint, the isolated Git worktrees are a double-edged sword. They prevent conflicts during parallel runs, but merging results manually can be error-prone, especially in larger projects. If you're not comfortable with Git subcommands, this might add unnecessary friction.

Another concern is the lack of built-in error handling for failed AI calls, which could leave workflows hanging. In my experience with similar tools, debugging custom prompts takes trial and error. Still, the tool's modularity allows for extensions, potentially addressing these issues over time.

On the positive side, Cook's lightweight design—it's essentially a CLI wrapper—means low overhead compared to full frameworks like

langchainnpm package
View on npm →
. I prefer this approach for quick scripts in AI automation, as it keeps things focused without bloating your stack.

Frequently Asked Questions

What is Cook primarily used for? Cook is a CLI for automating AI-driven code workflows, focusing on iteration and parallel execution with models like Claude and Codex. It helps developers refine and test code changes efficiently.

How does Cook compare to other AI orchestration tools? Unlike more comprehensive libraries such as

langchainnpm package
View on npm →
, Cook is simpler and CLI-based, making it ideal for quick tasks but less suitable for complex, integrated systems due to its reliance on manual Git handling.

Is Cook suitable for beginners? It's accessible for developers familiar with CLIs and Git, but the token-based syntax might require some practice. Start with basic commands to build familiarity before tackling advanced features.

---

📖 Related articles

Need a consultation?

I help companies and startups build software, automate workflows, and integrate AI. Let's talk.

Get in touch
← Back to blog