Skip to content

[Feature]: Add additional_context on workflow command steps for curated context provisioning #5533

Backlog

Description

@markuswondrak

Problem Statement

Today, workflow command steps (src/specify_cli/workflows/step/command/__init__.py) only forward input.args ($ARGUMENTS) to the dispatched integration command. When a workflow—or a workflow overlay—needs to provision curated, step-specific context (such as upstream check outputs, architecture constraints, or team guardrails), authors must either:

  • Pollute $ARGUMENTS by mixing domain input with out-of-band instructions, or
  • Drop down to type: prompt and lose the structured Spec Kit command (speckit.*).

Proposed Solution

Add an optional, expression-evaluated additional_context field to workflow command steps that injects out-of-band context into the dispatched agent turn while leaving $ARGUMENTS and installed command templates untouched:

- id: plan
  command: speckit.plan
  input:
    args: "{{ inputs.spec }}"
  additional_context: |
    Architecture constraints for this service:
    {{ steps.arch-check.output.stdout }}

Exploratory implementation ideas (not settled requirements; transport and event wiring remain implementation-planning decisions):

  1. CommandStep schema & evaluation:
    • Accept optional additional_context (string or expression resolving to string/null) in CommandStep.validate() and CommandStep.execute(), rejecting non-string values with a clear step contract error.
    • Evaluate {{ ... }} expressions against StepContext (treating None / empty string as unset).
  2. Scoped subprocess handoff:
    • Pass the resolved text to the dispatched child process via an explicit scoped env var (e.g., SPECKIT_ADDITIONAL_CONTEXT) inside dispatch_command() so concurrent fan-out branches stay isolated.
  3. Reuse existing event-envelope plumbing:
    • Extend .specify/events.py (src/specify_cli/events/) to emit SPECKIT_ADDITIONAL_CONTEXT once on agent startup (session_start / user_prompt_submit, guarded against duplicate emission) using each integration's native context envelope (additionalContext, hookSpecificOutput, additional_context, hook_specific_output, or plain stdout), and 0 bytes when unset.
  4. Explicit capability check:
    • Fail the step with an explicit error on integrations that do not support runtime context injection (mirroring reasoning_effort / context_size capability checks in specify_cli.integrations.base), rather than silently dropping additional_context.

Alternatives Considered

  • Appending context to input.args ($ARGUMENTS): Couples domain arguments with operational/guardrail context, clutters command artifacts/prompts, and breaks commands that treat $ARGUMENTS strictly as feature/spec input.
  • Using type: prompt instead of type: command: Loses structured Spec Kit command semantics, command template resolution, and workflow overlay targeting of command steps.
  • Silently ignoring additional_context on unsupported integrations: Risks silent policy/guardrail omission; failing explicitly matches Spec Kit's dispatch-setting contract.

Component

Agent integrations (command files, workflows)

AI Agent (if applicable)

All agents

Use Cases

  1. A workflow runs a deterministic shell step (e.g., architecture or dependency check) and passes its stdout as additional_context into command: speckit.plan without altering $ARGUMENTS.
  2. A team workflow overlay injects project guardrails or review criteria onto an existing command step (speckit.implement, speckit.specify) without duplicating or patching the command template.
  3. Parallel fan-out branches each pass branch-specific additional_context into concurrent command dispatches safely via child-process-scoped environment variables.

Acceptance Criteria

  • CommandStep.validate() and CommandStep.execute() accept optional additional_context (str / {{ ... }} expressions), validate its type, and resolve it against StepContext.
  • Capability check rejects additional_context with an actionable error on integrations without context-injection support (instead of silently dropping it).
  • Resolved additional_context is passed only to the dispatched child process (safe under parallel fan-out) without mutating parent process env or $ARGUMENTS.
  • On a normally initialized supported integration, the resolved additional_context is available to the agent exactly once for the dispatched command turn, without manual context-injection setup. When omitted or empty, it adds no context and existing command behavior is unchanged.
  • Automated tests cover positive and negative cases (validation, expression evaluation, capability rejection, process-env scoping, fan-out isolation, and event-envelope output across supported formats).
  • Workflow/step documentation updated to document additional_context and integration capability requirements.

