[TERMINAL · SKILLS]
> mounting /skills...
> indexing skill manifests...
> linking agents: claude · codex · gemini · cursor
> ready.
[░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%
Use Cases/Build a Data Pipeline Orchestrator with Lineage Tracking

Build a Data Pipeline Orchestrator with Lineage Tracking

Orchestrate ETL pipelines with dependency graphs, automatic retries, and data lineage tracking — so when a dashboard number looks wrong, you can trace it back to the source table in seconds.

DevOps#kestra#orchestration#workflow#yaml#data-pipelines
Works with:claude-codeopenai-codexgemini-clicursor

Skills stack · 8 skills

Avg quality 96/100·All SAFE
>

kestra

v1.0.0

Kestra is an open-source workflow orchestrator where pipelines are declarative YAML flows with tasks, schedules, webhooks, retries and a web UI. Use when asked to "orchestrate a data pipeline with Kestra", "write a Kestra flow", "schedule a job with cron in Kestra", "run a Python script on a schedule", "trigger a flow from a webhook", or "deploy flows with kestractl".

100/100 quality
2.52× impact
SAFE
View skill
>

typescript

v1.0.0

Sets up and repairs TypeScript projects: picks tsconfig.json settings for a Node.js service, an npm library or a bundled web app, runs type-checking in CI, and replaces `any` and unsafe casts with types the compiler can verify. Use when someone asks to "set up TypeScript", "fix this tsconfig", "fix a TypeScript error", "upgrade to TypeScript 6 or 7", "migrate JavaScript to TypeScript", "publish types for a package", "run .ts files in Node" or "make this type-safe". Covers the changed defaults in TypeScript 6.0 and 7.0, module and moduleResolution, strict mode, project references, declaration output, narrowing, satisfies and common compiler errors.

93/100 quality
7.30× impact
SAFE· stale score
View skill
>

postgresql

v1.1.0

Assists with designing schemas, writing performant queries, managing indexes, and operating PostgreSQL databases. Use when working with JSONB, full-text search, window functions, CTEs, row-level security, replication, or performance tuning. Trigger words: postgresql, postgres, sql, database, jsonb, rls, window functions, cte.

100/100 quality
5.15× impact
SAFE· stale score
View skill
>

redis

v1.1.0

Redis is an in-memory data store used as a cache, session store, message broker and counter service. Use when adding a cache layer, storing sessions, rate limiting an API, running pub/sub or Streams with consumer groups, taking a distributed lock, building a leaderboard, or configuring Redis for production (persistence, maxmemory, eviction).

93/100 quality
1.79× impact
SAFE· stale score
View skill
>

bull-mq

v1.1.0

Runs background jobs in Node.js with BullMQ, a job queue library backed by Redis (or PostgreSQL since v6): delayed and prioritized jobs, retries with backoff, rate limiting, cron-style job schedulers, parent-child flows and concurrency control. Use when a user asks to add a background worker, queue emails or webhooks, schedule recurring jobs, retry failed jobs, rate limit an API client, or migrate from Bull or from BullMQ 5 repeatable jobs.

100/100 quality
1.19× impact
SAFE· stale score
View skill
>

kafka

v1.1.0

Build event-driven systems with Apache Kafka. Use when a user asks to set up message streaming, implement event sourcing, build pub/sub systems, process real-time data streams, or connect microservices with async messaging.

87/100 quality
2.00× impact
SAFE· stale score
View skill
>

zod

v1.1.0

Zod is a TypeScript-first schema library that validates data at runtime and infers static types from the same schema. Use when validating API request bodies, form input, environment variables or config files, parsing untrusted JSON, or migrating from Zod 3 to Zod 4. Covers z.object, safeParse, z.infer, coercion, discriminated unions, refinements, JSON Schema output and the v4 API changes.

93/100 quality
3.87× impact
SAFE· stale score
View skill
>

hono

v1.1.0

Hono is a small web framework built on Web Standards (Request/Response) that runs unchanged on Cloudflare Workers, Deno, Bun, Node.js, AWS Lambda and Vercel. Use it when the user asks to build a Hono API, add Zod validation, JWT auth, CORS or middleware, use the type-safe RPC client (hc), render JSX, stream responses, or deploy one codebase to several runtimes.

100/100 quality
6.20× impact
SAFE· stale score
View skill
$

The Problem

A data team runs 80 ETL jobs across 3 tools (cron scripts, Airflow, and manual SQL queries). When the CEO asks "why is revenue $200K lower on the dashboard?" nobody can trace it. The pipeline graph is undocumented — nobody knows that the revenue dashboard depends on 6 intermediate tables that depend on 3 source systems. When a source API changes format, 12 downstream jobs fail over 3 days as each one is discovered. Average time to root-cause a data issue: 4 hours of detective work.

Step 1: Pipeline DAG Definition

typescript
// src/orchestrator/dag.ts
import { z } from 'zod';

export const PipelineStep = z.object({
  id: z.string(),
  name: z.string(),
  type: z.enum(['sql', 'typescript', 'python', 'api_extract']),
  dependsOn: z.array(z.string()).default([]),
  inputs: z.array(z.object({
    source: z.string(),     // "postgres:raw.orders" or "api:stripe"
    table: z.string().optional(),
  })),
  outputs: z.array(z.object({
    destination: z.string(), // "postgres:analytics.daily_revenue"
    table: z.string(),
  })),
  schedule: z.string().optional(),  // cron expression
  timeoutSeconds: z.number().int().default(300),
  retries: z.number().int().default(2),
  handler: z.string(),
});

export const Pipeline = z.object({
  id: z.string(),
  name: z.string(),
  description: z.string(),
  steps: z.array(PipelineStep),
  schedule: z.string().optional(),
  owner: z.string().email(),
  slackChannel: z.string().optional(),
});

export const revenuePipeline: z.infer<typeof Pipeline> = {
  id: 'revenue-pipeline',
  name: 'Daily Revenue Pipeline',
  description: 'Extract orders, payments, and refunds → transform → load into analytics',
  owner: 'data-team@company.com',
  schedule: '0 6 * * *', // 6 AM daily
  steps: [
    {
      id: 'extract-orders',
      name: 'Extract Orders',
      type: 'sql',
      dependsOn: [],
      inputs: [{ source: 'postgres:production', table: 'orders' }],
      outputs: [{ destination: 'postgres:warehouse', table: 'raw.orders' }],
      timeoutSeconds: 120,
      retries: 2,
      handler: 'extract-orders',
    },
    {
      id: 'extract-payments',
      name: 'Extract Payments from Stripe',
      type: 'api_extract',
      dependsOn: [],
      inputs: [{ source: 'api:stripe' }],
      outputs: [{ destination: 'postgres:warehouse', table: 'raw.stripe_payments' }],
      timeoutSeconds: 180,
      retries: 3,
      handler: 'extract-stripe-payments',
    },
    {
      id: 'transform-revenue',
      name: 'Calculate Daily Revenue',
      type: 'sql',
      dependsOn: ['extract-orders', 'extract-payments'],
      inputs: [
        { source: 'postgres:warehouse', table: 'raw.orders' },
        { source: 'postgres:warehouse', table: 'raw.stripe_payments' },
      ],
      outputs: [{ destination: 'postgres:warehouse', table: 'analytics.daily_revenue' }],
      timeoutSeconds: 60,
      retries: 1,
      handler: 'transform-revenue',
    },
    {
      id: 'aggregate-metrics',
      name: 'Aggregate Business Metrics',
      type: 'sql',
      dependsOn: ['transform-revenue'],
      inputs: [{ source: 'postgres:warehouse', table: 'analytics.daily_revenue' }],
      outputs: [{ destination: 'postgres:warehouse', table: 'analytics.business_metrics' }],
      timeoutSeconds: 60,
      retries: 1,
      handler: 'aggregate-metrics',
    },
  ],
};

Step 2: DAG Executor with Lineage

typescript
// src/orchestrator/executor.ts
import { Queue, Worker } from 'bullmq';
import { Redis } from 'ioredis';
import { Pool } from 'pg';
import type { Pipeline, PipelineStep } from './dag';

const connection = new Redis(process.env.REDIS_URL!);
const db = new Pool({ connectionString: process.env.DATABASE_URL });

export async function executePipeline(pipeline: z.infer<typeof Pipeline>): Promise<string> {
  const runId = crypto.randomUUID();

  await db.query(`
    INSERT INTO pipeline_runs (id, pipeline_id, status, started_at)
    VALUES ($1, $2, 'running', NOW())
  `, [runId, pipeline.id]);

  // Topological sort: execute steps respecting dependencies
  const executed = new Set<string>();
  const queue = [...pipeline.steps.filter(s => s.dependsOn.length === 0)];

  while (queue.length > 0) {
    // Execute all ready steps in parallel
    const batch = queue.splice(0, queue.length);

    await Promise.all(batch.map(async (step) => {
      await executeStep(runId, pipeline.id, step);
      executed.add(step.id);

      // Record lineage
      await recordLineage(runId, step);
    }));

    // Find next steps whose dependencies are all satisfied
    for (const step of pipeline.steps) {
      if (!executed.has(step.id) && step.dependsOn.every(d => executed.has(d))) {
        queue.push(step);
      }
    }
  }

  await db.query(`UPDATE pipeline_runs SET status = 'completed', completed_at = NOW() WHERE id = $1`, [runId]);
  return runId;
}

async function executeStep(runId: string, pipelineId: string, step: z.infer<typeof PipelineStep>): Promise<void> {
  const stepRunId = crypto.randomUUID();

  await db.query(`
    INSERT INTO step_runs (id, run_id, step_id, status, started_at)
    VALUES ($1, $2, $3, 'running', NOW())
  `, [stepRunId, runId, step.id]);

  let lastError: string | null = null;

  for (let attempt = 0; attempt <= step.retries; attempt++) {
    try {
      const handler = handlers[step.handler];
      if (!handler) throw new Error(`No handler: ${step.handler}`);

      const result = await Promise.race([
        handler(),
        new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), step.timeoutSeconds * 1000)),
      ]);

      await db.query(`
        UPDATE step_runs SET status = 'completed', completed_at = NOW(), rows_affected = $1
        WHERE id = $2
      `, [(result as any)?.rowsAffected ?? 0, stepRunId]);

      return;
    } catch (err: any) {
      lastError = err.message;
      if (attempt < step.retries) {
        await new Promise(r => setTimeout(r, 5000 * (attempt + 1)));
      }
    }
  }

  await db.query(`UPDATE step_runs SET status = 'failed', error = $1, completed_at = NOW() WHERE id = $2`, [lastError, stepRunId]);
  throw new Error(`Step ${step.id} failed: ${lastError}`);
}

