Skip to content

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

@doquanghuy

Description

@doquanghuy

Problem Statement

SkillsIntegration.build_exec_args() in
src/specify_cli/integrations/base.py:853 always dispatches the
agent subprocess as [self.key, "-p", prompt]. There is no
documented way to inject extra flags (e.g.
--dangerously-skip-permissions for Claude, or any agent-specific
flag for Gemini, Codex, Kiro CLI, etc.).

In CI / non-interactive contexts, the spawned <agent> -p ...
then hangs silently when it hits an internal permission or input
prompt. The prompt is invisible to the parent process, so
specify workflow run sits at ▸ speckit.X … until a
process-level timeout.

Proposed Solution

Read a per-integration env var in build_exec_args and append the
parsed flags to the argv. Generic shape so every requires_cli
integration gets the same affordance:

import os, shlex

args = [self.key, "-p", prompt]
env_name = f"SPECIFY_{self.key.upper().replace('-', '_')}_EXTRA_ARGS"
extra = os.environ.get(env_name, "").strip()
if extra:
    args.extend(shlex.split(extra))
if model:
    args.extend(["--model", model])
if output_json:
    args.extend(["--output-format", "json"])
return args
  • SPECIFY_CLAUDE_EXTRA_ARGS="--dangerously-skip-permissions"
    threads the flag into the spawned claude -p.
  • SPECIFY_GEMINI_EXTRA_ARGS, SPECIFY_CODEX_EXTRA_ARGS,
    SPECIFY_KIRO_CLI_EXTRA_ARGS, … all work the same way.
  • Default (env var unset for the active integration): byte-identical
    argv to today.
  • Inserted between -p prompt and --model so it cannot clobber
    the canonical Spec Kit flags.

If you'd prefer a Claude-only SPECIFY_CLAUDE_EXTRA_ARGS gated on
self.key == "claude" (smaller blast radius), happy to scope down.

Component

Agent integrations (command files, workflows)

AI Agent (if applicable)

All agents

Acceptance Criteria

  • SPECIFY_<KEY>_EXTRA_ARGS for the active integration → flag
    appears between -p prompt and --model.
  • Env var unset → byte-identical argv to today.
  • Env var for a different integration's key → ignored.
  • Multi-token value parsed via shlex.split.
  • Key normalization (e.g. kiro-cliKIRO_CLI) covered.
  • Tests cover all five cases.

Additional Context

AI disclosure: drafted with Claude Opus, human-reviewed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions