dagster: Command for Claude Code

.claude/commands/migrate-nt-to-record.md

migrate-nt-to-record is a command for Claude Code from dagster-io/dagster. It costs 0 tokens per session (554 once invoked), scanned A, original, Apache-2.0.

A command that converts a Python NamedTuple class into a class using Dagster's @record decorator. NamedTuple is a Python pattern for small data objects with named fields; the decorator provides the replacement format described by the command.

In plain words
What is it for?
Migrating NamedTuple definitions, choosing between @record and @record_custom, and preserving checks, defaults, and collection conversions.
Why use it?
It reduces the manual work of changing class structure while preserving custom validation and conversions when they are needed.

Command for Claude Code

Written for Claude Code: installed under .claude/.

This is dagster-io/dagster's own configuration. It tells Claude Code how to work on dagster itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything dagster configures →

About the project

Dagster is a platform for developing, running, and observing data assets, such as datasets and the processes that produce them. It is used to organize and automate data workflows.

dagster-io/dagster · 16,132 stars · on GitHub · dagster.io

Reuse

Borrowing it

Nothing to install: this file belongs to dagster-io/dagster. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/dagster-io/dagster/master/.claude/commands/migrate-nt-to-record.md
Clone the repo
git clone --depth 1 https://github.com/dagster-io/dagster

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for migrate-nt-to-record

README.md
[![agentmods](https://agentmods.dev/badge/commands/dagster-io/dagster/migrate-nt-to-record/github.svg)](https://agentmods.dev/commands/dagster-io/dagster/migrate-nt-to-record)
Your own site
<a href="https://agentmods.dev/commands/dagster-io/dagster/migrate-nt-to-record"><img src="https://agentmods.dev/badge/commands/dagster-io/dagster/migrate-nt-to-record/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for migrate-nt-to-record

Your own site · 80×15
<a href="https://agentmods.dev/commands/dagster-io/dagster/migrate-nt-to-record"><img src="https://agentmods.dev/badge/commands/dagster-io/dagster/migrate-nt-to-record.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 554 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00554
Opus 5 $0.00000 $0.00277
Sonnet 5 $0.00000 $0.00111
Haiku 4.5 $0.00000 $0.00055

Measured 10d ago against content hash b12c17e8e427, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

migrate-nt-to-record scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/migrate-nt-to-record.md · 59 lines

How it starts

The opening of the file, as written. The whole thing — 59 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Migrate NamedTuple to @record

Convert the specified NamedTuple class to use @record from dagster_shared.record.

Use @record (simple case)

When __new__ only contains check.*_param calls with no coercion:

@record
class Foo:
    x: str
    y: Optional[int] = None

Use @record_custom when:

  1. Any custom logic - validation, invariants, conditionals
  2. Collection coercion - check.opt_*_param coerces None → empty collection

Coercion functions requiring @record_custom:

  • check.opt_mapping_param / check.opt_dict_param{}
  • check.opt_list_param / check.opt_sequence_param[]
  • check.opt_set_paramset()

Callers may pass None explicitly even without a default - preserve the coercion:

@record_custom
class Foo(IHaveNew):
    tags: Mapping[str, str]

    def __new__(cls, tags: Optional[Mapping[str, str]] = None):
        return super().__new__(cls, tags={} if tags is None else tags)

When using @record_custom, there should be no defaults set on the field definitions, only the __new__ arguments.

Conversion steps

  1. Remove NamedTuple inheritance and inline field definitions
  2. Add @record or @record_custom decorator
  3. Move fields to class body with type annotations
  4. Delete check.*_param calls (auto-generated) unless coercion needed
  5. Keep only custom validation in __new__ for record_custom
  6. Handle NamedTuple method usage - search codebase for calls to ._replace(, ._asdict(, ._fields on this class:
    • Option A: Update callsites to use @record equivalents (from dagster_shared.record):
      • obj._replace(...)copy(obj, ...) or replace(obj, ...)
      • obj._asdict()as_dict(obj)
      • Cls._fieldsget_record_annotations(Cls).keys()
    • Option B: Add LegacyNamedTupleMixin to preserve NamedTuple API compatibility
  7. Use kwargs only in super().__new__() for record_custom
  8. Run just ruff

Positional args

For public APIs needing positional arg support: @record(kw_only=False)

Read the full file on GitHub · 59 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 59 lines · 0 tokens per session scan A b12c17e8e427

Subscribe to this mod's changes

migrate-nt-to-record is a command published in the GitHub repository dagster-io/dagster (16,132 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 554 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.