async function recordLineage(runId: string, step: z.infer<typeof PipelineStep>): Promise<void> {
  for (const input of step.inputs) {
    for (const output of step.outputs) {
      await db.query(`
        INSERT INTO data_lineage (run_id, step_id, source, source_table, destination, destination_table, recorded_at)
        VALUES ($1, $2, $3, $4, $5, $6, NOW())
      `, [runId, step.id, input.source, input.table, output.destination, output.table]);
    }
  }
}

const handlers: Record<string, () => Promise<{ rowsAffected: number }>> = {};
export function registerHandler(name: string, fn: () => Promise<{ rowsAffected: number }>): void {
  handlers[name] = fn;
}

import { z } from 'zod';

Step 3: Lineage Query API

typescript
// src/api/lineage.ts
import { Hono } from 'hono';
import { Pool } from 'pg';

const app = new Hono();
const db = new Pool({ connectionString: process.env.DATABASE_URL });

// Trace upstream: "what feeds into this table?"
app.get('/v1/lineage/upstream/:table', async (c) => {
  const table = c.req.param('table');

  const { rows } = await db.query(`
    WITH RECURSIVE upstream AS (
      SELECT source, source_table, destination, destination_table, step_id, 1 as depth
      FROM data_lineage WHERE destination_table = $1
      UNION ALL
      SELECT l.source, l.source_table, l.destination, l.destination_table, l.step_id, u.depth + 1
      FROM data_lineage l JOIN upstream u ON l.destination_table = u.source_table
      WHERE u.depth < 10
    )
    SELECT DISTINCT source, source_table, destination, destination_table, depth
    FROM upstream ORDER BY depth
  `, [table]);

  return c.json({ table, upstream: rows });
});

