Skip to content

Bug: Prompts starting with '---' parsed as CLI options — silent launch failure #91

Closed

Description

@c-h-

Bug: Prompts starting with --- are parsed as CLI options, crashing the launch

Problem

When launching Claude Code via agentctl launch claude-code -p "<prompt>" where the prompt content begins with --- (e.g., YAML frontmatter from a spec file), Claude Code's argument parser interprets --- as an invalid CLI option flag and exits immediately:

error: unknown option '---

The session never starts. agentctl reports success ("Launched session pending-XXXXX") because the process was spawned, but it exits immediately with an arg parse error.

Reproduction

agentctl launch claude-code --cwd /tmp/test -p "---
title: test
---
Build this."

Impact

  • Silent failure — agentctl reports success but no work happens
  • Discovered after two wasted launches (dashboard-redesign and unified-feed)
  • Any prompt containing a spec file with YAML frontmatter will fail

Suggested Fixes

In agentctl (workaround):

  • Prefix prompts that start with - with a newline or space to prevent arg parser confusion
  • Or write the prompt to a temp file and use --prompt-file if Claude Code supports it

In Claude Code (root cause):

  • The --print -p argument should not be parsed for sub-options. Everything after -p should be treated as literal prompt text.

Environment

  • agentctl 1.5.2
  • Claude Code 2.1.52

Activity

  1. c-h- commented on Mar 5, 2026

    @c-h-
    CollaboratorAuthor

    Workaround available in v1.5.2: Use the new --file flag (#95) to avoid passing prompts with YAML frontmatter directly:

    # Instead of: agentctl launch claude-code -p "$(cat spec.md)"  # crashes if spec.md starts with ---
    # Use:
    agentctl launch claude-code --file spec.md -p "Build the spec"

    This avoids the arg parser seeing --- as a CLI option.

    Root cause still unfixed: The underlying issue (Claude Code's arg parser treating --- in prompt text as an option flag) remains. A proper fix would need to escape or quote the prompt before passing to the adapter, or use a --prompt-file approach if the adapter supports it.

    Leaving open to track the root cause fix.

  2. added 2 commits that reference this issue on Mar 5, 2026
    835bc7d
    269ea67
  3. c-h- commented on Mar 5, 2026

    @c-h-
    CollaboratorAuthor

    Fixed in PR #99

  4. added 3 commits that reference this issue on Mar 5, 2026
    8653477
    ec22bf3
    a105e53
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions