Skip to content
BENIBIX Learn

cwd Option

Also known as Agent SDK cwd, Agent SDK working directory, Claude Agent SDK cwd

The option that sets which folder the agent works in.

Think of it like

It is like telling a helper which room to work in.

Example

A service runs one agent for each customer. Each call gets its own folder, so no agent sees the files of another.

Why it matters

The working folder decides what the agent can see and change. The wrong one can touch the wrong files.

Definition

cwd is the Agent SDK option that sets the folder the agent works in. Its tools read, write and run commands from there, and it is where project files such as CLAUDE.md are found. If you leave it out, the agent uses the folder your own program runs in. When many sessions run on one machine, give each one its own cwd. That way they do not write over each other's files.

Example code

typescript
cwd: "/work/session-a"
This session works in its own folder.
cwd is the home folder. Other folders stay shut unless you add them.

Common mistake

Leaving it out in a server. Every session then shares the server's folder, and their files mix.

Key takeaways

  1. 1
    The agent's folder. Where its tools start.
  2. 2
    Defaults to yours. Your program's folder.
  3. 3
    One per session. When many share a machine.