feat(integrations): support SPECIFY_<KEY>_EXTRA_ARGS env var for agent subprocess flags#2596
Open
doquanghuy wants to merge 1 commit into
Open
feat(integrations): support SPECIFY_<KEY>_EXTRA_ARGS env var for agent subprocess flags#2596doquanghuy wants to merge 1 commit into
doquanghuy wants to merge 1 commit into
Conversation
…t subprocess flags Read a per-integration env var (SPECIFY_<KEY>_EXTRA_ARGS) inside `SkillsIntegration.build_exec_args`, `MarkdownIntegration.build_exec_args`, and `TomlIntegration.build_exec_args` and append the parsed flags to the spawned agent's argv, gated per integration key. Operators can now opt into extra CLI flags (e.g. `SPECIFY_CLAUDE_EXTRA_ARGS=--dangerously-skip-permissions`) without modifying any SKILL or workflow YAML. Useful in CI / non-interactive contexts where the spawned `<agent> -p ...` would otherwise hang on an internal permission or input prompt invisible to the parent `specify workflow run` process. Key normalization: `kiro-cli` → `SPECIFY_KIRO_CLI_EXTRA_ARGS` (hyphen replaced with underscore, then uppercased). Default (env var unset or whitespace-only) is byte-identical to previous behaviour. Extra args are inserted between `-p prompt` and the model / output-format flags so they cannot clobber canonical Spec Kit args. Implementation: a single helper `IntegrationBase._apply_extra_args_env_var` encapsulates the env-var read + shlex parsing; each of the three concrete `build_exec_args` implementations calls it. Closes github#2595 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #2595.
Adds a per-integration env-var hook
(
SPECIFY_<KEY>_EXTRA_ARGS) so operators can inject extra CLIflags into the spawned agent subprocess without modifying any
SKILL or workflow YAML. The motivating use case is non-interactive
contexts (CI, batch, sandboxed eval) where the spawned
<agent> -p ...hangs silently on an internal permission orinput prompt invisible to the parent
specify workflow runprocess.
What changed
IntegrationBase._apply_extra_args_env_var(args)—reads
SPECIFY_<KEY>_EXTRA_ARGSfrom env (key normalized:-→
_, uppercased), parses withshlex.split, and appends toargs. No-op when the env var is unset or whitespace-only.
MarkdownIntegration.build_exec_args,TomlIntegration.build_exec_args, andSkillsIntegration.build_exec_argseach call the helper betweenargs = [self.key, "-p", prompt]and the model / output-formatappends — so extra args sit between
-p promptand thecanonical Spec Kit flags and cannot clobber them.
tests/integrations/test_extra_args.pywith 7 testscovering: default no-op, single-token, multi-token via shlex,
whitespace-only treated as unset, other-integration env var
ignored (per-key scoping), key normalization
(
kiro-cli→KIRO_CLI),requires_cli: Falseshort-circuit.
Default behaviour preserved
When
SPECIFY_<KEY>_EXTRA_ARGSis unset for the activeintegration,
build_exec_argsreturns byte-identical argv tobefore this change. Existing operators see no difference.
Examples
Testing
uv run specify --helppytest tests/ -q→2943 passed, 35 skipped (was 2936 before; +7 new tests
added in this PR).
specify workflow runagainst a Claude command step with
SPECIFY_CLAUDE_EXTRA_ARGS=--dangerously-skip-permissionsset — flag reaches the spawned
claude -p ...subprocessand the run completes non-interactively. Same workflow
without the env var still hangs as before (consistent with
the pre-PR behaviour).
Manual test results
Agent: Claude Code (CLI) | OS/Shell: macOS 14 / zsh
--dangerously-skip-permissionsappears between-p promptand--modelSPECIFY_GEMINI_EXTRA_ARGS=...does not affect Claude argv"--flag-a --flag-b 3"splits into 3 tokens" "→ no-opkiro-cli→KIRO_CLISPECIFY_KIRO_CLI_EXTRA_ARGScorrectly readrequires_cli: Falseshort-circuitbuild_exec_argsreturns None; env-var hook never reachedAI Disclosure
Used Claude Opus to draft the implementation (env-var hook +
helper extraction), the test suite, the issue body for #2595, and
this PR body. The reproducer scenario (non-interactive
claude -phang on permission prompts) was a real-world problem encountered
in operator practice. Code, tests, and design decisions were
human-reviewed before submission.