Repository navigation
Description
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
$ARGUMENTSby mixing domain input with out-of-band instructions, or - Drop down to
type: promptand 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):
CommandStepschema & evaluation:- Accept optional
additional_context(string or expression resolving to string/null) inCommandStep.validate()andCommandStep.execute(), rejecting non-string values with a clear step contract error. - Evaluate
{{ ... }}expressions againstStepContext(treatingNone/ empty string as unset).
- Accept optional
- Scoped subprocess handoff:
- Pass the resolved text to the dispatched child process via an explicit scoped env var (e.g.,
SPECKIT_ADDITIONAL_CONTEXT) insidedispatch_command()so concurrentfan-outbranches stay isolated.
- Pass the resolved text to the dispatched child process via an explicit scoped env var (e.g.,
- Reuse existing event-envelope plumbing:
- Extend
.specify/events.py(src/specify_cli/events/) to emitSPECKIT_ADDITIONAL_CONTEXTonce 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), and0 byteswhen unset.
- Extend
- Explicit capability check:
- Fail the step with an explicit error on integrations that do not support runtime context injection (mirroring
reasoning_effort/context_sizecapability checks inspecify_cli.integrations.base), rather than silently droppingadditional_context.
- Fail the step with an explicit error on integrations that do not support runtime context injection (mirroring
Alternatives Considered
- Appending context to
input.args($ARGUMENTS): Couples domain arguments with operational/guardrail context, clutters command artifacts/prompts, and breaks commands that treat$ARGUMENTSstrictly as feature/spec input. - Using
type: promptinstead oftype: command: Loses structured Spec Kit command semantics, command template resolution, and workflow overlay targeting ofcommandsteps. - Silently ignoring
additional_contexton 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
- A workflow runs a deterministic
shellstep (e.g., architecture or dependency check) and passes itsstdoutasadditional_contextintocommand: speckit.planwithout altering$ARGUMENTS. - A team workflow overlay injects project guardrails or review criteria onto an existing
commandstep (speckit.implement,speckit.specify) without duplicating or patching the command template. - Parallel
fan-outbranches each pass branch-specificadditional_contextinto concurrentcommanddispatches safely via child-process-scoped environment variables.
Acceptance Criteria
-
CommandStep.validate()andCommandStep.execute()accept optionaladditional_context(str/{{ ... }}expressions), validate its type, and resolve it againstStepContext. - Capability check rejects
additional_contextwith an actionable error on integrations without context-injection support (instead of silently dropping it). - Resolved
additional_contextis passed only to the dispatched child process (safe under parallelfan-out) without mutating parent process env or$ARGUMENTS. - On a normally initialized supported integration, the resolved
additional_contextis 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-outisolation, and event-envelope output across supported formats). - Workflow/step documentation updated to document
additional_contextand integration capability requirements.
Additional Context
- Approved in Discussion Idea: `additional_context` on workflow `command` steps for curated context provisioning #5528: Idea: `additional_context` on workflow `command` steps for curated context provisioning #5528
- Reuses event-envelope infrastructure (feat(events): context injection for opencode and JSON-envelope agent hooks #3934) and follows the dispatch-setting capability pattern (feat(workflows): add per-step reasoning effort and context size settings #5248).
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
github-actions commentedon Nov 23, 2026
Feature assessment — command-additional-context · Stage 1/5: Intake
Idea Intake: Additional context for command steps
additional_contexton workflowcommandsteps for curated context provisioning #5533Idea (as captured)
Restated
The request proposes a first-class way for workflow
commandsteps 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
additional_contexton workflowcommandsteps for curated context provisioning #5533)feature-assesslabel after issue submission with detailed proposal and acceptance criteria.First-Glance Unknowns
additional_context, and for which commands?]additional_contextbe command-step-only, or shared withpromptfor consistent semantics?]github-actions commentedon Nov 23, 2026
Feature assessment — command-additional-context · Stage 2/5: Research
Idea Research: Additional context for command steps
Users & Demand
input.args($ARGUMENTS), making curated guardrail/context injection awkward without changing command semantics. — [source: https://github.com/[Feature]: Addadditional_contexton workflowcommandsteps for curated context provisioning #5533] (confidence: medium)additional_contexton workflowcommandsteps for curated context provisioning #5533] (confidence: medium)Prior Art
input.args,integration_args,integration_options,model,reasoning_effort,context_size) but does not document anadditional_contextfield. — [source: docs/workflow-steps/types.md] (confidence: high)additional_contexthandling appears inCommandStep.execute()/validate(). — [source: src/specify_cli/workflows/step/command/init.py] (confidence: high)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
$ARGUMENTSor switching to prompt steps, both of which can weaken command-level abstraction boundaries. — [source: https://github.com/[Feature]: Addadditional_contexton workflowcommandsteps for curated context provisioning #5533] (confidence: medium)Data & Constraints
additional_contexton workflowcommandsteps for curated context provisioning #5533 acceptance criteria + fan-out context in docs/workflow-steps/types.md] (confidence: medium)additional_contexton workflowcommandsteps for curated context provisioning #5533] (confidence: high)Evidence Against the Idea
additional_contexton workflowcommandsteps for curated context provisioning #5533] (confidence: medium)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
additional_contextpayload is acceptable, and how should truncation/failure be surfaced?]Sources
additional_contexton workflowcommandsteps for curated context provisioning #5533 (host: github.com, policy: allowlisted)github-actions commentedon Nov 23, 2026
Feature assessment — command-additional-context · Stage 3/5: Problem
Problem Definition: Curated context in command workflows
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
Goals
$ARGUMENTSas domain input while enabling curated, out-of-band context for command steps.Non-Goals
promptsteps or generalizing all context semantics across every step type in this stage.Success Metrics
$ARGUMENTS(baseline: unsupported as a first-class command-step field).additional_contextcommand-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
github-actions commentedon Nov 23, 2026
Feature assessment — command-additional-context · Stage 4/5: Concept
Concept: Command-step curated context delivery
additional_contexton command stepsOptions
Option A — First-class
additional_contexton command steps$ARGUMENTSunchanged. Keep behavior explicit when unset/empty and explicit failure on unsupported integrations.Option B — Keep current model; codify workaround patterns
input.args,integration_options, andpromptsteps to carry curated context where needed.Option C — Broader shared context-injection primitive across step types
commandandprompt(and possibly more step types), with shared validation and capability contracts.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)
/speckit-specify).Assumptions to Validate
github-actions commentedon Nov 23, 2026
Feature assessment — command-additional-context · Stage 5/5: Decision — verdict needs-clarification
Decision: Additional context for command steps
Scorecard
$ARGUMENTSpollution and preserving command semantics has clear value; inaction preserves recurring workaround friction.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
additional_contextis oversized or empty?]If go — Handoff to
/speckit-specifyNot applicable for this verdict.
mnriem commentedon Nov 23, 2026
@markuswondrak It is a go, but can you fill in the clarification so we know what was decided?
markuswondrak commentedon Nov 23, 2026
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_contextis a field ofcommandsteps only, including steps that omittype.prompt-step field and noworkflow.additional_contextdefault. Apromptstep 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.
additional_contextwhen itsCANONICAL_TO_NATIVEmapssession_startand its context envelope forsession_startis notsuppress. The integration also has to have that hook installed in the project.session_startis used. Everycommandstep starts its own non-interactive CLI process, so one startup event per dispatch is enough. Usinguser_prompt_submitas well would need extra logic to prevent duplicate output.session_starthandler, so a normally initialized project needs no manual setup. When no context is set, the handler writes 0 bytes.session_start, or the hook is not installed (--events falseor an override), the step fails before the CLI starts. The error names the reason. Context is never dropped silently.session_startand passes the environment through to the hook process.3. Values and size
validate().nullor""counts as unset. The step then adds no context and skips the capability check, so existing behavior is unchanged.str(). Use| to_jsonfor structured data.envvalidation.SPECKIT_ADDITIONAL_CONTEXT. The workflow process's ownos.environis 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.4. What "exactly once" means
session_startevent, 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.$ARGUMENTSand the command prompt are byte-for-byte the same as in a run withoutadditional_context.session_startagain 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.steps.<id>.output.additional_context, ornullwhen unset, likeinput,model, and the dispatch settings. It is written tostate.jsonbut not printed and not written tolog.jsonl. The docs carry the same plain-text warning as captured output.5. Why existing fields don't cover this
input.args$ARGUMENTS, which command templates treat as the feature or spec input. Guardrails would be read as part of the feature description.integration_args/integration_optionsvalidate_runtime_config).type: promptcommandstep with the same command plusadditional_context, leaving the command template unchanged.{{ steps.x.output.stdout }}) or per-item values in afan-out.Out of scope
prompt-step field and workflow-level defaults.user_prompt_submit, and any de-duplication state.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.markuswondrak commentedon Nov 25, 2026
@mnriem does this work for you?