hatchet
Orchestrate background jobs and workflows with Hatchet — open-source distributed task queue with DAG workflows. Use when someone asks to "run background jobs", "Hatchet", "workflow orchestration", "distributed task queue", "durable execution", "replace Celery/Bull", or "DAG workflow engine". Covers workflow definition, step functions, retries, concurrency control, and event-driven triggers.
What this skill does
# Hatchet
## Overview
Hatchet is an open-source distributed task queue and workflow engine. Define workflows as DAGs (directed acyclic graphs), run steps with automatic retries and timeouts, control concurrency, and trigger workflows from events or schedules. Like Temporal but lighter, like BullMQ but with workflow orchestration. Built for background jobs that need reliability: payment processing, data pipelines, AI agent orchestration.
## When to Use
- Background jobs that need reliability (retries, timeouts, idempotency)
- Multi-step workflows (onboarding, order processing, data pipelines)
- Fan-out/fan-in patterns (process items in parallel, aggregate results)
- Rate-limited API calls (concurrency control per workflow)
- Replacing BullMQ/Celery with something more structured
## Instructions
### Setup
```bash
npm install @hatchet-dev/typescript-sdk
# Self-host
docker compose up -d # From hatchet-dev/hatchet repo
```
### Define a Workflow
```typescript
// workflows/onboarding.ts — Multi-step user onboarding
import Hatchet from "@hatchet-dev/typescript-sdk";
const hatchet = Hatchet.init();
const onboardingWorkflow = hatchet.workflow({
name: "user-onboarding",
on: { event: "user:created" },
timeout: "10m",
});
// Step 1: Send welcome email
onboardingWorkflow.step("send-welcome-email", async (ctx) => {
const { userId, email } = ctx.input();
await sendEmail(email, {
subject: "Welcome!",
template: "welcome",
});
return { emailSent: true };
}, { retries: 3, timeout: "30s" });
// Step 2: Set up default workspace (runs after step 1)
onboardingWorkflow.step("create-workspace", async (ctx) => {
const { userId } = ctx.input();
const workspace = await createWorkspace(userId, "My Workspace");
return { workspaceId: workspace.id };
}, {
parents: ["send-welcome-email"],
retries: 2,
timeout: "1m",
});
// Step 3: Generate sample data (runs after workspace created)
onboardingWorkflow.step("seed-data", async (ctx) => {
const { workspaceId } = ctx.stepOutput("create-workspace");
await seedSampleData(workspaceId);
return { seeded: true };
}, {
parents: ["create-workspace"],
timeout: "2m",
});
// Step 4: Send getting-started guide (runs after email + workspace)
onboardingWorkflow.step("send-guide", async (ctx) => {
const { email } = ctx.input();
await sendEmail(email, {
subject: "Getting Started Guide",
template: "getting-started",
});
}, {
parents: ["send-welcome-email", "create-workspace"],
retries: 3,
});
```
### Trigger Workflows
```typescript
// src/api/users.ts — Trigger from your application
import Hatchet from "@hatchet-dev/typescript-sdk";
const hatchet = Hatchet.init();
// Event-based trigger
await hatchet.event.push("user:created", {
userId: "user_123",
email: "[email protected]",
plan: "pro",
});
// Direct trigger
const run = await hatchet.workflow.run("user-onboarding", {
userId: "user_123",
email: "[email protected]",
});
// Wait for result
const result = await run.result();
console.log(result); // { emailSent: true, workspaceId: "ws_xxx", seeded: true }
```
### Concurrency Control
```typescript
// workflows/api-sync.ts — Rate-limited external API calls
const syncWorkflow = hatchet.workflow({
name: "api-sync",
concurrency: {
maxRuns: 5, // Max 5 concurrent workflow runs
limitStrategy: "QUEUE", // Queue excess, don't drop
},
});
syncWorkflow.step("fetch-data", async (ctx) => {
const { apiEndpoint } = ctx.input();
const data = await fetch(apiEndpoint).then(r => r.json());
return { records: data.length };
}, {
retries: 3,
backoff: { type: "exponential", base: 2 },
timeout: "30s",
concurrency: { key: "api-provider", maxRuns: 10 }, // Per-key limit
});
```
### Scheduled Workflows
```typescript
// workflows/daily-report.ts — Cron-triggered workflow
const reportWorkflow = hatchet.workflow({
name: "daily-report",
on: { cron: "0 9 * * *" }, // 9 AM daily
});
reportWorkflow.step("generate", async (ctx) => {
const stats = await generateDailyStats();
return stats;
});
reportWorkflow.step("send", async (ctx) => {
const stats = ctx.stepOutput("generate");
await sendSlackReport(stats);
}, { parents: ["generate"] });
```
## Examples
### Example 1: Order processing pipeline
**User prompt:** "Build a reliable order processing workflow — validate, charge, fulfill, notify."
The agent will create a Hatchet workflow with sequential steps, payment retry logic, and parallel notification to customer + warehouse.
### Example 2: AI agent orchestration
**User prompt:** "Run an AI pipeline: scrape data → process → generate report → email."
The agent will create a DAG workflow with fan-out scraping, aggregation step, LLM generation, and email delivery with retries.
## Guidelines
- **Workflows are DAGs** — define step dependencies with `parents`
- **Retries are per-step** — each step can have its own retry policy
- **Timeouts prevent hung jobs** — always set per-step and per-workflow timeouts
- **Concurrency control** — limit parallel runs globally or per-key
- **Events for decoupling** — trigger workflows from events, not direct calls
- **`ctx.stepOutput()` passes data between steps** — typed step results
- **Idempotency** — design steps to be safely retried
- **Self-hostable** — Postgres + Hatchet engine
- **Dashboard for monitoring** — see running workflows, failed steps, retry history
- **Backoff strategies** — exponential, linear, or constant for retries
Related in Productivity
gitea-workflow
IncludedOrchestrate agile development workflows for Gitea repositories using the tea CLI. Use when working with Gitea-hosted repos and asking to 'run the workflow', 'continue working', 'what's next', 'complete the task cycle', 'start my day', 'end the sprint', 'implement the next task', or wanting guided step-by-step development assistance. Keywords: workflow, orchestrate, agile, task cycle, sprint, daily, implement, review, PR, standup, retrospective, gitea, tea.
microsoft-graph-gateway
IncludedRoute Microsoft Graph work in this workspace. Use when users want to read or write Outlook mail, calendar events, contacts, OneDrive or SharePoint files, Teams, Planner, To Do, users, groups, directory data, or arbitrary Microsoft Graph endpoints from VS Code. Prefer WorkIQ for common read scenarios. Use Microsoft Graph for write actions and gap-read scenarios that need exact Graph properties, filters, permissions, or endpoints.
copilotkit
IncludedUse when building with CopilotKit — setup, development, integrations, debugging, upgrading, or contributing. Routes to the appropriate specialized skill based on the task.
wordly-wisdom
IncludedProvides calibrated decision analysis using Charlie Munger-style multiple mental models, inversion, incentive mapping, circle-of-competence checks, misjudgment audits, second-order effects, and forecast updates. Use when the user asks for an oracle take, a hard call, a decision memo, a premortem, an outside view, a red-team, a sanity-check, what am I missing, think this through, or wants a strategy, hire, investment, plan, product, partnership, or major life choice analysed. Avoid for simple factual lookups or time-sensitive legal, medical, or market questions without fresh evidence.
swain-session
IncludedSession management and project status dashboard. Owns the full session lifecycle (start/work/close/resume), focus lane, bookmarks, worktree detection, and tab naming. Also serves as the project status dashboard — shows active epics, progress, actionable next steps, blocked items, tasks, GitHub issues, and recommendations. Worktree creation is deferred to swain-do task dispatch (SPEC-195). Triggers on: 'session', 'status', 'what's next', 'dashboard', 'overview', 'where are we', 'what should I work on', 'show me priorities', 'bookmark', 'focus on', 'session info'.
gandi
IncludedComprehensive Gandi domain registrar integration for domain and DNS management. Register and manage domains, create/update/delete DNS records (A, AAAA, CNAME, MX, TXT, SRV, and more), configure email forwarding and aliases, check SSL certificate status, create DNS snapshots for safe rollback, bulk update zone files, and monitor domain expiration. Supports multi-domain management, zone file import/export, and automated DNS backups. Includes both read-only and destructive operations with safety controls.