# env Option

> The option that sets env values for the agent.

**Field:** Artificial Intelligence  
**Category:** Claude Agent SDK  
**Also known as:** Agent SDK environment variables, Claude Agent SDK env

## Think of it like

It is like the bag of things you pack for a helper.

## Definition

env is the Agent SDK option that sets environment variables for the Claude Code process. The two SDKs treat it in different ways. In TypeScript, env replaces the whole set, so spread process.env into it to keep PATH and the rest. In Python, your values are merged on top.

## Example

Leo sets env to just his API key in TypeScript, and the agent can no longer find git. He spreads process.env in first, and it works.

## Example code

```typescript
env: { ...process.env, DEBUG: "1" }
```

Keep the inherited variables and add one.

## Why it matters

With no PATH, each shell command the agent runs fails. The error does not say why.

## Common mistake

Passing only your new variable in TypeScript. That wipes out all the rest.

## Three principles

- **TypeScript replaces.** Spread process.env.
- **Python merges.** Over the inherited.
- **For the agent's process.** Not your app.

## Related terms

- [Environment Variable](https://learn.benibix.com/term/infrastructure/environment-variable)
- [ClaudeAgentOptions](https://learn.benibix.com/term/ai/claude-agent-options)
- [settingSources Option](https://learn.benibix.com/term/ai/setting-sources-option)

---

Source: https://learn.benibix.com/term/ai/env-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.
