Skip to content

fix: set cwd to /vercel/sandbox/mono for Claude Code agent#94

Merged
sweetmantech merged 2 commits intomainfrom
fix/claude-code-cwd
Mar 15, 2026
Merged

fix: set cwd to /vercel/sandbox/mono for Claude Code agent#94
sweetmantech merged 2 commits intomainfrom
fix/claude-code-cwd

Conversation

@sweetmantech
Copy link
Copy Markdown
Contributor

@sweetmantech sweetmantech commented Mar 15, 2026

Summary

  • Hardcodes cwd: "/vercel/sandbox/mono" in runClaudeCodeAgent so Claude Code always executes from inside the cloned monorepo
  • Without this, commands ran from /vercel/sandbox (the Vercel Sandbox default), missing CLAUDE.md and git context

Test plan

  • Added test asserting cwd is always set to /vercel/sandbox/mono
  • Updated existing exact-match tests to include the new cwd field
  • All 7 tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Configured the Claude code agent to operate from a consistent working directory.
  • Tests

    • Updated tests to validate working directory configuration behavior.

Without an explicit cwd, Claude Code runs from /vercel/sandbox (the
Vercel Sandbox default) instead of inside the cloned monorepo, missing
CLAUDE.md and git context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 15, 2026

Warning

Rate limit exceeded

@sweetmantech has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 7 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 335807cd-73d7-463b-8fb6-e515e106701b

📥 Commits

Reviewing files that changed from the base of the PR and between e5134b1 and bed4ee0.

📒 Files selected for processing (3)
  • src/sandboxes/__tests__/runClaudeCodeAgent.test.ts
  • src/sandboxes/cloneMonorepoViaAgent.ts
  • src/sandboxes/runClaudeCodeAgent.ts
📝 Walkthrough

Walkthrough

This change enforces a fixed working directory for Claude code agent CLI invocations by adding cwd: "/vercel/sandbox/mono" to the command options in runClaudeCodeAgent. The test file is updated to verify this behavior with expectation assertions.

Changes

Cohort / File(s) Summary
Working Directory Configuration
src/sandboxes/runClaudeCodeAgent.ts
Adds cwd: "/vercel/sandbox/mono" to commandOpts passed to sandbox.runCommand.
Test Updates
src/sandboxes/__tests__/runClaudeCodeAgent.test.ts
Updates two existing tests to expect the cwd field and introduces a new test validating default cwd behavior (22 lines added).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A bunny hops through sandy paths so clear,
Setting waypoints, working directories appear,
/vercel/sandbox/mono now the constant home,
No matter where commands wander or roam! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: setting the working directory to /vercel/sandbox/mono for the Claude Code agent, which is the core fix implemented across the modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/claude-code-cwd
📝 Coding Plan
  • Generate coding plan for human review comments

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

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/sandboxes/runClaudeCodeAgent.ts (1)

34-43: Use a module constant for the workdir literal to reduce drift.

"/vercel/sandbox/mono" is now a behavior-critical value. Consider extracting it to a local constant so future edits are less error-prone.

♻️ Suggested refactor
+const CLAUDE_CODE_WORKDIR = "/vercel/sandbox/mono";
+
 export async function runClaudeCodeAgent(
   sandbox: Sandbox,
   options: RunClaudeCodeAgentOptions,
 ): Promise<RunClaudeCodeAgentResult> {
@@
   const commandOpts: Record<string, unknown> = {
     cmd: "claude",
     args,
-    cwd: "/vercel/sandbox/mono",
+    cwd: CLAUDE_CODE_WORKDIR,
     detached: true,
     env: {
       ...env,
       CLAUDE_CODE_OAUTH_TOKEN: process.env.CLAUDE_CODE_OAUTH_TOKEN,
     },
   };

As per coding guidelines, "Extract shared logic into reusable utilities to follow DRY (Don't Repeat Yourself)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/sandboxes/runClaudeCodeAgent.ts` around lines 34 - 43, The work directory
string "/vercel/sandbox/mono" used in the commandOpts object is
behavior-critical and should be a module-level constant to avoid drift; add a
descriptive constant (e.g., DEFAULT_WORKDIR or CLAUDE_WORKDIR) near the top of
src/sandboxes/runClaudeCodeAgent.ts and replace the literal in the
commandOpts.cwd assignment with that constant (ensure any other occurrences in
this file use the same constant so runClaudeCodeAgent and commandOpts reference
a single source of truth).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/sandboxes/runClaudeCodeAgent.ts`:
- Around line 34-43: The work directory string "/vercel/sandbox/mono" used in
the commandOpts object is behavior-critical and should be a module-level
constant to avoid drift; add a descriptive constant (e.g., DEFAULT_WORKDIR or
CLAUDE_WORKDIR) near the top of src/sandboxes/runClaudeCodeAgent.ts and replace
the literal in the commandOpts.cwd assignment with that constant (ensure any
other occurrences in this file use the same constant so runClaudeCodeAgent and
commandOpts reference a single source of truth).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 92aeb347-5594-4503-9598-23a1c956edda

📥 Commits

Reviewing files that changed from the base of the PR and between 70f345c and e5134b1.

📒 Files selected for processing (2)
  • src/sandboxes/__tests__/runClaudeCodeAgent.test.ts
  • src/sandboxes/runClaudeCodeAgent.ts

cloneMonorepoViaAgent now passes cwd: "/vercel/sandbox" so the clone
runs from the sandbox root, while all other agent calls default to
/vercel/sandbox/mono (the cloned monorepo).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sweetmantech sweetmantech merged commit e2599e7 into main Mar 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant