prefect
Prefect is a modern workflow orchestration framework for Python data pipelines. Learn to define flows and tasks with decorators, handle retries and scheduling, create deployments, and monitor via the Prefect UI.
What this skill does
# Prefect
Prefect turns Python functions into observable, schedulable workflows with minimal boilerplate. Add `@flow` and `@task` decorators to get retries, logging, caching, and a monitoring UI.
## Installation
```bash
# Install Prefect
pip install prefect
# Start the local Prefect server (UI + API)
prefect server start
# UI at http://localhost:4200
# Or use Prefect Cloud (managed)
prefect cloud login
```
## Basic Flow
```python
# flows/hello.py: Simple flow with tasks
from prefect import flow, task, get_run_logger
from datetime import timedelta
@task(retries=3, retry_delay_seconds=10)
def fetch_data(url: str) -> dict:
import httpx
logger = get_run_logger()
logger.info(f"Fetching {url}")
response = httpx.get(url)
response.raise_for_status()
return response.json()
@task(cache_expiration=timedelta(hours=1))
def transform(data: dict) -> list:
return [
{"id": item["id"], "value": item["amount"] * 100}
for item in data["results"]
]
@task
def load(records: list) -> int:
logger = get_run_logger()
logger.info(f"Loading {len(records)} records")
# Insert into database...
return len(records)
@flow(name="etl-pipeline", log_prints=True)
def etl_pipeline(api_url: str = "https://api.example.com/data"):
raw = fetch_data(api_url)
cleaned = transform(raw)
count = load(cleaned)
print(f"Processed {count} records")
return count
if __name__ == "__main__":
etl_pipeline()
```
## Scheduling and Deployments
```python
# flows/deploy.py: Create a deployment with schedule
from prefect import flow
from prefect.deployments import Deployment
from prefect.server.schemas.schedules import CronSchedule
@flow
def daily_report():
print("Generating daily report...")
if __name__ == "__main__":
# Deploy via Python
daily_report.serve(
name="daily-report-deployment",
cron="0 8 * * *", # Every day at 8 AM
tags=["reporting"],
parameters={"param1": "value1"},
)
```
```bash
# deploy.sh: Deploy and manage via CLI
# Create deployment from flow file
prefect deploy flows/hello.py:etl_pipeline \
--name etl-prod \
--pool default-agent-pool \
--cron "*/30 * * * *"
# Start a worker to execute deployments
prefect worker start --pool default-agent-pool
# Trigger a deployment run
prefect deployment run "etl-pipeline/etl-prod" --param api_url=https://api.example.com
```
## Error Handling and Concurrency
```python
# flows/advanced.py: Concurrent tasks, error handling, and sub-flows
from prefect import flow, task
from prefect.tasks import task_input_hash
import asyncio
@task(
retries=2,
retry_delay_seconds=[10, 60], # Exponential backoff
cache_key_fn=task_input_hash,
timeout_seconds=300,
)
def process_item(item_id: int) -> dict:
# Process a single item
return {"id": item_id, "status": "done"}
@flow
def batch_process(item_ids: list[int]):
# Submit tasks concurrently
futures = [process_item.submit(id) for id in item_ids]
results = [f.result() for f in futures]
succeeded = [r for r in results if r["status"] == "done"]
print(f"Processed {len(succeeded)}/{len(item_ids)} items")
@flow
async def async_pipeline():
# Async flow for I/O-bound work
results = await asyncio.gather(
fetch_from_api("source_a"),
fetch_from_api("source_b"),
)
return results
```
## Blocks and Infrastructure
```python
# flows/blocks.py: Use blocks for reusable configuration
from prefect.blocks.system import Secret, JSON
from prefect_sqlalchemy import SqlAlchemyConnector
# Store secrets (set via UI or CLI)
# prefect block register -m prefect_sqlalchemy
# Then configure in UI at http://localhost:4200/blocks
# Use in flows
@flow
def db_flow():
api_key = Secret.load("my-api-key").get()
config = JSON.load("pipeline-config").value
with SqlAlchemyConnector.load("prod-db") as conn:
result = conn.fetch_all("SELECT count(*) FROM users")
print(result)
```
## Notifications
```python
# flows/notifications.py: Send alerts on failure
from prefect import flow
from prefect.blocks.notifications import SlackWebhook
@flow
def monitored_flow():
try:
# ... do work
pass
except Exception as e:
slack = SlackWebhook.load("alerts-channel")
slack.notify(f"❌ Pipeline failed: {e}")
raise
# Or use automations in Prefect UI:
# Automations → Create → Trigger: Flow run failed → Action: Send Slack notification
```
## CLI Reference
```bash
# cli.sh: Common Prefect CLI commands
# Check connection
prefect version
prefect config view
# List flows and deployments
prefect flow-run ls
prefect deployment ls
# View logs
prefect flow-run logs <flow-run-id>
# Manage work pools
prefect work-pool create my-pool --type process
prefect work-pool ls
```
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.