# cwd Option

> The option that sets which folder the agent works in.

**Field:** Artificial Intelligence  
**Category:** Claude Agent SDK  
**Also known as:** Agent SDK cwd, Agent SDK working directory, Claude Agent SDK cwd

## Think of it like

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

## 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

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

## Example code

```typescript
cwd: "/work/session-a"
```

This session works in its own folder.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [additionalDirectories Option](https://learn.benibix.com/term/ai/additional-directories-option)
- [Primary Working Directory](https://learn.benibix.com/term/ai/primary-working-directory)
- [Working Directory](https://learn.benibix.com/term/development/working-directory)
- [settingSources Option](https://learn.benibix.com/term/ai/setting-sources-option)
- [Claude Agent SDK Hosting](https://learn.benibix.com/term/ai/agent-sdk-hosting)

![The agent at the top with three arrows down. The highlighted one goes to its cwd, /work/app, where its tools start. The other two go to added folders, ../shared-lib and ../docs. A note says every other folder on the machine stays out of reach.](https://learn.benibix.com/diagrams/ai9-sdk-folders.svg)

---

Source: https://learn.benibix.com/term/ai/cwd-option
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
