> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kubiya.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Environments

> Manage execution environments with variables, secrets, and integrations

Execution contexts with variables, secrets, and integrations for agent operations.

## Quick Start

```bash theme={null}
# List environments
kubiya environment list
```

**Output:**

```
🌍 Environments (1)

ID                                    NAME                 DESCRIPTION
2667caff-8d0e-4b5e-9c1a-3e5f0a7b2c9d  Default Environment  Default environment for agents
```

```bash theme={null}
# Get environment details
kubiya environment get <environment-id>

# Create environment
kubiya environment create --file environment.yaml
```

## List Environments

```bash theme={null}
# List all environments
kubiya environment list

# JSON output
kubiya environment list --output json
```

**Output:**

```
🌍 Environments (3)

ID                                    NAME                    DESCRIPTION
2667caff-8d0e-4b5e-9c1a-3e5f0a7b2c9d  Default Environment    Default environment for agents
a1b2c3d4-e5f6-7890-abcd-ef1234567890  Production            Production environment with AWS
b2c3d4e5-f6a7-8901-bcde-f12345678901  Staging               Staging environment for testing
```

## Get Environment Details

View complete environment configuration including variables, secrets, and integrations:

```bash theme={null}
# View environment configuration
kubiya environment get <environment-id>
```

**Output:**

```
🌍 Environment Details

ID: 2667caff-8d0e-4b5e-9c1a-3e5f0a7b2c9d
Name: Production
Description: Production environment with AWS integration

Variables:
  DATABASE_URL: postgres://prod-db.example.com:5432/mydb
  API_ENDPOINT: https://api.example.com
  LOG_LEVEL: info

Secrets:
  - aws-credentials
  - db-password
  - api-key

Integrations:
  - github
  - slack
  - aws

Created: 2025-01-10 14:23:45
Updated: 2025-01-15 09:12:30
```

## Create Environment

Create a new environment from a YAML configuration file:

```bash theme={null}
# Create from file
kubiya environment create --file environment.yaml
```

**environment.yaml:**

```yaml theme={null}
name: production
description: Production environment
variables:
  DATABASE_URL: "postgres://..."
  API_ENDPOINT: "https://api.example.com"
  LOG_LEVEL: "info"
secrets:
  - aws-credentials
  - db-password
integrations:
  - github
  - slack
```

**Example with multiple integrations:**

```yaml theme={null}
name: staging
description: Staging environment for testing
variables:
  DATABASE_URL: "postgres://staging-db.example.com:5432/mydb"
  API_ENDPOINT: "https://staging-api.example.com"
  DEBUG: "true"
secrets:
  - staging-aws-credentials
  - staging-db-password
integrations:
  - github
  - slack
  - datadog
  - pagerduty
```

## Update Environment

Update an existing environment configuration:

```bash theme={null}
# Update environment configuration
kubiya environment update <environment-id> --file environment.yaml
```

The update will merge new configuration with existing settings. To replace completely, delete and recreate the environment.

## Delete Environment

```bash theme={null}
# Delete environment
kubiya environment delete <environment-id>
```

<Warning>
  Deleting an environment does not delete agents or teams using it. They will need to be reconfigured with a new environment.
</Warning>

## Best Practices

### Organization

* Separate environments by stage (dev, staging, production)
* Use descriptive names and detailed descriptions
* Document variable purposes in environment descriptions
* Maintain environment definitions in version control

### Security

* Never store sensitive data in plain text variables - always use secrets
* Rotate secrets regularly with automated processes
* Use role-based access control for environment management
* Encrypt secrets at rest
* Enable and review audit logs for environment changes

### Variable Management

* Use consistent naming conventions (UPPER\_SNAKE\_CASE for env vars)
* Document required vs optional variables
* Provide sensible defaults where possible
* Use environment-specific values (don't share credentials across envs)

### Integration Management

* Only add integrations that are actually used
* Review integration permissions regularly
* Test integrations after adding or updating
* Document integration setup requirements

## Command Reference

```bash theme={null}
# List environments
kubiya environment list [--output json|yaml]

# Get environment details
kubiya environment get <id>

# Create environment
kubiya environment create --file env.yaml

# Update environment
kubiya environment update <id> --file env.yaml

# Delete environment
kubiya environment delete <id>
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Core Resources" icon="cube" href="/cli/core-resources">
    Create agents and teams in environments
  </Card>

  <Card title="Capabilities" icon="puzzle-piece" href="/cli/capabilities">
    Configure skills and policies for environments
  </Card>

  <Card title="Workers" icon="server" href="/cli/workers">
    Deploy workers for environment execution
  </Card>

  <Card title="On-Demand Execution" icon="bolt" href="/cli/on-demand-execution">
    Execute tasks in configured environments
  </Card>
</CardGroup>
