How to Easily Create AI Agent Workflows

The future of AI-assisted development isn’t about using smarter tools, it’s about orchestrating AI into custom workflows that match exactly how you work.

In my previous post I shared how we built a TDD coding agent in just 4 hours using a surprisingly simple architecture. The real revelation wasn’t the TDD automation itself, but how accessible it is for any developer to create specialized AI workflows. No complex frameworks, no deep AI knowledge required, just clear thinking about your process.

The Architecture That Changes Everything

The pattern we discovered is almost embarrassingly simple:

# Your workflow orchestrator
while ! is_task_complete; do
 ai_output=$(claude -p "Do step X with context: $current_state")
 update_state "$ai_output"
 check_quality_gates
done

Bash handles the workflow logic. CLI AI agents handle the execution. That’s it.

This simplicity is a feature, not a limitation. Bash is universal, reliable, and perfect for coordinating other tools. CLI agents like Claude Code, GitHub Copilot CLI, or even custom API wrappers become composable building blocks you can orchestrate into any process you can imagine.

The separation of concerns is clean: your script manages the workflow, timing, decision points, and quality gates. The AI handles the creative, generative work within those constraints.

Workflow Patterns That Actually Work

The Iterative Refinement Pattern

Perfect for creative tasks that benefit from multiple passes:

# Code review improvements
for iteration in {1..3}; do
 feedback=$(claude -p "Review this code and suggest improvements: $(cat $file)")
 improvements=$(claude -p "Apply these improvements: $feedback")
 echo "$improvements" > $file
 run_tests || break
done

The Human-in-the-Loop Pattern

For decisions that need human judgment:

# Architecture decision workflow
options=$(claude -p "Generate 3 architecture options for: $requirements")
echo "$options"
read -p "Which option? (1-3): " choice
implementation=$(claude -p "Implement option $choice with details")

The Evolutionary Tree Pattern

Generate multiple solution branches and evolve the best ones:

# Solution exploration
mkdir solutions
for approach in "functional" "oop" "reactive"; do
 solution=$(claude -p "Solve $problem using $approach paradigm")
 echo "$solution" > "solutions/$approach.js"
 score=$(evaluate_solution "solutions/$approach.js")
 echo "$approach: $score" >> scores.txt
done

best_approach=$(sort -nr scores.txt | head -1 | cut -d: -f1)
refine_solution "solutions/$best_approach.js"

The Pipeline Pattern

Sequential processing with validation at each stage:

# Documentation pipeline
outline=$(claude -p "Create outline for: $topic")
validate_outline "$outline" || exit 1

draft=$(claude -p "Write draft from outline: $outline")
check_draft_quality "$draft" || exit 1

final=$(claude -p "Polish and finalize: $draft")
publish "$final"

Beyond Coding: Universal Workflow Automation

The bash + CLI agent pattern extends far beyond software development:

Content Creation Workflows

  • Research → Outline → Draft → Edit → Publish pipelines

  • Multi-format content generation (blog → social → newsletter)

  • SEO optimization and cross-platform adaptation

Business Process Automation

  • Customer support ticket routing and initial responses

  • Contract analysis and risk assessment workflows

  • Competitive analysis and market research pipelines

Data Analysis Workflows

  • Automated EDA (Exploratory Data Analysis) → hypothesis generation → validation

  • Multi-model comparison and ensemble creation

  • Report generation with human checkpoints

Creative Workflows

  • Brainstorming → concept development → iteration → finalization

  • A/B testing content variations

  • Multi-perspective analysis (technical, business, user experience)

The key insight is that any process with clear steps, decision points, and quality criteria can be automated while keeping humans in control of the important decisions.

Workflow Orchestration Patterns

State Management: Track progress through files, environment variables, or simple databases:

echo "step:outline,status:complete,quality:8/10" >> workflow_state.log

Quality Gates: Build in validation at each step:

validate_step() {
 local output="$1"
 local criteria="$2"
 claude -p "Does this output meet criteria '$criteria'? Answer YES/NO: $output"
}

Branching Logic: Handle different scenarios:

if complexity_score > 7; then
 use_advanced_workflow
else
 use_simple_workflow
fi

Error Recovery: Graceful handling of AI failures:

retry_count=0
while [ $retry_count -lt 3 ]; do
 result=$(claude -p "$prompt") && break
 ((retry_count++))
 prompt="$prompt. Previous attempt failed, try a different approach."
done

The Future: Dynamic Workflow Generation

Here’s where this gets really interesting. What if we could dynamically generate workflows based on specific problems?

Imagine an AI service that works like this:

$ workflow-ai "I need to migrate a legacy codebase to microservices"

Generated workflow: legacy-to-microservices-v1.sh
Steps: analyze → identify-boundaries → extract-services → test-integration → deploy
Estimated time: 2-3 days
Human checkpoints: architecture-review, integration-testing, deployment-approval

Run workflow? (y/n)

The service would:

  • Analyze the problem and identify the type of workflow needed

  • Generate a custom bash script with appropriate AI agent calls

  • Include relevant quality gates and human checkpoints

  • Adapt based on your specific context (tech stack, team size, constraints)

This isn’t science fiction, it’s just workflow orchestration applied to workflow creation itself. The same bash + CLI agent pattern that automates development tasks can automate the creation of automation.

Getting Started: Your First Custom Workflow

Pick a repetitive process you do regularly. Break it into clear steps. Identify where AI can help and where you need to stay in control. Then start simple:

#!/bin/bash
# my-first-workflow.sh

echo "Starting custom workflow..."
step1_output=$(claude -p "Your first AI step")
echo "Review this output: $step1_output"
read -p "Continue? (y/n): " continue

if [ "$continue" = "y" ]; then
 step2_output=$(claude -p "Second step using: $step1_output")
 echo "Final result: $step2_output"
fi

The barrier to entry is remarkably low. If you can write a bash script and call a CLI tool, you can build AI workflows that match exactly how you think and work.

The Bigger Picture

We’re moving from an era of “AI tools” to “AI orchestration.” Instead of adapting our processes to fit existing tools, we can now create tools that fit our processes. The TDD agent was just the beginning, a proof that with simple architectures and clear thinking, any developer can become a workflow automation expert.

The most powerful AI systems of the future might not be the ones with the most sophisticated models, but the ones that are most easily orchestrated into the specific workflows that solve real problems.

What workflow will you automate first?

The complete TDD agent code and architecture details are available in the original blog post. Start there, then build your own.

© 2025 Jaksa Vuckovic. Built with SvelteKit