The Complete Production SOP: How to Deploy and Run Dagster Software-Defined Assets & Data Lineage in Autonomous AI Agents
Step-by-step SOP to install and run Dagster Software-Defined Assets in Codex, Claude Code, and Cursor. Includes verified prompts, partitions, and IO managers.
Technical Overview & Architectural Context
Without structured procedural guardrails, autonomous coding agents frequently construct brittle, task-centric orchestration code—such as legacy Airflow-style DAG operators or raw sequential Python scripts—instead of declarative, Software-Defined Assets (SDAs). This antipattern causes agents to omit explicit asset dependencies, hardcode intermediate file pathways instead of leveraging Dagster IOManagers, and neglect column-level metadata and partition slicing. As a result, downstream lineage is broken, multi-asset updates lack atomicity, and asset re-materialization requires brute-force re-execution. The `dagster-software-defined-assets` skill enforces strict architectural rules across Codex, Claude Code, Cursor, and Windsurf. It forces agents to model data transformations as pure or IOManager-backed `@asset` functions, bind explicit dependency graphs (`deps` or direct upstream function parameters), declare temporal partition definitions (`DailyPartitionsDefinition`), and attach column-level schema definitions via `MetadataValue`. By codifying Dagster's declarative paradigm into a deterministic SKILL.md specification, the agent is constrained to generate self-contained asset definitions, robust asset checks (`@asset_check`), and verified `Definitions` entry points that satisfy Dagster compilation and type checking on the first pass.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into agent runtime contexts.
Agent runtimes such as Claude Code and Cursor scan `.agents/skills` or `.claude/skills` for domain SOPs. We mount the `dagster-software-defined-assets` definition into the canonical workspace skill path, ensuring runtime compatibility and trigger discovery when prompting for asset creation, partitioning, or IO manager implementation.
mkdir -p .agents/skills/dagster-software-defined-assets && curl -fsSL https://askills.dev/api/skills/dagster-software-defined-assets/raw -o .agents/skills/dagster-software-defined-assets/SKILL.md---
name: "dagster-software-defined-assets"
description: "Declare data pipelines as Software-Defined Assets with integrated column-level lineage."
metadata:
author: "Dagster Labs"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "create dagster asset"
- "setup dagster partitions"
- "configure dagster io manager"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---
# Dagster Software-Defined Assets & Data Lineage
Implements data platforms using Dagster: declaring assets with @asset, defining upstream dependencies, partition definitions (DailyPartitionsDefinition), I/O managers, and declarative freshness policies.
## When to Invoke
Invoke this skill whenever you need to:
- create dagster asset
- setup dagster partitions
- configure dagster io manager
## Execution SOP & Rules
1. Define assets using @asset(deps=[upstream_asset]) or accept upstream assets directly as function parameters.
2. Assign partitions_def = DailyPartitionsDefinition(start_date='2025-01-01') for date-partitioned tables.
3. Declare auto-materialize policies with AutoMaterializePolicy.eager() for real-time asset freshness.
4. Launch the Dagit/Dagster web UI to inspect the asset graph, execution history, and data lineage.Place the SKILL.md in the root `.agents/skills/` directory rather than project subpackages so multi-project workspaces in Cursor and Windsurf ingest the frontmatter triggers without bloating context tokens.
The skill enforces `shell_exec: false`. Never grant arbitrary command execution permissions to the agent for asset definitions; all pipeline verification must occur through targeted linting and Dagster loader checks.
Environment Secrets & Dependency Validation
Install core Dagster libraries and configure isolated workspace dependencies without leaking credentials.
Software-Defined Assets require Dagster core, Dagster DuckDB/Parquet IOManagers, and type validators. We ensure dependencies are locked in `pyproject.toml` or `requirements.txt` and load environment variables exclusively via `.env` files mapped to `dagster.EnvVar` references rather than plaintext strings.
python -m pip install "dagster>=1.6.0" "dagster-webserver>=1.6.0" "dagster-duckdb>=0.22.0" pandas pyarrowfrom dagster import Definitions, load_assets_from_modules, EnvVar
from dagster_duckdb import DuckDBIOManager
from . import assets
all_assets = load_assets_from_modules([assets])
defs = Definitions(
assets=all_assets,
resources={
"io_manager": DuckDBIOManager(
database=EnvVar("DUCKDB_DATABASE_PATH").get_value("warehouse.duckdb")
)
}
)Always wrap database paths, S3 buckets, and credentials in `EnvVar` instances. Dagster resolves these lazily at runtime, preventing the AI agent from hardcoding local paths or credentials into python source code.
Do not commit `.env` containing sensitive warehouse credentials. Add `.env` and `*.duckdb` to `.gitignore` before allowing the agent to run verification routines.
Intent Matching & Trigger Invocation
Verify deterministic activation using frontmatter trigger phrases and specific SDA parameters.
Test the agent's ingestion of the skill by supplying a task containing one of the registered triggers (`create dagster asset`, `setup dagster partitions`, or `configure dagster io manager`). The agent must recognize the trigger and structure the Python asset with explicit types, metadata, and partition slices.
import pandas as pd
from dagster import asset, Output, MetadataValue, DailyPartitionsDefinition, AssetExecutionContext
DAILY_PARTITION = DailyPartitionsDefinition(start_date="2025-01-01")
@asset(
partitions_def=DAILY_PARTITION,
group_name="ingestion",
compute_kind="python"
)
def raw_telemetry_events(context: AssetExecutionContext) -> Output[pd.DataFrame]:
partition_date = context.partition_key
context.log.info(f"Processing partition: {partition_date}")
# Ingest partition data
df = pd.DataFrame({
"event_id": [f"{partition_date}_1", f"{partition_date}_2"],
"user_id": [101, 102],
"duration_ms": [342.5, 120.1]
})
return Output(
value=df,
metadata={
"record_count": MetadataValue.int(len(df)),
"partition_window": MetadataValue.text(partition_date),
"columns": MetadataValue.json({"fields": list(df.columns)})
}
)
@asset(
partitions_def=DAILY_PARTITION,
group_name="analytics",
compute_kind="python"
)
def daily_user_aggregates(raw_telemetry_events: pd.DataFrame) -> Output[pd.DataFrame]:
aggregated = raw_telemetry_events.groupby("user_id").agg({
"duration_ms": ["sum", "mean"]
}).reset_index()
aggregated.columns = ["user_id", "total_duration", "mean_duration"]
return Output(
value=aggregated,
metadata={
"user_count": MetadataValue.int(len(aggregated)),
"schema": MetadataValue.md("| column | type |\n|---|---|\n| user_id | int |\n| total_duration | float |")
}
)Always request both an upstream asset and downstream consumer in the same prompt to verify that the agent injects upstream assets as function arguments rather than invoking external loaders inside the function body.
Avoid prompt instructions like 'write a Dagster job with an op'. The skill prioritizes Software-Defined Assets; mixing `@op` and `@job` syntax confuses agent lineage resolution and creates antipattern warnings in Dagster 1.6+.
Verification, Linting & Output Quality Gate
Execute automated self-healing checks to ensure the Dagster asset graph compiles without cyclical dependencies.
Instruct the agent to validate the Dagster definitions repository using the official Dagster CLI toolchain and standard syntax linter before committing changes.
dagster definitions validate -f analytics_pipeline/definitions.py && ruff check analytics_pipeline/#!/usr/bin/env bash
set -euo pipefail
echo "Validating Dagster Definitions..."
dagster definitions validate -f analytics_pipeline/definitions.py
echo "Running Ruff lint checks..."
ruff check analytics_pipeline/
echo "Dagster Software-Defined Assets verified successfully."Run `dagster asset materialize --select raw_telemetry_events --partition 2025-01-01` in dry-run/mock testing mode to confirm end-to-end execution before opening pull requests.
If `dagster definitions validate` fails due to unresolvable upstream assets, check for typos in parameter names. In Dagster, function parameter names must identically match the upstream asset key.
Real-World Scenario: Partitioned E-Commerce Customer Analytics Pipeline with Column Lineage
“create dagster asset: In analytics_pipeline/assets.py, build two partitioned assets: 'stg_orders' which reads order events for a daily partition and attaches column schemas, and 'customer_daily_spend' which consumes 'stg_orders' to aggregate daily expenditure per customer. Use setup dagster partitions for DailyPartitionsDefinition starting 2025-01-01 and configure dagster io manager to use DuckDB in definitions.py.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent defined the downstream asset argument with a parameter name that does not match the upstream asset name, or omitted the asset from load_assets_from_modules/Definitions.
Ensure the parameter name in the downstream function matches the upstream asset function name exactly:
# Correct:
@asset(partitions_def=DAILY_PARTITION)
def customer_daily_spend(stg_orders: pd.DataFrame) -> Output[pd.DataFrame]:
...
# Ensure both are included in definitions:
defs = Definitions(assets=[stg_orders, customer_daily_spend])Root Cause: The requested materialization partition key precedes the configured `start_date` or formatting differs from '%Y-%m-%d'.
Verify the start date parameter in the partition definition: `DailyPartitionsDefinition(start_date='2025-01-01', fmt='%Y-%m-%d')`. Do not supply partitions dated prior to the defined `start_date`.Frequently Asked Questions (Dagster Software-Defined Assets & Data Lineage SOP)
Q:Can I use Dagster Software-Defined Assets & Data Lineage across Codex, Claude Code, and Cursor simultaneously?
Yes. The SKILL.md specification is runtime-agnostic. Runtimes read the frontmatter triggers and SOP guidelines directly, allowing you to build assets in Cursor, inspect them with Claude Code CLI, and validate syntax with Codex Desktop.
Q:How does Dagster Software-Defined Assets & Data Lineage prevent context window overflow during long agent sessions?
The skill enforces concise asset function definitions, standard modular definitions (`load_assets_from_modules`), and decoupled metadata schemas. This avoids passing massive monolithic pipeline files into LLM context and keeps files under 150 lines.
Q:Does this skill require escalated root or container permissions?
No. The skill is audited with a security score of 98/100, explicitly declares `shell_exec: false` and `net_access: false`, and operates entirely within workspace file boundaries using local Python execution environments.
Ready to equip your autonomous agent with Dagster Software-Defined Assets & Data Lineage?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.