Skip to main content
skill CX Codex

tracing-upstream-lineage — Claude Code skill: trace where data comes

A skill that answers "where does this data come from" by finding the producing DAG, reading its source and walking the chain back to external systems.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add astronomer/agents --skill tracing-upstream-lineage -a claude-code
Open on GitHub

What tracing-upstream-lineage does

The skill works through lineage in steps. It first decides what you are tracing: a table, a column or a DAG. Then it looks for the DAG that populates the table with af dags list, reads the definition via af dags source <dag_id> and checks the tasks with af tasks list <dag_id>. From there it picks out sources by scanning FROM clauses and operators such as S3Operator, PostgresOperator or SalesforceOperator, and recurses upward.

You get a report: a one-line answer, a diagram of the flow, a table of sources with connection type and freshness, the transformation chain, and a short list of risks like single points of failure. Column tracing is handled separately, including direct mappings, COALESCE and aggregations.

This runs on Airflow. On Astro the Lineage tab in the UI already shows cross-DAG dependencies, and the skill points you there instead of grepping source code by hand. OSS Airflow has no such view, so tracing falls back to DAG source and task logs. Freshness checks are handed off to the checking-freshness skill, DAG debugging to debugging-dags.

What it helps with

  • find the DAG that populates a given table
  • trace a single column back through transformations
  • map the chain from a mart down to an external API or database
  • flag stale upstream sources and single points of failure
  • see which DAGs read from S3 or Salesforce

Example prompts for the agent

  • Where does the data in analytics.orders_daily come from?
  • Trace the origin of the total_amount column in fct.orders
  • What sources feed the etl_daily_orders DAG?

How to install tracing-upstream-lineage

1Skills CLI (Vercel)

npx skills add astronomer/agents --skill tracing-upstream-lineage -a claude-code

2Manually: put the files in place

~/.claude/skills/tracing-upstream-lineage/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/tracing-upstream-lineage/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about tracing-upstream-lineage

How do I install tracing-upstream-lineage in Claude?

Run npx skills add astronomer/agents --skill tracing-upstream-lineage -a claude-code. The skill file then sits at ~/.claude/skills/tracing-upstream-lineage/SKILL.md.

What does tracing-upstream-lineage do?

It traces data origins upstream: finds the producing DAG, reads its source code, identifies the sources and builds the chain back to external systems. It finishes with a report containing a diagram, a source table and the transformation chain.

What does the skill need to work?

Airflow, plus the af CLI for commands like af dags list, af dags source <dag_id> and af dags stats. On Astro you can use the Lineage tab instead; on OSS Airflow tracing relies on DAG source and task logs.

Source text

SKILL.md · Apache-2.0
---
name: tracing-upstream-lineage
description: Trace upstream data lineage. Use when the user asks where data comes from, what feeds a table, upstream dependencies, data sources, or needs to understand data origins.
---

# Upstream Lineage: Sources

Trace the origins of data - answer "Where does this data come from?"

## Lineage Investigation

### Step 1: Identify the Target Type

Determine what we're tracing:
- **Table**: Trace what populates this table
- **Column**: Trace where this specific column comes from
- **DAG**: Trace what data sources this DAG reads from

### Step 2: Find the Producing DAG

Tables are typically populated by Airflow DAGs. Find the connection:

1. **Search DAGs by name**: Use `af dags list` and look for DAG names matching the table name
   - `load_customers` -> `customers` table
   - `etl_daily_orders` -> `orders` table

2. **Explore DAG source code**: Use `af dags source <dag_id>` to read the DAG definition
   - Look for INSERT, MERGE, CREATE TABLE statements
   - Find the target table in the code

3. **Check DAG tasks**: Use `af tasks list <dag_id>` to see what operations the DAG performs

### On Astro

If you're running on Astro, the **Lineage tab** in the Astro UI provides visual lineage exploration across DAGs and datasets. Use it to quickly trace upstream dependencies without manually searching DAG source code.

### On OSS Airflow

Use DAG source code and task logs to trace lineage (no built-in cross-DAG UI).

### Step 3: Trace Data Sources

From the DAG code, identify source tables and systems:

**SQL Sources** (look for FROM clauses):
```python
# In DAG code:
SELECT * FROM source_schema.source_table  # <- This is an upstream source
```

**External Sources** (look for connection references):
- `S3Operator` -> S3 bucket source
- `PostgresOperator` -> Postgres database source
- `SalesforceOperator` -> Salesforce API source
- `HttpOperator` -> REST API source

**File Sources**:
- CSV/Parquet files in object storage
- SFTP drops
- Local file paths

### Step 4: Build the Lineage Chain

Recursively trace each source:

```
TARGET: analytics.orders_daily
    ^
    +-- DAG: etl_daily_orders
            ^
            +-- SOURCE: raw.orders (table)
            |       ^
            |       +-- DAG: ingest_orders
            |               ^
            |               +-- SOURCE: Salesforce API (external)
            |
            +-- SOURCE: dim.customers (table)
                    ^
                    +-- DAG: load_customers
                            ^
                            +-- SOURCE: PostgreSQL (external DB)
```

### Step 5: Check Source Health

For each upstream source:
- **Tables**: Check freshness with the **checking-freshness** skill
- **DAGs**: Check recent run status with `af dags stats`
- **External systems**: Note connection info from DAG code

## Lineage for Columns

When tracing a specific column:

1. Find the column in the target table schema
2. Search DAG source code for references to that column name
3. Trace through transformations:
   - Direct mappings: `source.col AS target_col`
   - Transformations: `COALESCE(a.col, b.col) AS target_col`
   - Aggregations: `SUM(detail.amount) AS total_amount`

## Output: Lineage Report

### Summary
One-line answer: "This table is populated by DAG X from sources Y and Z"

### Lineage Diagram
```
[Salesforce] --> [raw.opportunities] --> [stg.opportunities] --> [fct.sales]
                        |                        |
                   DAG: ingest_sfdc         DAG: transform_sales
```

### Source Details

| Source | Type | Connection | Freshness | Owner |
|--------|------|------------|-----------|-------|
| raw.orders | Table | Internal | 2h ago | data-team |
| Salesforce | API | salesforce_conn | Real-time | sales-ops |

### Transformation Chain
Describe how data flows and transforms:
1. Raw data lands in `raw.orders` via Salesforce API sync
2. DAG `transform_orders` cleans and dedupes into `stg.orders`
3. DAG `build_order_facts` joins with dimensions into `fct.orders`

### Data Quality Implications
- Single points of failure?
- Stale upstream sources?
- Complex transformation chains that could break?

### Related Skills
- Check source freshness: **checking-freshness** skill
- Debug source DAG: **debugging-dags** skill
- Trace downstream impacts: **tracing-downstream-lineage** skill
- Add manual lineage annotations: **annotating-task-lineage** skill
- Build custom lineage extractors: **creating-openlineage-extractors** skill

© astronomer · Apache-2.0 · astronomer/agents

Similar skills

All skills for Data and databases →

From the same set24

migrating-airflow-2-to-3 Walks Airflow 2.x DAG code through the move to 3.x: imports, operators, hooks, metadata access. Useful when the upgrade is due and hunting breaking changes by hand is tedious. CX Codex +1 1,100installs checking-freshness The skill checks when a table was last updated and tells you whether the data is safe to use. CX Codex +1 1,000installs tracing-downstream-lineage The skill finds everything downstream of a table or DAG and shows what breaks when you change it. Run it before touching a schema. CX Codex +1 1,000installs profiling-tables Profiles specific database tables through targeted SQL queries. It inspects schema, gathers column statistics, and evaluates data quality. CX Codex +1 1,000installs cosmos-dbt-core Turns a dbt Core project into an Airflow DAG or TaskGroup with Astronomer Cosmos. Useful when your models need a schedule and retries. CX Codex +1 962installs airflow-hitl A skill for building human-in-the-loop Airflow workflows: approval gates, form input, and branching on a person's choice. Useful when a DAG has to wait for a response. CX Codex +1 952installs creating-openlineage-extractors Helps implement custom OpenLineage extraction for Apache Airflow operators. Useful when you need column-level lineage or support for third-party operators. CX Codex +1 933installs warehouse-init Walks your warehouse and writes every database, schema and table into .astro/warehouse.md, so the agent looks up tables without querying the warehouse. CX Codex +1 814installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor