Dynamic Workflows in Claude Code: When to Use Them (and When Not To)
Default Claude Code handles most tasks well. But complex, adversarial, or long-running tasks expose three failure modes. Dynamic workflows solve them by letting Claude coordinate a team.
TL;DR: Default Claude Code has three failure modes on complex tasks: laziness, self-preferential bias, and goal drift. Dynamic workflows solve them by letting Claude coordinate a team of subagents, each in its own context window. Costs more tokens but handles tasks that a single agent can’t.
Default Claude Code handles most tasks fine. Ask it to refactor a function, write a test, explain a module: it works. One agent, one context window, done.
But there’s a class of tasks where one agent working alone hits a wall. Complex, adversarial, or long-running. The longer Claude works on these, the more predictable the failures become.
Dynamic workflows solve this by letting Claude coordinate a team.
The Three Failure Modes of Single-Agent Claude Code
Agentic Laziness
Your 50-file security audit. Claude reviews 20 files and says “I’ve covered the critical areas.” It hasn’t: it stopped because it got tired, not because the job was done. Multi-part tasks that require sustained attention expose this hard.
Self-Preferential Bias
Ask Claude to verify its own code review. It approves its own work at a higher rate than it should: same blind spot any of us have when reviewing our own code. “Looks good to me” from the person who wrote it isn’t a real review.
Goal Drift
Over long sessions, Claude’s memory gets compressed. Each summarization step loses details: edge cases, “don’t do X” rules, specific requirements. By hour three, the agent is working toward a simplified version of the original goal, not the actual goal.
These failure modes don’t show up in simple tasks. They’re predictable consequences of one agent planning and executing in the same context window, indefinitely. (If you want to understand harness design more, I wrote about the 15 jobs every agent harness must do.)
What Dynamic Workflows Are
A dynamic workflow is a JavaScript file Claude Code writes on the fly. It defines a custom harness, a team structure, specifically built for your task.
The workflow can:
- Spawn subagents: separate Claude instances, each with their own clean context window and a focused job
- Choose which model to use. Sonnet for simple steps, Opus for complex ones
- Run agents in isolated worktrees: changes don’t conflict
- Resume if interrupted: quit mid-task, come back, Claude picks up where it left off
Standard JavaScript functions (JSON, Math, Array) are available for processing data between agents.
Think of it like moving from one chef doing everything to a brigade in a kitchen. One person can make a burger. But a well-coordinated team can run a busy dinner service without dropping tickets.
Six Patterns That Work
Fan-Out-and-Synthesize
Split a big task into many smaller pieces. Run an agent on each simultaneously. Collect and merge the results.
This is for tasks where each step is independent and benefits from its own clean context window: so agents don’t cross-contaminate each other’s reasoning.
Example prompt: “Sort 80 resumes for our backend role. Rank them, double-check the top 10, and prepare interview questions using the AskUserQuestion tool.”
Instead of stuffing all 80 resumes in one prompt (quality degrades, doesn’t fit in context), one agent handles each resume, then a merger combines rankings.
Adversarial Verification
For every agent that produces output, run a second agent to tear it apart against a rubric.
One agent writes the code review. A second agent’s job is to break it: find what was missed, challenge every conclusion. The second agent has no investment in the first agent’s work, so it doesn’t go easy.
Example prompt: “Review my security audit for the auth module. Use a separate agent to adversarially challenge every finding: play devil’s advocate.”
Tournament
Instead of dividing work, multiple agents compete on the same task using different approaches. A judge agent runs a pairwise tournament until there’s a clear winner.
Comparative judgment is more reliable than absolute scoring. Instead of asking “is this name good?” (hard), ask “is A better than B?” (easier, more consistent).
Example prompt: “Brainstorm 10 names for my CLI tool. Run them through a tournament to pick the top 3. Use separate agents for each brainstorming pass and a judge agent for the bracket.”
Loop Until Done
Keep spawning agents until a stop condition is met: no new findings, no more errors, or criteria satisfied. Not a fixed number of passes.
Example prompt: “Triage my support queue. Process tickets until the queue is empty. Classify each one, dedupe against existing tickets, attempt fixes where possible, escalate what needs a human.”
Pair this with Claude Code’s /loop command for continuous background processing.
Classify-and-Act
A classifier agent decides what type of task it is, then routes to different behavior based on that classification.
Example prompt: “Here’s a backlog of 200 tickets. Classify each as bug, feature, or question. Handle bugs by attempting a fix. Route features to the roadmap. Escalate questions to the right person.”
Generate-and-Filter
Generate a large set of candidates, then filter them by a rubric, verify them, dedupe duplicates, and return only the highest quality.
Example prompt: “Mine my last 50 Claude Code sessions for corrections I keep making. Cluster them with parallel agents, adversarially verify each cluster (would this rule have prevented a real mistake?), distill survivors into CLAUDE.md rules.”
When to Use It
The honest heuristic: if one agent can do it in under 5 minutes, it probably doesn’t need a workflow.
Dynamic workflows shine for:
- Migrations and refactors: rename User to Account across 200 files, one agent per file, adversarial review on each change, merge
- Deep research: fan out web searches, verify claims, synthesize a cited report (Claude Code’s built-in
/deep-researchskill uses this) - Deep verification: fact-check every claim in a document against the codebase
- Sorting at scale: pairwise comparison tournament for ranking 1000 items
- Root-cause investigation: separate agents for logs, files, data, each generating independent hypotheses
- Triage at scale: continuous queue processing with
/loop - Memory and rule adherence: mine sessions for corrections, verify each as a real pattern, distill into CLAUDE.md
When Not to Use It
Don’t reach for a workflow when:
- It’s a simple coding task: one agent, one context window, done in minutes
- The answer is straightforward and verifiable in one pass
- You need a quick one-off
(For simpler multi-step workflows that don’t need the full dynamic harness, AI agent multi-step workflows are a lighter alternative.)
Workflows are new. Best practices are still developing. They use more tokens. A panel of 5 reviewers for a one-line bash script is overkill. Match the tooling to the task.
Practical Tips
Trigger word: Say “ultracode” when you want Claude Code to create a workflow: it recognizes it and jumps into workflow mode.
Pair with /goal: Set a hard completion requirement so Claude doesn’t stop early. “Review all 50 files: don’t stop until every one is covered.”
Pair with /loop: For triage or research that needs to run continuously, combine with /loop and set intervals.
Set token budgets: “Use 10k tokens maximum”: this caps spending on the task.
Save and share: Press “s” in the workflow menu to save. Distribute workflows as skills by putting the .js files in the skill directory and referencing them in SKILL.md. Prompt Claude to treat them as templates, not scripts to run verbatim.
The Decision Framework
| Task | Use a Workflow? |
|---|---|
| Write a function, add a test | No |
| Explain a module | No |
| Refactor 5 files | Probably not |
| Rename a model across 200 files | Yes |
| Security audit of 50 files | Yes |
| Research a topic, write a cited report | Yes |
| Triage a 500-item backlog | Yes |
| Fact-check every claim in a document | Yes |
| Sort 100 support tickets by severity | Yes |
The test: does this task benefit from multiple focused perspectives, or will one agent doing it all produce the same quality faster?
The Bottom Line
Default Claude Code = one smart person working alone. Dynamic workflows = one project manager coordinating a team of specialists.
The team approach costs more tokens and takes more setup. But for complex, adversarial, or long-running tasks, the quality gains are real. It’s the difference between a solo security audit and a red team actively trying to break each other’s findings.
Try it on your next hard task. Start with “ultracode” and describe what you need. See what kind of team Claude assembles.
Key Takeaways
- Default Claude Code has three predictable failure modes on complex tasks: laziness, self-preferential bias, and goal drift
- Dynamic workflows let Claude write a custom harness that spawns subagents with focused, isolated goals
- Six high-value patterns: fan-out-and-synthesize, adversarial verification, tournament, loop-until-done, classify-and-act, generate-and-filter
- One agent can do it in under 5 minutes? Don’t use a workflow: match the tooling to the task
- Use “ultracode” as a trigger word, pair with
/goaland/loopfor maximum effect
This article was published on Agentic Up (https://agenticup.dev): practical guides for developers and founders building with AI agents. Reach me at [email protected].
Related: The Proactive Agent Problem: what Claude Fable’s proactivity reveals about agent design scope control.
Reworked’s coverage of Claude Code dynamic workflows details the multi-agent coordination feature Anthropic released.
Reworked’s coverage of Claude Code dynamic workflows details Anthropic’s multi-agent coordination feature.
Related Posts
- Cursor vs Claude Code vs Copilot. A six-month comparison of the three major AI coding tools on real development tasks
- Best AI coding agents in 2026. Comparing Claude Code, Cursor, Copilot, and OpenCode for development workflows
- Build a state machine for your AI agent in a weekend. The 6-state FSM that provides the foundation for agent loop orchestration
- How AI coding agents use your SDK. Understanding the context assembly and tool selection process behind coding agents