Additional Context

AI Disclosure

Drafted with the pi coding agent (provider: github-copilot, model: gemini-4-hydrogen, reasoning effort: high, human-supervised) based on Discussion #5528 and codebase inspection. The issue was posted on behalf of @markuswondrak without prior review of its text.

Disclosure correction by the pi coding agent (GitHub Copilot, model: gpt-6.1-terra, reasoning effort: high, interactive mode); removed an unsupported claim of prior review.

Requirements clarification on behalf of @markuswondrak by the pi coding agent (provider: github-copilot, model: gpt-6.1-sol, reasoning effort: high, interactive/human-supervised mode): clarified the observable once-per-command context-delivery requirement and marked transport/event-wiring ideas as exploratory rather than settled requirements.

Activity

  1. added
    feature-assess
    on Nov 23, 2026
  2. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor

    Feature assessment — command-additional-context · Stage 1/5: Intake

    Idea Intake: Additional context for command steps

    Idea (as captured)

    "Add an optional, expression-evaluated additional_context field to workflow command steps that injects out-of-band context into the dispatched agent turn while leaving $ARGUMENTS and installed command templates untouched."

    Example provided in the issue:

    - id: plan
      command: speckit.plan
      input:
        args: "{{ inputs.spec }}"
      additional_context: |
        Architecture constraints for this service:
        {{ steps.arch-check.output.stdout }}

    The request asks for validation, capability checks, process-scoped dispatch, one-time context delivery, tests, and documentation updates.

    Restated

    The request proposes a first-class way for workflow command steps to pass curated operational context to the underlying integration dispatch without overloading $ARGUMENTS. The goal is to preserve structured command semantics while supporting per-step guardrails/context injection, including in fan-out execution.

    Origin & Context

    First-Glance Unknowns

    • [NEEDS CLARIFICATION: How many real workflows currently need additional_context, and for which commands?]
    • [NEEDS CLARIFICATION: Should additional_context be command-step-only, or shared with prompt for consistent semantics?]
    • [NEEDS CLARIFICATION: What exact once-per-command observability signal proves context was injected exactly once across all supported integrations?]
    • [NEEDS CLARIFICATION: Is context size bounded/truncated, and who owns that limit (workflow engine vs integration)?]

    Generated by 💡 Assess a Feature Request by Installing and Running Spec Kit for #5533 · copilot · gpt53codex · 63.2 AIC · ⌖ 0.687 AIC · ⊞ 27.7K · ◷

  3. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor

    Feature assessment — command-additional-context · Stage 2/5: Research

    Idea Research: Additional context for command steps

    • Slug: command-additional-context
    • Created: 2026-11-23T18:17:46Z
    • Evidence confidence (overall): medium

    Users & Demand

    Prior Art

    • Existing command-step configuration already supports argument payloads and dispatch/runtime controls (input.args, integration_args, integration_options, model, reasoning_effort, context_size) but does not document an additional_context field. — [source: docs/workflow-steps/types.md] (confidence: high)
    • Command-step execution and validation paths currently type-check known fields and dispatch settings; no explicit additional_context handling appears in CommandStep.execute()/validate(). — [source: src/specify_cli/workflows/step/command/init.py] (confidence: high)
    • Existing dispatch-setting capability checks already fail unsupported settings explicitly, establishing a precedent for feature-gated runtime options by integration. — [source: src/specify_cli/integrations/base.py; tests/workflows/test_dispatch_settings.py] (confidence: high)
    • Event plumbing already supports context envelopes across multiple integration output shapes (additionalContext, hookSpecificOutput, additional_context, hook_specific_output), which may reduce implementation risk for one-time context delivery wiring. — [source: src/specify_cli/events/init.py] (confidence: medium)

    Market & Context

    • Spec Kit positions agentic workflows as reusable, composable automation where overlays and step composition are first-class; friction in passing curated context to command steps can reduce reuse and force prompt-step fallbacks. — [source: docs/workflow-steps/types.md; docs/guides/agentic-sdlc.md] (confidence: medium)
    • Current workaround options are either embedding operational context into $ARGUMENTS or switching to prompt steps, both of which can weaken command-level abstraction boundaries. — [source: https://github.com/[Feature]: Add additional_context on workflow command steps for curated context provisioning #5533] (confidence: medium)

    Data & Constraints

    • Parallel fan-out behavior requires branch-local isolation; process-scoped environment handoff to child dispatch is aligned with this constraint, while parent-env mutation would be unsafe. — [source: issue [Feature]: Add additional_context on workflow command steps for curated context provisioning #5533 acceptance criteria + fan-out context in docs/workflow-steps/types.md] (confidence: medium)
    • Integration support is heterogeneous; explicit capability checks are required to prevent silent context loss on unsupported integrations. — [source: src/specify_cli/integrations/base.py; tests/workflows/test_dispatch_settings.py] (confidence: high)
    • Acceptance criteria require automated positive/negative coverage across validation, expression evaluation, capability rejection, env scoping, fan-out isolation, and envelope output behavior. — [source: https://github.com/[Feature]: Add additional_context on workflow command steps for curated context provisioning #5533] (confidence: high)

    Evidence Against the Idea

    • The demand signal is currently concentrated in a single issue without quantified impact across existing workflows; this weakens urgency confidence. — [source: https://github.com/[Feature]: Add additional_context on workflow command steps for curated context provisioning #5533] (confidence: medium)
    • Introducing a new command-step field plus cross-integration delivery semantics adds maintenance and compatibility surface area; without usage data, complexity may outweigh value. — [source: ASSUMPTION, informed by breadth of integration/event code] (confidence: medium)
    • Existing capabilities (integration_args, integration_options, prompt steps) may satisfy some cases, reducing marginal value if most contexts can already be expressed acceptably. — [source: docs/workflow-steps/types.md] (confidence: low)

    Gaps & Open Questions

    • [NEEDS CLARIFICATION: What measured frequency/severity of this pain exists across real workflow repositories?]
    • [NEEDS CLARIFICATION: Which integrations are expected to support context injection at launch vs explicitly unsupported?]
    • [NEEDS CLARIFICATION: What maximum additional_context payload is acceptable, and how should truncation/failure be surfaced?]
    • [NEEDS CLARIFICATION: How should retries/resume semantics treat one-time context emission to avoid duplicate or missing injection?]

    Sources

    Generated by 💡 Assess a Feature Request by Installing and Running Spec Kit for #5533 · copilot · gpt53codex · 63.2 AIC · ⌖ 0.687 AIC · ⊞ 27.7K · ◷

  4. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor

    Feature assessment — command-additional-context · Stage 3/5: Problem

    Problem Definition: Curated context in command workflows

    • Slug: command-additional-context
    • Created: 2026-11-23T18:17:46Z
    • Inputs used: intake.md | research.md

    Problem Statement

    Workflow authors need a reliable way to pass step-specific operational context (for example, guardrails or prior-step outputs) into command-step agent turns without changing the semantic meaning of $ARGUMENTS. Today, that separation is weak, which creates authoring friction and inconsistent behavior across reusable workflows and overlays.

    Affected Users & Stakeholders

    • Users: Workflow/package authors — must currently mix domain args and operational context or switch step types, reducing clarity and reuse.
    • Users: Teams running fan-out workflows — need branch-local context injection semantics that do not leak across parallel branches.
    • Stakeholders: Maintainers of workflow and integration surfaces — responsible for correctness, compatibility, and support burden of new step/runtime behavior.
    • Stakeholders: Project maintainers deciding feature scope/prioritization — need evidence that this pain is broad enough to justify added complexity.

    Goals

    • Preserve $ARGUMENTS as domain input while enabling curated, out-of-band context for command steps.
    • Maintain explicit failure behavior when integrations cannot honor context injection.
    • Keep parallel workflow execution safe (no parent-env mutation, no cross-branch leakage).

    Non-Goals

    • Designing concrete architecture, API contracts, or task breakdown for implementation.
    • Replacing existing prompt steps or generalizing all context semantics across every step type in this stage.
    • Introducing implicit/silent fallback behavior that drops requested context without an explicit signal.

    Success Metrics

    • Workflow authors can express command-step context without embedding it in $ARGUMENTS (baseline: unsupported as a first-class command-step field).
    • Unsupported integrations fail with actionable errors instead of silently dropping requested context (baseline: unknown for this specific capability).
    • Parallel fan-out command dispatches do not cross-contaminate context between branches (baseline: [NEEDS CLARIFICATION: no current regression metric provided]).
    • Documentation clearly explains field semantics and capability requirements (baseline: no additional_context command-step documentation present).

    Cost of Inaction

    If this remains unaddressed, teams will continue using less-clear workarounds (argument overloading or prompt-step fallbacks), which can erode command abstraction consistency, increase workflow maintenance burden, and make policy/guardrail context handling less predictable.

    Open Questions

    • [NEEDS CLARIFICATION: What proportion of active workflow repos currently need this capability versus existing fields?]
    • [NEEDS CLARIFICATION: Which integrations should be considered in-scope for initial support?]
    • [NEEDS CLARIFICATION: What payload-size and truncation rules are acceptable for runtime context injection?]
    • [NEEDS CLARIFICATION: What exact observable behavior constitutes “available exactly once” across event envelopes and resume/retry paths?]

    Generated by 💡 Assess a Feature Request by Installing and Running Spec Kit for #5533 · copilot · gpt53codex · 63.2 AIC · ⌖ 0.687 AIC · ⊞ 27.7K · ◷

  5. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor

    Feature assessment — command-additional-context · Stage 4/5: Concept

    Concept: Command-step curated context delivery

    • Slug: command-additional-context
    • Created: 2026-11-23T18:17:46Z
    • Recommended option: Option A — First-class additional_context on command steps

    Options

    Option A — First-class additional_context on command steps

    • Sketch: Add an optional command-step field that accepts text/expression-resolved text and is delivered to the dispatched agent turn as out-of-band context while leaving $ARGUMENTS unchanged. Keep behavior explicit when unset/empty and explicit failure on unsupported integrations.
    • Appetite: medium
    • Trade-offs: Improves workflow clarity and overlay composability; adds cross-surface complexity (workflow schema, dispatch handoff, integration capability checks, event delivery semantics, tests/docs).
    • Rabbit holes: Context-size handling, once-only delivery semantics across resume/retry, and consistent behavior across many integrations/envelopes.

    Option B — Keep current model; codify workaround patterns

    • Sketch: Do not add a new field. Document sanctioned patterns using existing input.args, integration_options, and prompt steps to carry curated context where needed.
    • Appetite: small
    • Trade-offs: Lowest implementation cost and compatibility risk; preserves current user friction and keeps command semantics less clean for context-heavy workflows.
    • Rabbit holes: Workarounds may diverge by team/integration, increasing long-term inconsistency and maintenance burden.

    Option C — Broader shared context-injection primitive across step types

    • Sketch: Introduce a generalized context mechanism applicable to both command and prompt (and possibly more step types), with shared validation and capability contracts.
    • Appetite: large
    • Trade-offs: Best long-term consistency if broadly needed; highest design/implementation complexity and larger blast radius than this request.
    • Rabbit holes: Scope expansion into step-model redesign, migration concerns, and increased risk of regressions across workflow execution paths.

    Recommendation

    Recommend Option A as the smallest concept that directly solves the stated command-step boundary problem while preserving existing command semantics. However, this recommendation depends on clarifying demand breadth and launch integration scope before implementation commitment.

    Out of Scope (for the recommended option)

    • Full architecture/specification details (deferred to /speckit-specify).
    • A generalized all-step context framework.
    • Silent compatibility fallbacks that ignore requested context on unsupported integrations.

    Assumptions to Validate

    • Multiple workflow authors beyond the filing contributor need this in practice.
    • Existing event-envelope and dispatch-capability patterns are sufficient to add this safely.
    • Integration maintainers can commit to explicit support/error behavior without excessive per-integration burden.

    Generated by 💡 Assess a Feature Request by Installing and Running Spec Kit for #5533 · copilot · gpt53codex · 63.2 AIC · ⌖ 0.687 AIC · ⊞ 27.7K · ◷

  6. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor

    Feature assessment — command-additional-context · Stage 5/5: Decision — verdict needs-clarification

    Decision: Additional context for command steps

    • Slug: command-additional-context
    • Decided: 2026-11-23T18:17:46Z
    • Verdict: needs-clarification
    • Artifacts reviewed: intake.md | research.md | problem.md | concept.md

    Scorecard

    Criterion Rating Justification
    Problem validity adequate The workflow-author pain is concrete and clearly articulated, with plausible impact on command-step clarity and reuse.
    Evidence strength weak Evidence is concentrated in a single issue with no quantified prevalence/impact across active workflows.
    Value vs. inaction adequate If real demand is broader, avoiding $ARGUMENTS pollution and preserving command semantics has clear value; inaction preserves recurring workaround friction.
    Feasibility / appetite adequate A medium-appetite concept exists and aligns with existing dispatch-setting and event-envelope patterns.
    Strategic fit adequate The request aligns with Spec Kit workflow ergonomics and composability goals.
    Risk posture weak Cross-integration behavior, payload limits, and once-only delivery semantics are not yet bounded with concrete acceptance thresholds.

    Verdict & Rationale

    needs-clarification. The problem and concept are credible, but the evidence base is not yet strong enough for a go: demand breadth, launch integration scope, and key runtime boundaries (size/once semantics) remain unresolved. Per decision rules, weak evidence must be clarified before promotion to specification.

    If needs-clarification

    • Blocking questions:
      • [NEEDS CLARIFICATION: What measurable prevalence/impact does this pain have across current workflow users (examples, counts, or repeated reports)?]
      • [NEEDS CLARIFICATION: Which integrations are required for initial support, and which are explicitly unsupported at launch?]
      • [NEEDS CLARIFICATION: What explicit limits and failure behavior apply when additional_context is oversized or empty?]
      • [NEEDS CLARIFICATION: What testable criterion proves “exactly once” delivery across normal run, fan-out, and resume/retry paths?]
    • Revisit stage: research

    If go — Handoff to /speckit-specify

    Not applicable for this verdict.

    Generated by 💡 Assess a Feature Request by Installing and Running Spec Kit for #5533 · copilot · gpt53codex · 63.2 AIC · ⌖ 0.687 AIC · ⊞ 27.7K · ◷

  7. added
    feature-needs-clarification
    on Nov 23, 2026
  8. mnriem commented on Nov 23, 2026

    @mnriem
    Collaborator

    @markuswondrak It is a go, but can you fill in the clarification so we know what was decided?

  9. markuswondrak commented on Nov 23, 2026

    @markuswondrak
    ContributorAuthor

    Clarifications for the open questions from the feature assessment, posted on behalf of @markuswondrak. They are the decisions the implementation will be built and reviewed against.

    1. Scope

    • additional_context is a field of command steps only, including steps that omit type.
    • There is no prompt-step field and no workflow.additional_context default. A prompt step already owns its whole prompt text.

    2. Supported integrations

    Support is derived from the existing event abstraction. There is no list of agents and no new capability declaration.

    • Capability: An integration supports additional_context when its CANONICAL_TO_NATIVE maps session_start and its context envelope for session_start is not suppress. The integration also has to have that hook installed in the project.
    • Single event: Only session_start is used. Every command step starts its own non-interactive CLI process, so one startup event per dispatch is enough. Using user_prompt_submit as well would need extra logic to prevent duplicate output.
    • Built-in handler: Spec Kit registers its own session_start handler, so a normally initialized project needs no manual setup. When no context is set, the handler writes 0 bytes.
    • Rejection: If the integration has no context-carrying session_start, or the hook is not installed (--events false or an override), the step fails before the CLI starts. The error names the reason. Context is never dropped silently.
    • Docs: The list of supporting integrations is generated from the integration registry, not written into the docs by hand.
    • Per-integration proof: Each supporting integration must show in its own tests that its non-interactive CLI mode fires session_start and passes the environment through to the hook process.

    3. Values and size

    • Literals: A literal value must be a string; anything else is reported by validate().
    • Unset values: An expression that resolves to null or "" counts as unset. The step then adds no context and skips the capability check, so existing behavior is unchanged.
    • Other types: A number, list, or mapping fails the step; it is not converted with str(). Use | to_json for structured data.
    • NUL and encoding: No NUL characters are allowed. On POSIX, the value must be encodable for the process environment. This reuses the shell step's env validation.
    • Transport: The resolved text is passed only to the dispatched child process, in SPECKIT_ADDITIONAL_CONTEXT. The workflow process's own os.environ is never changed. When no value is set, the variable is removed from the child environment, so a value inherited from the parent cannot leak into the step.
    • Size limit: At most 16 KiB (16,384 UTF-8 bytes), which stays below the per-variable limits on Linux and Windows. Larger values fail the step before the CLI starts, and the text is never truncated.
    • Errors: Error messages report only the type or byte length, never the text, because it can come from captured agent output.

    4. What "exactly once" means

    • Per startup event: For each session_start event, the built-in handler writes exactly one copy of the context in the integration's envelope. When the context is unset or empty, it writes 0 bytes.
    • Prompt unchanged: $ARGUMENTS and the command prompt are byte-for-byte the same as in a run without additional_context.
    • Re-fired events: If the agent fires session_start again inside its own session, for example after compacting its context, it gets the context again. That is intended and is not a duplicate.
    • fan-out: Each item's child process sees only its own value.
    • Retry and resume: A step that runs again is a new dispatch and resolves its expressions again from the current inputs, like every other command-step field today. A completed step is not run again.
    • Run state: The resolved value is stored in steps.<id>.output.additional_context, or null when unset, like input, model, and the dispatch settings. It is written to state.json but not printed and not written to log.jsonl. The docs carry the same plain-text warning as captured output.

    5. Why existing fields don't cover this

    Alternative Why it is not enough
    input.args It is substituted as $ARGUMENTS, which command templates treat as the feature or spec input. Guardrails would be read as part of the feature description.
    integration_args / integration_options They become CLI arguments or options, not model context, and integrations reject unknown values by default (validate_runtime_config).
    type: prompt It does not invoke the installed command, so the command's template, scripts, and hooks are lost.
    Overlays An overlay can only replace a whole step. With this field, an overlay replaces a command step with the same command plus additional_context, leaving the command template unchanged.
    Presets on the command template They apply project-wide to every invocation and cannot carry step-specific values ({{ steps.x.output.stdout }}) or per-item values in a fan-out.

    Out of scope

    • A prompt-step field and workflow-level defaults.
    • Injection through user_prompt_submit, and any de-duplication state.
    • Integrations without a context-carrying session_start, such as Vibe in its current event mapping.

    AI disclosure: Drafted on behalf of @markuswondrak by the pi coding agent (provider: github-copilot, model: claude-opus-5.5, reasoning effort: high, interactive and human-supervised). Each decision was discussed and chosen by @markuswondrak. The agent inspected the code and wrote the text; no implementation or validation was performed.

  10. markuswondrak commented on Nov 25, 2026

    @markuswondrak
    ContributorAuthor

    @mnriem does this work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-assessfeature-needs-clarification

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions