Skip to main content

Claude Code Workflows: A Complete Guide for Developers

Patrick Roebuck
4 min read

Claude Code workflows turn your AI assistant into a specialized, repeatable developer tool. Instead of typing the same long prompts repeatedly, a workflow packages instructions, context collection, and output formatting into a single command.

This guide covers everything you need to know: what workflows are, how to run built-in ones, how Attune AI extends them, and how to build your own.

What Is a Claude Code Workflow?

A workflow is a structured sequence of steps that:

  1. Collects context from your codebase (files, git history, tests)
  2. Builds a prompt with that context baked in
  3. Calls Claude with the optimized prompt
  4. Formats the output for your use case

Instead of manually copying files into a chat, a workflow handles all of that for you. The result is a consistent, repeatable process that you can run from the CLI.

Attune AI's 10 Workflows

Attune AI ships with 10 workflows covering the most common developer tasks:

# List all available workflows
attune workflow list
WorkflowCommandWhat It Does
Security Auditattune workflow run securityOWASP scan with fix recommendations
Bug Predictionattune workflow run bug-predictFlag risky code patterns
Code Reviewattune workflow run code-reviewQuality + best practices check
Performance Auditattune workflow run perf-auditBottleneck identification
Test Generationattune workflow run test-genGenerate pytest tests
Documentationattune workflow run doc-genGenerate API docs + READMEs
Release Prepattune workflow run release-prepPre-release quality gate

Running Your First Workflow

# Install Attune AI
pip install attune-ai

# Set your Anthropic API key
export ANTHROPIC_API_KEY=your_key_here

# Run a security audit on your source directory
attune workflow run security --input '{"path": "src/"}'

The output is a prioritized list of findings with severity levels and fix suggestions.

How Workflows Use Prompt Caching

Attune AI automatically enables Anthropic's prompt caching for all workflows. When you run multiple workflows on the same codebase in a session, the codebase context is cached after the first call.

This means:

  • First workflow run: full token cost
  • Subsequent runs (within 5 min): up to 90% cheaper
# Run two workflows in quick succession — second one hits cache
attune workflow run security --input '{"path": "src/"}'
attune workflow run code-review --input '{"path": "src/"}'

Multi-Tier Model Routing

Attune AI routes each workflow to the optimal Claude model tier:

from attune.models import Tier

# Cheap tier: fast, low-cost for simple tasks
# Capable tier: balanced for most dev tasks
# Premium tier: maximum capability for complex analysis

Workflows automatically select the appropriate tier. You can override:

from attune.workflows import SecurityAuditWorkflow, Tier

workflow = SecurityAuditWorkflow(tier=Tier.PREMIUM)
result = await workflow.execute({"path": "src/"})

Building a Custom Workflow

from attune.workflows import BaseWorkflow
from attune.models import Tier

class DependencyAnalysisWorkflow(BaseWorkflow):
    """Analyze dependencies for outdated packages and CVEs."""

    name = "dependency-analysis"
    tier = Tier.CHEAP

    def build_prompt(self, input_data: dict) -> str:
        requirements = self._read_file("requirements.txt")
        return f"""Analyze these Python dependencies for:
1. Known CVEs (check against NVD)
2. Packages with newer major versions
3. Unmaintained packages (no releases in 2+ years)

requirements.txt:
{requirements}

Return a prioritized list of actions, highest risk first."""

    def format_output(self, raw: str) -> dict:
        return {"analysis": raw, "source": "requirements.txt"}

Run it:

attune workflow run dependency-analysis

Chaining Workflows with Multi-Agent Teams

You can compose workflows into multi-agent pipelines:

from attune.orchestration import WorkflowComposer

# Run security audit → code review → test generation in sequence
pipeline = WorkflowComposer([
    "security",
    "code-review",
    "test-gen",
])

results = await pipeline.execute({"path": "src/"})

Or run them in parallel:

from attune.orchestration import ParallelWorkflowRunner

runner = ParallelWorkflowRunner(["security", "perf-audit"])
results = await runner.execute({"path": "src/"})

Workflow Output Formats

All workflows support structured JSON output for CI/CD integration:

# JSON output for scripts and CI
attune workflow run security --json

# Save to file
attune workflow run security --output security-report.json

Next Steps

Related Articles