What is @crew?
@crew decorates exactly one factory method per @CrewBase class. That method stitches together the auto-discovered self.agents and self.tasks lists, picks a Process (sequential, hierarchical, consensual), and returns a fully configured Crew instance. It is the choke point for runtime concerns: verbose logging, memory backends, embedder dicts, manager_llm for hierarchical flows, planning flags, and tracing hooks that should apply to every kickoff originating from the scaffold.
Keeping assembly here avoids drift between CLI-generated layouts and bespoke scripts — teammates know to open the @crew method when they need to understand how YAML personas become executable graphs. You can still inject pure-Python objects (custom callbacks, dynamic tool filters) alongside the declarative lists as long as you stay consistent with Crew constructor expectations for your CrewAI version.
Because main.py typically calls MyProjectCrew().crew().kickoff(...), treat the method idempotently: constructing a fresh Crew each call is normal, but expensive singletons (remote clients) belong in @before_kickoff or lazy properties to avoid reconnect storms.
When to Use
Exactly once per CrewBase class.
Use Cases
- • Crew assembly
- • Process selection
- • Wiring callbacks and memory
Key Features
- ✓ Auto-collects @agent / @task methods
- ✓ Single source of truth for Crew config
When NOT to Use
If you need multiple crews per file — split them into separate CrewBase classes.
Notes
Process choice
Hierarchical crews need a capable manager_llm and budget for extra LLM rounds. Sequential remains the default for linear ETL-style pipelines.
Memory and embedders
Turning memory=True without configuring embedders falls back to framework defaults that may not match your knowledge_sources. Align configs to avoid double billing.
Multiple @crew mistakes
Only one @crew method is supported per class. If you truly need variants, use subclasses or pass flags through inputs instead of duplicating decorators.
Import
from crewai.project import crew
How to Apply
@crew
def crew(self) -> Crew:
return Crew(agents=self.agents, tasks=self.tasks, process=Process.sequential)
What It Enables
- ✓ Single-entry crew assembly
- ✓ Top-level configuration in one place
Code Examples
Sequential crew
@crew
def crew(self) -> Crew:
return Crew(agents=self.agents, tasks=self.tasks, process=Process.sequential, verbose=True)
Hierarchical crew with manager
@crew
def crew(self) -> Crew:
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.hierarchical,
manager_llm='openai/gpt-4o-mini',
memory=True,
)
Lean tracing defaults
@crew
def crew(self) -> Crew:
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.sequential,
step_callback=self.log_step,
verbose=False,
)
Integration Patterns
Called by main.py via MyCrewClass().crew().kickoff(inputs=...)
Common Mistakes
❌ Manually building agents/tasks lists inside @crew
✅ Rely on self.agents and self.tasks populated by the decorators.
Related: Task class reference, Agent class reference, and the first Crew tutorial.
@crew FAQ
What is @crew in CrewAI?
Marks the method that returns the Crew object — the assembled agents + tasks + process. @crew decorates exactly one factory method per @CrewBase class. That method stitches together the auto-discovered self.agents and self.tasks lists, picks a Process (sequential, hierarchical, consensual), and returns a fully configured Crew instance. It is the choke point for runtime concerns: verbose logging, memory backends, embedder dicts, manager_llm for hierarchical flows, planning flags, and tracing hooks that should apply to every kickoff originating from the scaffold. …
Which module defines the CrewAI decorator @crew?
DevShelfHub maps @crew to Python module crewai.project. Pin your installed crewai version and match imports to the import snippet on this page.
When should I use @crew?
Exactly once per CrewBase class.
When should I avoid @crew?
If you need multiple crews per file — split them into separate CrewBase classes.
How do I apply @crew in Python?
@crew def crew(self) -> Crew: return Crew(agents=self.agents, tasks=self.tasks, process=Process.sequential)
Where can I explore more CrewAI API reference pages?
Open the CrewAI API reference index on DevShelfHub to search classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.