Claude Code for CrewAI — Workflow Guide
The Setup
You are building multi-agent AI systems with CrewAI, a Python framework for orchestrating autonomous AI agents that collaborate on complex tasks. CrewAI lets you define agents with roles, goals, and tools, then organize them into crews that execute tasks sequentially or in parallel. Claude Code can generate agent code, but it produces single-agent LangChain patterns instead of CrewAI’s multi-agent architecture.
What Claude Code Gets Wrong By Default
-
Creates a single LangChain agent. Claude writes one agent with multiple tools using LangChain’s
AgentExecutor. CrewAI uses multiple specialized agents, each with a specific role and backstory, coordinated by a Crew. -
Ignores the Agent-Task-Crew hierarchy. Claude puts all logic in one function. CrewAI has three core abstractions:
Agent(who),Task(what), andCrew(how they work together) — each defined separately with specific parameters. -
Hardcodes tool implementations. Claude writes tool functions inline. CrewAI has a
@tooldecorator and integrates with LangChain tools, but agents should have limited, role-specific tools — not every tool available to every agent. -
Skips process configuration. Claude runs tasks without defining execution order. CrewAI supports
sequential(tasks run in order) andhierarchical(a manager agent delegates) processes — the process type changes how agents collaborate.
The CLAUDE.md Configuration
# CrewAI Multi-Agent Project
## AI Framework
- Library: CrewAI (Python multi-agent orchestration)
- Agents: Specialized roles with goals and backstory
- Tasks: Specific assignments with expected output
- Crew: Orchestrates agents executing tasks
## CrewAI Rules
- Agent: role, goal, backstory, tools, llm
- Task: description, expected_output, agent
- Crew: agents, tasks, process (sequential/hierarchical)
- Tools: @tool decorator or LangChain tools
- Memory: enable crew memory for context sharing
- Delegation: allow_delegation=True for agent collaboration
- Output: task expected_output defines format
## Conventions
- One agent per domain role (researcher, writer, reviewer)
- Each agent gets only relevant tools
- Tasks reference specific agents
- Sequential process for linear workflows
- Hierarchical process for complex coordination
- Use verbose=True during development
- Environment variables for API keys (OPENAI_API_KEY)
Workflow Example
You want to build a content research and writing pipeline. Prompt Claude Code:
“Create a CrewAI crew with three agents: a Researcher that searches the web for information, a Writer that creates blog posts from research, and an Editor that reviews and improves the writing. Use sequential process so research happens first, then writing, then editing.”
Claude Code should create three Agent instances with distinct roles, goals, and backstories, three corresponding Task instances with expected_output fields, and a Crew with process=Process.sequential that executes research, writing, and editing in order.
Common Pitfalls
-
All agents using the same LLM. Claude configures every agent with GPT-4. Different agents may benefit from different models — the researcher might use a model with web access, the writer a creative model, and the editor a precise model. Set
llmper agent. -
Missing context passing between tasks. Claude creates independent tasks without output chaining. In CrewAI, set
context=[previous_task]on a task to pass the output of one task as context to the next — without this, agents lose information between steps. -
No error handling for agent failures. Claude runs the crew without try/except. LLM calls can fail, rate limit, or produce unexpected output. Wrap
crew.kickoff()with error handling and consider settingmax_iteron agents to prevent infinite loops.