Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

build-flow

БесплатноБез исполняемых скриптовНе проверен

Building CrewAI Flows on crewai 1.15.x: structured (Pydantic) vs dict state and state.id, @start/@listen/@router wiring, or_/and_ semantics, router labels vs…

crewAIIncот crewAIInc★ 51 звезда на GitHub

Об этом скилле

Build a CrewAI Flow

How to write a Flow that wires correctly, keeps typed state, persists and resumes, and calls crews and agents, on the current API.

Verified against crewai 1.15.22 and 1.15.23 on 2026-10-01. Live-tested on CrewAI AMP and real LLMs on 2026-10-01. Run crewai version first; if the major/minor differs from 1.15, re-verify version-sensitive rows with the ask-docs skill before trusting them.


1. Scaffold and run a flow project

crewai create flow lead-router      # the package is still lead_router
cd lead_router
crewai install                      # uv sync; writes uv.lock
crewai run                          # runs the `kickoff` script in pyproject.toml
crewai flow plot                    # runs the `plot` script

What the scaffold gives you:

File Contents
pyproject.toml [project.scripts] kickoff, run_crew (both <pkg>.main:kickoff), plot, run_with_trigger; [tool.crewai] type = "flow"
src/<pkg>/main.py A Flow[ContentState] subclass plus kickoff() and plot() functions; from crewai.flow import Flow, listen, start
src/<pkg>/crews/content_crew/ A classic @CrewBase crew with config/agents.yaml and config/tasks.yaml; its agents set no llm, so they use the default OpenAI model
.env OPENAI_API_KEY=YOUR_API_KEY - a placeholder; a run with it fails with 401 ... Incorrect API key provided. An OPENAI_API_KEY exported in the shell takes precedence over .env: with a valid key exported, the unmodified scaffold's crewai run ran its three agents on gpt-4.1-mini and wrote output/post.md
AGENTS.md, CLAUDE.md, GEMINI.md (plus CURSOR.md from 1.15.23), README.md, tests/ Coding-assistant instructions and an empty tests folder
.git/ crewai create runs git init (no commit, no remote)

To use another provider, set llm: anthropic/claude-haiku-4-5 (for example) on each agent in agents.yaml, run uv add "crewai[anthropic]", and put ANTHROPIC_API_KEY=<your-key> in .env - crewai run read the key from .env with nothing exported in the shell.

Rules the scaffold implies:

  • Keep [tool.crewai] type = "flow". The CLI uses it to decide that crewai run means uv run kickoff.
  • The template's plan_content() overwrites self.state.topic with "AI Agents" unless a trigger payload is present, so kickoff(inputs={"topic": ...}) (and a deployed kickoff's inputs) is ignored. Delete that assignment before relying on inputs.
  • The template's plot() calls plot() with the default show=True, so crewai flow plot opens a browser. Change it to plot("<name>.html", show=False) for headless use.
  • Import with the absolute package path (from lead_router.crews.content_crew.content_crew import ContentCrew), as the template does.
  • kickoff() in main.py must return None. The generated console script does sys.exit(kickoff()), so returning the flow result (a dict, say) makes the process exit with status 1 and prints the value to stderr, and crewai run prints "An error occurred while running the flow" - yet crewai run itself still exits 0, so a CI step that only checks its exit code passes.
  • crewai run --inputs '{...}' is rejected for a Python flow: Error: --inputs requires a declarative flow definition ([tool.crewai].definition) or --definition. Pass inputs in code (flow.kickoff(inputs=...)), or read them from sys.argv in your kickoff() and call uv run kickoff '<json>'.
  • crewai flow kickoff still works but prints "deprecated. Use 'crewai run' instead."
  • A placeholder or invalid key makes the flow fail, yet crewai run still exits 0 (it prints An error occurred while running the flow: Command '['uv', 'run', 'kickoff']' returned non-zero exit status 1.). Check for that line, not the exit code.

2. State: structured or dict

Structured (recommended) Unstructured
Declare class MyFlow(Flow[MyState]) with MyState(BaseModel) class MyFlow(Flow)
Access self.state.topic self.state["topic"]
id Added for you (self.state.id, a UUID string) self.state["id"]
Validation kickoff(inputs=...) values are type-checked none
from pydantic import BaseModel
from crewai.flow import Flow, listen, start


class ReportState(BaseModel):
    topic: str = ""          # give every field a default
    draft: str = ""
    notes: list[str] = []


class ReportFlow(Flow[ReportState]):
    @start()
    def plan(self):
        self.state.notes.append(f"planning {self.state.topic}")
        return self.state.topic.upper()

    @listen(plan)
    def write(self, plan_output):          # receives plan()'s return value
        self.state.draft = f"Draft about {plan_output}"
        return self.state.draft


flow = ReportFlow()
result = flow.kickoff(inputs={"topic": "bees"})   # inputs set state BEFORE @start runs
print(result)           # "Draft about BEES" - kickoff returns the last method's ou
Полный SKILL.md на GitHub

Установить build-flow в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/conversational-flows.mdreferences/persistence-and-checkpoints.mdreferences/routing-patterns.md

FAQ

Что делает скилл build-flow?

Building CrewAI Flows on crewai 1.15.x: structured (Pydantic) vs dict state and state.id, @start/@listen/@router wiring, or_/and_ semantics, router labels vs method names, @persist (correct import, where it stores state, restore_from_state_id), checkpointing with CheckpointConfig, @human_feedback and HumanFeedbackResult.feedback, plot(), calling crews and agents from flow methods, kickoff inputs, and the `crewai create flow` scaffold. Use when writing or debugging a Flow subclass or main.py with `from crewai.flow import ...`, when a listener never fires or fires twice, or when you see errors like "listen condition 'x' references the handler name 'x'", "cannot import name 'persist'", "'StateWithId' object is not subscriptable", "Flow state model must have an 'id' field", "--inputs requires a declarative flow definition", "invoked synchronously from within a running event loop", or HumanFeedbackCollapseError.

Как установить скилл build-flow?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл build-flow запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить build-flow с