fix(server): thread cwd through Claude capability probe (#2048) #2124
main fromrefs/pull/2124/head·merged by juliusmarminge View on GitHubSummary#
probeClaudeCapabilities enables settingSources: ["user", "project", "local"] but never passed a cwd to the Claude Agent SDK, so the SDK resolved the "project" and "local" sources against the T3 server process cwd rather than the user's active project. Project-level .claude/skills/ was invisible in composer autocomplete even though those skills still executed when typed manually (#2048).
Why this matters#
From #2048 (@r3xsean, area: apps/server):
Project-level skills from
.claude/skills/are not discovered in the composer autocomplete when using the Claude provider. User-level skills from~/.claude/skills/appear correctly. Skills execute fine when typed manually - only the autocomplete/discovery is broken.
probeClaudeCapabilitiesenablessettingSources: ["user", "project", "local"]but does not passcwd, so the SDK resolves project/local sources relative to the T3 server process cwd.
Tested on 0.0.17-nightly.20260415.45 with 40+ project-level skills.
Changes#
apps/server/src/provider/Layers/ClaudeProvider.ts:
probeClaudeCapabilities(binaryPath, cwd?)now takes an optionalcwdand spreads{ cwd }into theclaudeQueryoptions when set. Whencwdis undefined the SDK keeps its previous behavior.subscriptionProbeCachekey becomes${binaryPath}|${cwd ?? ""}. Capacity bumped from 1 to 8 so switching between projects doesn't force a re-probe each time (the probe talks to the SDK's init path, which is not free).- Cache
lookupparses the composite key back into(binaryPath, cwd)before calling the probe. - Added a short comment on the probe explaining the
cwdcontract so future edits don't regress.
What this PR does NOT do#
The two arrow functions at lines 781-789 that feed subscriptionType and slashCommands into checkClaudeProviderStatus still receive binaryPath only. The final wire-up threads session.cwd from ProviderService (which already has it on hand at apps/server/src/provider/Layers/ProviderService.ts:110) into those lookups.
I'm happy to follow up with that caller change as a separate PR once this one lands and you confirm the shape of the probe is what you want. Keeping this PR tight to the probe layer so the diff is easy to review. If you'd prefer the wire-up in one PR, let me know and I'll expand.
Testing#
cd apps/server && bun run typecheck passes with exit 0.
No behavior change when the caller still passes undefined for cwd - the probe keeps its current fallback path.
Request#
@r3xsean on the thread has a 40-skill .claude/skills/ setup and reproduced the bug cleanly. Once the caller is wired, they're a good candidate for verification.
Fixes #2048 (probe layer only - caller wire-up to follow).
This contribution was developed with AI assistance (Claude Code).
Note
Low Risk
Scoped to Claude provider status/capability probing and caching; no auth or session execution path changes in this diff, with undefined cwd preserving prior SDK behavior.
Overview
Fixes broken composer autocomplete for project-level Claude skills when the capability probe used settingSources: ["user", "project", "local"] without a working directory—the SDK was resolving project and local config relative to the server process cwd, not the user's workspace.
probeClaudeCapabilities accepts an optional cwd and forwards it to claudeQuery when set. ClaudeDriver reads cwd from ServerConfig, passes it into the probe, and extends makeClaudeCapabilitiesCacheKey with a third segment (binaryPath, resolved Claude HOME, cwd) so cached probe results (slash commands, account metadata) are not reused across different workspace roots.
Tests cover the updated cache key shape and assert distinct keys for different cwd values.
Note
Thread cwd through Claude capability probe and cache key#
probeClaudeCapabilitiesin ClaudeProvider.ts now accepts an optionalcwdand passes it to the Claude subprocess, so project-level settings are respected during probing.makeClaudeCapabilitiesCacheKeyin ClaudeHome.ts appends a NUL-delimitedcwdsegment to the cache key, scoping cached capability results per working directory.- ClaudeDriver.ts reads
cwdfromServerConfigand passes it to both functions. - Behavioral Change: existing cached capability entries keyed without
cwdwill no longer match the new key format, causing a one-time re-probe on first use.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
🟢 Low
Layers/ClaudeProvider.ts:791The
probeKeyfunction includescwdin the cache key format${binaryPath}|${cwd ?? ""}, but the resolve callbacks incheckClaudeProviderStatusonly receivebinaryPathand never passcwd. This meanscwdis alwaysundefined, the cache key is always${binaryPath}|, and the SDK never receives the project directory for resolving.claude/skills/commands despite the comment explaining this is the purpose (#2048).✅ Resolved in 614529d5fa48fa8ae0693c030f5dada639bbce74
Approvability#
Verdict: Approved
Straightforward bug fix that threads
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).cwdthrough capability probing to ensure cache keys are unique per working directory. The changes are mechanical parameter passing with clear intent and appropriate test coverage.github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Good catch. Fixed in 614529d5.
ClaudeProviderLive now resolves cwd from ServerConfig at layer construction and threads it into both Cache.get calls, so the cache key actually reflects the active workspace instead of always being
${binaryPath}|. ServerConfig.cwd is the same value serverRuntimeStartup treats as workspaceRoot (serverRuntimeStartup.ts:199), so no new service surface was needed.Added three unit tests for the per-cwd key contract (distinct cwds, undefined/empty equivalence, distinct binaries).
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this4e3f2f0
juliusmarminge closed this
Thanks for taking this, @juliusmarminge - the capability probe respecting cwd fixes the confusing failures from #2048.
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
9515d4ef-dcd1-46d3-9013-5dc8bbe3c439You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share