Skip to content

[Feature]: Expose run_id as a workflow template variable #2590

@doquanghuy

Description

@doquanghuy

Problem Statement

Spec Kit prints Run ID: <8-char hex> at the end of
specify workflow run, but that identifier isn't exposed to
workflow YAMLs as a template variable. There is no
{{ context.run_id }} (or similar) for type: shell /
type: command steps to reference.

- id: dump-context
  type: shell
  run: 'echo "RUN_ID={{ context.run_id }}"'

{{ context.run_id }} resolves empty / errors today.

Proposed Solution

Expose the run id as a template variable. Three shapes:

  • A. {{ context.run_id }} — consistent with existing
    context.* / inputs.* / steps.X.output.*.
  • B. {{ runtime.run_id }} — separate namespace for
    machine-managed values.
  • C. SPECIFY_RUN_ID env var on the spawned subprocess.

A is the most discoverable.

Component

Other

AI Agent (if applicable)

All agents

Use Cases

  1. Telemetry / observability cross-join — stamp logs and events
    with the Spec Kit run id so external systems can join workflow
    runs to downstream artifacts.
  2. Per-run scratch / isolation — workflows running interactive
    operator commands want per-run storage to isolate concurrent
    runs.
  3. Run-id in artifact metadata — stable join key from artifact
    back to the producing run.

Acceptance Criteria

  • Chosen syntax resolves to the same hex string Spec Kit
    prints as Run ID:.
  • Defaults gracefully when not in a run context (e.g. dry-run)
    — empty string or sentinel, not an error.
  • Workflows that don't reference the variable continue to work
    unchanged.
  • Tests cover resolution inside type: shell run:,
    type: command input.args, and switch expressions.

Additional Context

Implementation should be small — threading the existing run id into
the template resolver's context map.

AI disclosure: drafted with Claude Opus, human-reviewed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions