Skip to content

CLI --add-dir flags not forwarded to Claude Code #798

@FurlanLuka

Description

@FurlanLuka

Problem

When passing --add-dir flags to happy, they are not forwarded to the underlying Claude Code process. Claude Code starts but only has access to the primary working directory.

# Works — Claude sees all dirs:
claude --add-dir /path/to/other-repo "prompt"

# Broken — Claude only sees cwd:
happy --add-dir /path/to/other-repo "prompt"

The agent confirms only the primary working directory is configured:

"I don't see any extra directories configured in this session — only api is in my working context."

Additional finding

Positional prompt arguments are also not working:

happy --add-dir /tmp "test"
# → Error: Input must be provided either through stdin or as a prompt argument when using --print

Root cause

Traced through the source:

  1. index.ts--add-dir is correctly captured in unknownArgsoptions.claudeArgs
  2. runClaude.tsloop()SessionclaudeArgs flows through ✅
  3. claudeLocalLauncher.tsclaudeLocal.tsargs.push(...opts.claudeArgs)
  4. claudeRemote.tsclaudeArgs are NOT passed to the SDK query() call ❌

The SDK's QueryOptions in query.ts has no additionalDirs or equivalent option. When happy switches to remote mode (which happens when the message queue has items), --add-dir is silently dropped.

Even in local mode, the positional prompt arg appears to not reach Claude correctly through the launcher chain.

Proposed fix

  1. Add additionalDirs?: string[] to QueryOptions in query.ts, mapping to --add-dir flags
  2. In claudeRemote.ts, extract --add-dir values from claudeArgs and pass them as additionalDirs
  3. Ensure positional prompt args work through the local launcher path

Environment

  • happy: latest (npm)
  • Claude Code: v2.1.63 (Homebrew)
  • OS: macOS + Ubuntu (same behavior on both)

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