Dynamic Workflows in Claude Code clearly explained

... PLUS: [Hands-On] Build a Brand Intelligence Agent With Scrapingdog

In today’s newsletter:

  • [Hands-On] Build a Brand Intelligence Agent With Scrapingdog

  • Claude Code Can Now Write Its Own Harness

Reading time: 5 minutes.

Tracking what the internet says about a brand manually means checking search results and social platforms separately, piecing together a picture from scattered sources. By the time you finish, half the data is stale.

This project automates that entirely. You type a brand name, and the agent collects raw data across four platforms and returns a structured intelligence brief in about a minute.

Scrapingdog handles every piece of the data collection. DeepSeek V4 Flash handles the analysis. Complete setup and implementation available on GitHub.

How the Data Layer Works

All the data collection lives in tools.py. Scrapingdog exposes four endpoints the agent uses directly:

Each platform analyzer calls a different combination of these:

  • Web: Google SERP (/google) for reputation searches + Google News (/google_news) for recent coverage

  • YouTube: YouTube search (/youtube) for brand mentions and reviews

  • Twitter/X: Google SERP filtered with site:twitter.com to surface public mentions

  • LinkedIn: Google SERP filtered with site:linkedin.com for professional presence and company activity

The Twitter and LinkedIn scrapers use a clean pattern: instead of authenticating directly with those platforms, they query Google SERP with a site: filter. Scrapingdog handles the rendering and anti-bot layer so the agent gets clean, structured results.

Collecting the Raw Data

Each analyzer function calls Scrapingdog first, then formats the results for the LLM. Here's the web analyzer as an example:

One LLM Call Per Platform

Once the raw data is formatted, each analyzer makes a single LLM call through to produce a structured markdown report.

The model receives raw scraped data and a prompt asking for specific sections: sentiment overview, key themes, notable mentions, and a brand health assessment.

Run All Four Platforms

run_brand_monitor in main.py executes the four analyzers sequentially and returns a dict of reports:

Launch the App

We used “Scrapingdog” as the test brand. Here's what came back across the four channels:

Web: Positive sentiment. The standout mention was a SerpAPI vs Serper vs Scrapingdog comparison that called out "blazing-fast response times, 100% success rate, and ridiculously affordable pricing."

Twitter/X: 50% positive, 50% neutral, zero negative. Startup founders and automation builders mention it in the context of n8n workflows, Google AI Overview extraction, and side projects.

LinkedIn: Active educational posting cadence with API walkthroughs and product announcements.

YouTube: Primarily founder-led tutorial content focused on specific platforms (Amazon, Google Maps, YouTube).

Claude Code just got dynamic workflows. Instead of one Claude handling a complex task in a single context window, it can now write a custom orchestration harness on the fly, spawn multiple Claude instances to work in parallel, and coordinate their outputs.

Why This Exists

Single-context-window agents hit three specific failure modes on long, complex tasks:

Agentic laziness. Claude stops before finishing and declares the job done. You asked it to review 50 items. It reviewed 20 and called it complete.

Self-preferential bias. When asked to verify its own work, Claude tends to agree with itself. An independent agent checking the same output doesn't have that bias.

Goal drift. Across many turns, especially after context compaction, the original objective blurs. Constraints like "don't do X" quietly disappear from the working context.

Dynamic workflows solve all three by spinning up separate Claude instances with their own context windows and focused, isolated goals.

How It Works

When you trigger a workflow, Claude writes a JavaScript file that coordinates subagents. Each subagent can run with a different model, in its own isolated worktree, with its own context. The orchestrator manages the logic, handles the results, and knows when the task is done.

If a workflow is interrupted, resuming the session picks up exactly where it left off.

To trigger one, either ask Claude directly to "use a workflow" or use the keyword ultracode.

The Patterns Worth Knowing

Fan-out-and-synthesize. Split a task into many smaller pieces, run one agent per piece, then merge the results. Best for tasks with a large number of parallel steps where cross-contamination between steps would cause problems.

Adversarial verification. For every agent that produces output, run a separate agent whose only job is to check that output against a rubric. Eliminates self-preferential bias structurally.

Tournament. Spawn N agents that each attempt the same task using different approaches. A judge agent picks the winner through pairwise comparison. More reliable than asking one agent to self-evaluate.

Loop until done. For tasks where the amount of work is unknown upfront, keep spawning agents until a stop condition is met: no new findings, no more errors, or a rubric is satisfied.

Where It's Actually Useful

The use cases that benefit most are tasks with large amounts of parallel work, or tasks where independent verification matters more than speed.

  • Migrations and refactors: The Bun team rewrote their codebase from Zig to Rust using workflows. Each callsite gets its own agent fix, another agent adversarially reviews it, and passing fixes get merged.

  • Deep research: Fan out web searches, fetch sources in parallel, verify claims independently, synthesize a cited report.

  • Root-cause investigation: Spawn separate agents for logs, files, and data to generate hypotheses from disjoint evidence. Each hypothesis then faces a panel of verifiers rather than being judged by the same agent that generated it.

  • Triage at scale: Classify, dedupe, and act on support queues, bug reports, or backlogs too large for humans to fully process.

Practical Notes

Workflows use significantly more tokens than standard Claude Code. Not every task needs one. Before creating a workflow, ask whether the task actually needs parallel compute or independent verification.

Pair workflows with /goal to set a hard completion condition and /loop to run triage or research workflows on a schedule.

Set explicit token budgets by prompting: "use 10k tokens." Workflows respect this cap.

That’s all for today. Thank you for reading today’s edition. See you in the next issue with more AI Engineering insights.

PS: We curate this AI Engineering content for free, and your support means everything. If you find value in what you read, consider sharing it with a friend or two.

Your feedback is valuable: If there’s a topic you’re stuck on or curious about, reply to this email. We’re building this for you, and your feedback helps shape what we send.

WORK WITH US

Looking to promote your company, product, or service to 200K+ AI developers? Get in touch today by replying to this email.