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

# env

> Manage environment variables and secrets per environment.

# cirron env

Manage environment variables for your Cirron project environments (development, staging, production, etc.) via the Cirron API.

## Usage

```bash theme={null}
cirron env list [--env <environment>]
cirron env set <key> <value> [--env <environment>]
cirron env delete <key> [--env <environment>]
```

## Options

| Option      | Description        | Default      |
| ----------- | ------------------ | ------------ |
| `--env, -e` | Target environment | `production` |

## Subcommands

### list

List all environment variables for an environment. Sensitive values (keys containing `password`, `secret`, or `key`) are automatically masked.

```bash theme={null}
cirron env list --env production
cirron env list --env staging
cirron env list --env development
```

Example output:

```
Environment Variables (production)
API_URL: https://app.cirron.com
DB_PASSWORD: ********
SECRET_KEY: ********
DATABASE_URL: postgresql://user:pass@localhost:5432/db
DEBUG: false
```

### set

Set or update an environment variable.

```bash theme={null}
cirron env set API_URL https://app.cirron.com --env production
cirron env set DB_PASSWORD mypassword123 --env staging
cirron env set DEBUG true --env development
```

### delete

Delete an environment variable. Prompts for confirmation before deletion.

```bash theme={null}
cirron env delete SECRET_KEY --env staging
cirron env delete DEBUG --env development
```

## Security

* Values for keys containing `password`, `secret`, or `key` are masked in all output.
* Variables are transmitted encrypted and stored securely on the Cirron platform with per-project, per-environment access control.
* Never log secrets in CI; pass them via your CI's secret store. Regularly audit with `env list` and remove unused variables with `env delete`.

## Requirements

Requires a `cirron.yaml` with declared environments and an authenticated CLI session.

```json theme={null}
{
  "name": "my-project",
  "version": "1.0.0",
  "environments": {
    "development": {},
    "staging": {},
    "production": {}
  }
}
```

```bash theme={null}
cirron auth login
cirron env list --env production
```

## Examples

```bash theme={null}
# Development setup
cirron env set DEBUG true --env development
cirron env set API_URL http://localhost:3000 --env development
cirron env set DATABASE_URL postgresql://localhost/dev_db --env development

# Staging
cirron env set API_URL https://staging-app.cirron.com --env staging
cirron env set DEBUG false --env staging

# Production audit
cirron env list --env production
```

## CI/CD Integration

```yaml theme={null}
# GitHub Actions example
- name: Set Environment Variables
  run: |
    cirron env set API_URL ${{ secrets.API_URL }} --env production
    cirron env set SECRET_KEY ${{ secrets.SECRET_KEY }} --env production

- name: Deploy
  run: cirron deploy --env production
```

## Troubleshooting

| Error                                   | Resolution                                                               |
| --------------------------------------- | ------------------------------------------------------------------------ |
| `No cirron.yaml found`                  | Run `cirron init my-project`                                             |
| `Not authenticated`                     | Run `cirron auth login`; verify with `cirron auth status`                |
| `Failed to fetch environment variables` | Check connectivity, re-authenticate, verify `cirron config --get apiUrl` |
| `Invalid environment`                   | Ensure the name matches an entry under `environments` in `cirron.yaml`   |

## Related Commands

* **cirron auth** - Manage authentication
* **cirron config** - Manage CLI configuration
* **cirron deploy** - Deploy applications
* **cirron status** - Check system status
