Skip to content

fix(claude): pass every --add-dir launch directory to Claude - #23281

Open
only21mil wants to merge 2 commits into
pingdotgg:mainfrom
only21mil:r13/a059-preserve-every-additional-directory-in-l
Open

only21mil wants to merge 2 commits into
pingdotgg:mainfrom
only21mil:r13/a059-preserve-every-additional-directory-in-l

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

The claude CLI declares --add-dir <directories...>. The flag can repeat, and its space form takes several directories: the CLI's own example is claude --add-dir ../apps ../lib. If you put that in Settings → Providers → Claude → Launch arguments, T3 keeps only one directory.

The cause is parseCliArgs, which stores one value per flag. A repeated --add-dir keeps only its last value, and the extra words of the space form become positionals that nothing reads. Two things break:

  • The Claude process gets only one of the launch-arg directories. The others are outside its permission scope, so Claude asks before touching files there.
  • Skill discovery scans only that one directory. Skills under the other directories' .claude/skills are missing from the $ and / menus.

The SDK's extraArgs is a Record<string, string | null>, so it can't carry a second --add-dir value anyway.

Change

  • claudeLaunchArgDirectories (in ClaudeSkills.ts) reads every --add-dir value the way the CLI does: repeated flags, the = form, and each word after the flag until the next option or --. It uses the existing tokenizeCliArgs, so quoting works as before.
  • discoverClaudeSkills scans each of those directories, with the same relative-path rule as before.
  • makeClaudeQueryOptions takes add-dir out of extraArgs, the same way it already handles append-system-prompt. It adds the directories to the SDK's typed additionalDirectories after the cwd and the attachments directory. The SDK sends each entry as its own --add-dir argument, and relative paths still resolve against the session cwd.

A bare --add-dir with no directory after it now adds nothing.

Size: +39/−16 production lines in two files. Tests: two new launch-arg rows in the existing discovery test and one new makeClaudeQueryOptions test.

Scope and approval

This is a focused bug fix for an existing setting. No issue covers the multi-directory case. #20156 reported that skills from --add-dir were missing from the menus, and #20167 fixed that for one directory. This PR extends the same path to every directory the CLI accepts. Two open PRs touch nearby lines. #21336 makes parseCliArgs stop at --, and the new helper also stops there. #22864 handles --settings, and its diff still applies cleanly on this branch.

Verification

New tests against main's source, then on the branch:

The two new tests fail against main's source

The same tests pass on the branch

I ran the real app on Linux, using production builds of main and this branch (vp build for web, vp pack for server). Each run had fresh state and its own HOME. Claude was the real claude CLI binary, version 2.1.306. ANTHROPIC_BASE_URL pointed it at a local Messages API stub, with a placeholder key, so no account was used. Both builds used the same launch arguments, and each of the two directories held one skill:

Claude launch arguments used for both builds

Typing $ in a Claude thread:

main: the skill menu lists only Alpha Notes from shared-a

branch: the skill menu lists Alpha Notes and Beta Review

Next I sent a message. While the turn ran I read the --add-dir arguments of the running Claude process, and I also read the environment block Claude sent to the stub. On main, ../shared-b is missing from both. On the branch, both directories reach Claude.

Claude process --add-dir arguments and Claude's additional working directories, main vs branch

Other checks on the branch:

  • Full ClaudeSkills.test.ts and ClaudeAdapterV2.test.ts: 228 passed. The existing --add-dir missing --add-dir "<dir>" row still passes.
  • Typecheck, lint and format: pass. The one lint warning, an unused layer in ClaudeAdapterV2.ts, is already on main.
# in apps/server
pnpm exec vp test run src/provider/Drivers/ClaudeSkills.test.ts src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
pnpm run typecheck
# in the repo root
FILES="apps/server/src/provider/Drivers/ClaudeSkills.ts apps/server/src/provider/Drivers/ClaudeSkills.test.ts apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts"
pnpm exec vp lint $FILES
pnpm exec vp fmt --check $FILES

Not checked:

  • macOS and Windows. The change has no platform-specific code, but I only ran Linux.
  • A tool call that reads a file in the second directory. The stub only answers with text, so the evidence is the arguments and the environment block Claude reported, not a permission prompt.
  • --allowedTools and --disallowedTools lose extra words through the same parser. That is a separate change.

Prior PRs

#20167 by @ScottN-PV made skill discovery read --add-dir from launch args, for issue #20156 by @Young-caveman. This PR keeps that discovery path and reads every directory instead of one.

Production fix, tests, PR description and images written with Claude Opus 5.5 in T3 Code Nightly.

🤖 Generated with Claude Opus 5.5 in T3 Code Nightly

Claude Code declares --add-dir <directories...>, so the flag can repeat
and the space form takes several words. parseCliArgs kept one value per
flag, so launches passed only the last directory and skill discovery
scanned only that one. Read every value with claudeLaunchArgDirectories
and send them through the SDK's additionalDirectories.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 22, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at f32a0e9

Macroscope's review found this PR approvable — This is a focused fix that preserves the default Claude path while correctly forwarding every explicitly configured --add-dir directory and discovering skills from those locations. The production change is localized and covered by targeted tests, with no schema, deployment, or static-analysis configuration impact.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between f32a0e9 and 441c08c.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dbf1d9a0-b071-4bb0-848c-5c860da850ba
📥 Commits

Reviewing files that changed from the base of the PR and between aa0158d and f32a0e9.

📒 Files selected for processing: 4
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
  • apps/server/src/provider/Drivers/ClaudeSkills.test.ts
  • apps/server/src/provider/Drivers/ClaudeSkills.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

Claude launch-argument handling now collects values from repeated and multi-value --add-dir flags. Skill discovery uses eligible directories, and Claude query options place the directories in additionalDirectories rather than extraArgs. Tests cover discovery and query-option behavior.

Changes: Claude add-dir handling

Layer / File(s) Summary
Collect directories for discovery
apps/server/src/provider/Drivers/ClaudeSkills.ts, apps/server/src/provider/Drivers/ClaudeSkills.test.ts
claudeLaunchArgDirectories collects values from repeated and multi-value --add-dir arguments. Skill discovery adds eligible values as roots. Tests cover arguments adjacent to missing directory paths.
Pass directories to Claude query options
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
Claude query options remove --add-dir from extraArgs and include its directory values in additionalDirectories. The test checks the workspace and attachments directories alongside the supplied values.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to f32a0

The directory-handling change is mergeable after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main fix: passing every --add-dir launch directory to Claude.
Description check Passed The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the cause, implementation, tests, manual verification, limitations, and related work.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

…y-in-l

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant