Skip to content

feat(integrations): support SPECIFY_<KEY>_EXTRA_ARGS env var for agent subprocess flags#2596

Open
doquanghuy wants to merge 1 commit into
github:mainfrom
doquanghuy:feat/integrations-extra-args
Open

feat(integrations): support SPECIFY_<KEY>_EXTRA_ARGS env var for agent subprocess flags#2596
doquanghuy wants to merge 1 commit into
github:mainfrom
doquanghuy:feat/integrations-extra-args

Conversation

@doquanghuy
Copy link
Copy Markdown

Description

Closes #2595.

Adds a per-integration env-var hook
(SPECIFY_<KEY>_EXTRA_ARGS) so operators can inject extra CLI
flags 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 or
input prompt invisible to the parent specify workflow run
process.

What changed

  • New helper IntegrationBase._apply_extra_args_env_var(args)
    reads SPECIFY_<KEY>_EXTRA_ARGS from env (key normalized: -
    _, uppercased), parses with shlex.split, and appends to
    args. No-op when the env var is unset or whitespace-only.
  • MarkdownIntegration.build_exec_args,
    TomlIntegration.build_exec_args, and
    SkillsIntegration.build_exec_args each call the helper between
    args = [self.key, "-p", prompt] and the model / output-format
    appends — so extra args sit between -p prompt and the
    canonical Spec Kit flags and cannot clobber them.
  • New tests/integrations/test_extra_args.py with 7 tests
    covering: 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-cliKIRO_CLI), requires_cli: False
    short-circuit.

Default behaviour preserved

When SPECIFY_<KEY>_EXTRA_ARGS is unset for the active
integration, build_exec_args returns byte-identical argv to
before this change. Existing operators see no difference.

Examples

# Non-interactive Claude run in CI
SPECIFY_CLAUDE_EXTRA_ARGS="--dangerously-skip-permissions" \
    specify workflow run my-pipeline

# Per-integration scoping
SPECIFY_GEMINI_EXTRA_ARGS="--max-turns 3" specify workflow run …

# Multi-token via shlex
SPECIFY_CLAUDE_EXTRA_ARGS="--dangerously-skip-permissions --max-turns 3"# Hyphenated keys
SPECIFY_KIRO_CLI_EXTRA_ARGS="--some-flag" specify workflow run …

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests: pytest tests/ -q
    2943 passed, 35 skipped (was 2936 before; +7 new tests
    added in this PR).
  • Tested with a sample project: invoked specify workflow run
    against a Claude command step with
    SPECIFY_CLAUDE_EXTRA_ARGS=--dangerously-skip-permissions
    set — flag reaches the spawned claude -p ... subprocess
    and 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

Test Result Notes
Env var set → flag in argv PASS --dangerously-skip-permissions appears between -p prompt and --model
Env var unset → byte-identical argv PASS argv matches pre-PR shape exactly
Other-integration env var ignored PASS SPECIFY_GEMINI_EXTRA_ARGS=... does not affect Claude argv
Multi-token via shlex PASS "--flag-a --flag-b 3" splits into 3 tokens
Whitespace-only treated as unset PASS " " → no-op
Key normalization kiro-cliKIRO_CLI PASS env var SPECIFY_KIRO_CLI_EXTRA_ARGS correctly read
requires_cli: False short-circuit PASS build_exec_args returns None; env-var hook never reached

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (described below)

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 -p
hang on permission prompts) was a real-world problem encountered
in operator practice. Code, tests, and design decisions were
human-reviewed before submission.

…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>
@doquanghuy doquanghuy requested a review from mnriem as a code owner May 16, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Inject extra CLI flags into the agent subprocess via env var

1 participant