fix: set cwd to /vercel/sandbox/mono for Claude Code agent#94
fix: set cwd to /vercel/sandbox/mono for Claude Code agent#94sweetmantech merged 2 commits intomainfrom
Conversation
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>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis change enforces a fixed working directory for Claude code agent CLI invocations by adding Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (2)
src/sandboxes/__tests__/runClaudeCodeAgent.test.tssrc/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>
Summary
cwd: "/vercel/sandbox/mono"inrunClaudeCodeAgentso Claude Code always executes from inside the cloned monorepo/vercel/sandbox(the Vercel Sandbox default), missing CLAUDE.md and git contextTest plan
cwdis always set to/vercel/sandbox/monocwdfield🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Tests