spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

[Feature]: Add dry-run flag to preview spec output without AI invocation

Open fuleinist opened this issue 6 months ago • 2 comments

Problem Statement

When running commands like specify workflow run, the CLI immediately invokes the AI model to generate output. For large projects or when iterating on constitution/principles, users may want to preview what the output would look like without burning tokens or waiting for generation — especially useful in CI environments or when testing templates.

Proposed Solution

Add a --dry-run flag to specify workflow run. When enabled, the CLI prints the rendered prompt/inputs that would be sent to the AI for each step without actually making the API call. This lets users verify their workflow definitions, templates, and configuration are correct before spending time or money on actual generation.

Scope Re-scope (2026-06-04)

The original proposal also asked for --dry-run on specify specify and specify plan. After design review with maintainer @mnriem (comment https://github.com/github/spec-kit/pull/2704#issuecomment-4624465842), those were intentionally not added:

"The specify CLI is NOT the command executor — coding agent is. The per-stage surface (/speckit.specify, /speckit.plan, ...) belongs to the agent, not the CLI."

specify specify and specify plan are scaffolders — they copy .specify/scripts/<variant>/ and .specify/templates/ into the project. There is nothing meaningful to "dry run" in that copy step; the actual AI invocation is the coding agent's job (Claude / Copilot / Cursor / etc.), not the CLI's. The only place where the CLI itself drives a step-based invocation is specify workflow run, which is what this issue now targets.

Acceptance Criteria

  • [x] --dry-run flag added to specify workflow run command
  • [x] Output shows the rendered prompt/configuration per step without AI invocation
  • [x] Clear message indicates this is a dry run with no actual generation
  • [x] AI invocation short-circuits across CommandStep, GateStep, and PromptStep
  • [x] dry_run flag persists across workflow resume so an interrupted dry-run does not silently become a real run
  • [x] --json mode emits a single well-formed JSON object (no banner / preview leak on stdout)

Out of scope (intentional)

  • --dry-run on specify specify / specify plan — see scope re-scope above
  • start_at / stop_after step-ID filtering — separate concern, would be a follow-up PR

Implementation

Tracked in PR #2704 (https://github.com/github/spec-kit/pull/2704). Once that PR merges, this issue closes.

Alternatives Considered

  • Running in a separate sandboxed environment — heavyweight, impractical for quick iteration
  • Checking generated output after the fact — wastes tokens on incorrect configurations
  • Modifying templates blindly — error-prone without feedback

Component

Specify CLI (workflows)

AI Agent (if applicable)

All agents (only via the per-step integrations that specify workflow run already wires up; the per-stage agent surface is unchanged).

Use Cases

  1. When authoring custom workflow definitions, preview the rendered prompts and command invocations before running for real
  2. When onboarding new team members, demonstrate a workflow's step sequence without making API calls
  3. When debugging a workflow failure, surface the partial step previews that were resolved before the failure point

Additional Context

Addresses token cost concerns in large teams and CI environments. Similar to how kubectl apply --dry-run works for Kubernetes manifests.

fuleinist avatar May 21 '26 14:05 fuleinist

Go for it!

mnriem avatar May 26 '26 12:05 mnriem

Closing as won't-fix after the design review on #3933.

The core ask — preview what a workflow will do without running it — doesn't have a truthful answer for this engine, for two compounding reasons:

  1. Control flow (condition, if_then, loops, fan-out, gates) branches on runtime step output that only exists once the agent runs. Any preview stubs that output and evaluates the branches against fabricated data, producing a counterfactual path presented as a real one.
  2. The step set is open. Custom step types register via load_custom_steps and are opaque to us — a preview can't stub what it doesn't know, so those steps run for real and their outputs feed downstream branches. You cannot soundly preview a program whose instruction set is user-extensible.

A static validate/resolve inherits the same ceiling in a quieter form — green-checking workflows that fail for real and only honestly speaking to literal inputs, which is false confidence about the parts that break.

This follows directly from "the CLI is not the executor, the agent is": previewing the program without the agent, and without knowledge of third-party steps, means previewing it without the things that decide what actually happens.


Disclosure: this assessment and note were worked through together by me (@mnriem) and GitHub Copilot (model: Claude Opus 4.8); I reviewed and endorse it.

mnriem avatar Aug 03 '26 15:08 mnriem