# Crewai

> CrewAI multi-agent framework -- Agent/Task/Crew classes, role-based design, sequential/hierarchical processes, YAML config, memory, and delegation patterns.

- Skill: `leolin990405/crewai` (Agent Skill)
- Install (CLI): `npx get-skill add leolin990405/crewai`
- Raw SKILL.md: https://api.skillmd.com/api/skills/leolin990405/crewai/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: LeoLin990405 (https://skillmd.com/u/leolin990405)
- Updated: 2026-11-11
- Page: https://skillmd.com/skills/leolin990405/crewai

---


# CrewAI

> Multi-agent orchestration with role-based design. Agents collaborate on tasks via sequential or hierarchical processes.

## Core Concepts

```python
from crewai import Agent, Task, Crew, Process

researcher = Agent(
    role="Senior Researcher",
    goal="Find comprehensive information on {topic}",
    backstory="Expert researcher with 10 years experience.",
    tools=[search_tool, web_scraper],
    verbose=True,
    allow_delegation=True,
)

writer = Agent(
    role="Technical Writer",
    goal="Write clear, engaging content based on research",
    backstory="Experienced technical writer specializing in developer docs.",
    verbose=True,
)

research_task = Task(
    description="Research {topic} thoroughly. Cover architecture, best practices, pitfalls.",
    expected_output="Comprehensive research report in markdown",
    agent=researcher,
)

writing_task = Task(
    description="Write a technical guide based on the research.",
    expected_output="Well-structured technical guide",
    agent=writer,
    context=[research_task],  # Receives output from research_task
)

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    process=Process.sequential,  # or Process.hierarchical
    verbose=True,
)

result = crew.kickoff(inputs={"topic": "MCP Protocol"})
```

## Process Types

| Process | Description |
|---------|-------------|
| `sequential` | Tasks execute in order, output chains to next |
| `hierarchical` | Manager agent delegates to team members |

### Hierarchical with Manager
```python
crew = Crew(
    agents=[researcher, writer, reviewer],
    tasks=[research_task, writing_task, review_task],
    process=Process.hierarchical,
    manager_llm=ChatOpenAI(model="gpt-4o"),
)
```

## YAML Configuration

### agents.yaml
```yaml
researcher:
  role: Senior Researcher
  goal: Find comprehensive information on {topic}
  backstory: Expert researcher with deep domain knowledge.

writer:
  role: Technical Writer
  goal: Write clear content based on research findings
  backstory: Experienced writer specializing in tech docs.
```

### tasks.yaml
```yaml
research_task:
  description: Research {topic} covering architecture, patterns, and pitfalls.
  expected_output: Detailed research report in markdown.
  agent: researcher

writing_task:
  description: Create a technical guide from research findings.
  expected_output: Publication-ready technical guide.
  agent: writer
  context:
    - research_task
```

## Memory System

```python
crew = Crew(
    agents=[...],
    tasks=[...],
    memory=True,           # Enable memory
    embedder={
        "provider": "openai",
        "config": {"model": "text-embedding-3-small"}
    }
)
```

Three types: short-term (conversation), long-term (cross-session), entity (knowledge about entities).

## Delegation

```python
agent = Agent(
    role="Project Manager",
    allow_delegation=True,   # Can delegate subtasks to other agents
    tools=[...]
)
```

When enabled, agent can ask other crew members to help with subtasks.

## Sources

- [CrewAI Docs](https://docs.crewai.com/)
- [CrewAI GitHub](https://github.com/crewAIInc/crewAI)

