Skip to content

Your First Crew: The Quickstart Guide

Theory is essential, but nothing beats running code. In this chapter, we will build a simple crew that researches a technology topic and writes a short blog post about it. We will use the CrewAI CLI to generate the project structure.

Open your terminal and run the create command. We will name our project latest_ai_news.

Terminal window
crewai create crew latest_ai_news

The CLI will ask you to select a provider (like OpenAI) and a model. Once completed, navigate into your new folder:

Terminal window
cd latest_ai_news

CrewAI encourages a clean separation of concerns. Here is the layout of the generated project:

latest_ai_news/
├── src/
│ └── latest_ai_news/
│ ├── config/
│ │ ├── agents.yaml <-- Define your Agents' personas here
│ │ └── tasks.yaml <-- Define the Tasks here
│ ├── crew.py <-- The logic binding everything together
│ └── main.py <-- Entry point to run the crew
├── .env <-- API Keys (DON'T commit this)
└── pyproject.toml <-- Dependencies

Open src/latest_ai_news/config/agents.yaml. This file allows you to define agents using natural language, keeping your code clean. Let’s define a Researcher and a Writer.

src/latest_ai_news/config/agents.yaml
researcher:
role: >
Senior Data Researcher
goal: >
Uncover cutting-edge developments in {topic}
backstory: >
You are a veteran tech journalist with an instinct for
finding the most important news. You prioritize facts over hype.
writer:
role: >
Tech Content Strategist
goal: >
Craft compelling content on tech advancements
backstory: >
You are a famous writer, known for simplifying complex topics.
You base your writing on the work of the Data Researcher.

Notice the {topic} placeholder? We will pass this dynamic input when we run the crew.

Next, open src/latest_ai_news/config/tasks.yaml. We define what the agents need to do.

src/latest_ai_news/config/tasks.yaml
research_task:
description: >
Conduct a thorough research about {topic}.
Identify key trends and breakthrough technologies.
expected_output: >
A list of top 5 trends with brief descriptions.
agent: researcher
writing_task:
description: >
Using the research findings, write a blog post about {topic}.
expected_output: >
A 4-paragraph blog post formatted in markdown.
agent: writer

Look at src/latest_ai_news/crew.py. The CLI has already generated the Python code to load these YAML files. It uses decorators (@agent, @task, @crew) to map the YAML configurations to actual Python class instances.

Before running, ensure your .env file contains your API key (e.g., OPENAI_API_KEY=sk-...).

Now, execute the crew using the command below. This invokes the logic in main.py.

Terminal window
crewai run

You will see the agents interacting in the console: the Researcher will generate the trends, and the Writer will pick that up and draft the post. Congratulations! You’ve just built your first multi-agent AI system.