// Trace downstream: "what breaks if this table changes?"
app.get('/v1/lineage/downstream/:table', async (c) => {
  const table = c.req.param('table');

  const { rows } = await db.query(`
    WITH RECURSIVE downstream AS (
      SELECT source, source_table, destination, destination_table, step_id, 1 as depth
      FROM data_lineage WHERE source_table = $1
      UNION ALL
      SELECT l.source, l.source_table, l.destination, l.destination_table, l.step_id, d.depth + 1
      FROM data_lineage l JOIN downstream d ON l.source_table = d.destination_table
      WHERE d.depth < 10
    )
    SELECT DISTINCT source, source_table, destination, destination_table, depth
    FROM downstream ORDER BY depth
  `, [table]);

  return c.json({ table, downstream: rows });
});

export default app;

Results

  • Root-cause time: 30 seconds with lineage trace (was 4 hours of detective work)
  • CEO's $200K question: traced to Stripe API format change in 2 minutes
  • Cascading failures: when source changes, all 12 downstream jobs alerted immediately
  • 80 ETL jobs: unified into one orchestrator with dependency-aware execution
  • Retry success: 15% of transient failures auto-recovered (were permanent before)
  • Data freshness SLA: 99.5% of tables updated by 7 AM (was untracked)
  • Impact analysis: before changing a table, see every downstream dependency instantly

Related Skills

  • kestra — choose it when you would rather adopt a declarative YAML orchestrator with schedules, retries and a UI than build the orchestrator yourself

Related use cases