prodigy 0.4.4

Turn ad-hoc Claude sessions into reproducible development pipelines with parallel AI agents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
## Environment Variables

Prodigy supports two types of environment variables:

1. **System Environment Variables**: Standard Unix environment variables that control Prodigy's behavior globally
2. **Workflow Environment Variables**: Variables defined in workflow YAML files that are available during workflow execution

This page documents both types. For details on how environment variables interact with other configuration sources, see [Configuration Precedence Rules](configuration-precedence-rules.md).

---

## Workflow Environment Variables

Workflows can define custom environment variables using the `env:` block. These variables are available to all commands within the workflow and support advanced features like secrets, profiles, and interpolation.

### Basic Syntax

```yaml
name: my-workflow

env:
  # Plain variables
  PROJECT_NAME: "prodigy"
  VERSION: "1.0.0"
  BUILD_DIR: "target/release"

commands:
  - shell: "echo Building $PROJECT_NAME version $VERSION"
  - shell: "cargo build --release --target-dir $BUILD_DIR"
```

### Variable Interpolation

Workflow environment variables can be referenced using two syntaxes:

- **`$VAR`** - Simple variable reference (shell-style)
- **`${VAR}`** - Bracketed reference (recommended for clarity and complex expressions)

```yaml
env:
  API_URL: "https://api.example.com"
  API_VERSION: "v2"
  ENDPOINT: "${API_URL}/${API_VERSION}"

commands:
  - shell: "curl ${ENDPOINT}/status"
  - claude: "/deploy --url $API_URL --version $API_VERSION"
```

### Secrets and Sensitive Data

Mark sensitive values as secrets to automatically mask them in logs and output:

```yaml
env:
  # Public configuration
  DATABASE_HOST: "db.example.com"

  # Secret configuration (masked in logs)
  DATABASE_PASSWORD:
    secret: true
    value: "super-secret-password"

  API_KEY:
    secret: true
    value: "sk-abc123..."

commands:
  - shell: "psql -h $DATABASE_HOST -p $DATABASE_PASSWORD"
  # Output: psql -h db.example.com -p ***
```

**Security Best Practices**:
- Always mark API keys, passwords, and tokens as secrets
- Never commit secret values to version control
- Use environment variable references for secrets: `value: "${PROD_API_KEY}"`
- Rotate secrets regularly

### Profiles for Multiple Environments

Profiles allow different values for different environments (dev, staging, prod):

```yaml
env:
  # API endpoints vary by environment
  API_URL:
    default: "http://localhost:3000"
    staging: "https://staging.api.com"
    prod: "https://api.com"

  # Credentials vary by environment
  API_KEY:
    secret: true
    default: "dev-key-123"
    staging:
      secret: true
      value: "${STAGING_API_KEY}"  # From system env
    prod:
      secret: true
      value: "${PROD_API_KEY}"

commands:
  - shell: "curl -H 'Authorization: Bearer ${API_KEY}' ${API_URL}/health"
```

**Activate a profile**:

```bash
# Use staging profile
prodigy run workflow.yml --profile staging

# Use prod profile via environment variable
export PRODIGY_PROFILE=prod
prodigy run workflow.yml
```

### Step-Level Environment Overrides

Individual commands can override workflow environment variables:

```yaml
env:
  NODE_ENV: "development"
  LOG_LEVEL: "info"

commands:
  # Uses workflow-level NODE_ENV
  - shell: "npm test"

  # Override for this command only
  - shell: "npm run build"
    env:
      NODE_ENV: "production"
      LOG_LEVEL: "warn"

  # Back to workflow-level NODE_ENV
  - shell: "npm start"
```

**Precedence**: Step env > Profile env > Workflow env > System env

### MapReduce Environment Variables

Environment variables work across all MapReduce phases (setup, map, reduce, merge):

```yaml
name: parallel-processing
mode: mapreduce

env:
  MAX_PARALLEL: "10"
  TIMEOUT: "300"
  OUTPUT_DIR: "/tmp/results"

setup:
  - shell: "mkdir -p $OUTPUT_DIR"
  - shell: "generate-work-items.sh > items.json"

map:
  input: "items.json"
  json_path: "$[*]"
  max_parallel: ${MAX_PARALLEL}  # Use env var for parallelism

  agent_template:
    - claude: "/process ${item.file} --timeout $TIMEOUT"
    - shell: "cp result.json ${OUTPUT_DIR}/${item.name}.json"

reduce:
  - shell: "echo Processed ${map.total} items to $OUTPUT_DIR"
```

**Advanced MapReduce Usage**:
- Use env vars for `max_parallel`, `timeout`, `agent_timeout_secs`
- Reference in `filter` and `sort_by` expressions
- Pass to validation and gap-filling commands

### Environment Files (`.env`)

Load variables from dotenv-format files (not yet implemented in Prodigy, but planned):

```yaml
env:
  env_files:
    - ".env"
    - ".env.${PRODIGY_PROFILE}"

# .env file format:
# PROJECT_NAME=prodigy
# VERSION=1.0.0
# API_KEY=sk-abc123
```

**Note**: This feature is planned but not yet available. Use system environment variables as a workaround.

### Complete Workflow Example

```yaml
name: deployment-workflow

env:
  # Project configuration
  PROJECT_NAME: "my-app"
  VERSION: "2.1.0"

  # Environment-specific settings
  DEPLOY_TARGET:
    default: "dev-server"
    staging: "staging-cluster"
    prod: "prod-cluster"

  # Secrets (masked in logs)
  DEPLOY_TOKEN:
    secret: true
    default: "${DEV_TOKEN}"
    prod:
      secret: true
      value: "${PROD_TOKEN}"

commands:
  - shell: "echo Deploying $PROJECT_NAME v$VERSION to $DEPLOY_TARGET"
  - shell: "docker build -t ${PROJECT_NAME}:${VERSION} ."
  - shell: "deploy --target $DEPLOY_TARGET --token $DEPLOY_TOKEN"
  # Output: deploy --target prod-cluster --token ***
```

Run with:

```bash
# Development deployment
prodigy run deploy.yml

# Production deployment
export PROD_TOKEN="secret-prod-token"
prodigy run deploy.yml --profile prod
```

---

## System Environment Variables

System environment variables control Prodigy's global behavior and configuration.

### Claude API Configuration

#### `PRODIGY_CLAUDE_API_KEY`

**Purpose**: Claude API key for AI-powered commands
**Default**: None
**Overrides**: Global and project `claude_api_key` settings

```bash
export PRODIGY_CLAUDE_API_KEY="sk-ant-api03-..."
```

This is the **recommended** way to provide API keys (more secure than storing in config files).

#### `PRODIGY_CLAUDE_STREAMING`

**Purpose**: Control Claude JSON streaming output
**Default**: `true` (streaming enabled by default)
**Valid values**: `true`, `false`

```bash
export PRODIGY_CLAUDE_STREAMING=false  # Disable streaming
```

When `false`, uses legacy print mode instead of JSON streaming.

### General Configuration

#### `PRODIGY_LOG_LEVEL`

**Purpose**: Logging verbosity
**Default**: `info`
**Valid values**: `trace`, `debug`, `info`, `warn`, `error`
**Overrides**: Global and project `log_level` settings

```bash
export PRODIGY_LOG_LEVEL=debug
```

#### `PRODIGY_EDITOR`

**Purpose**: Default text editor for interactive operations
**Default**: None
**Overrides**: Global `default_editor` setting
**Fallback**: `EDITOR` environment variable

```bash
export PRODIGY_EDITOR=vim
```

If neither `PRODIGY_EDITOR` nor `EDITOR` is set, Prodigy uses system defaults.

#### `EDITOR`

**Purpose**: Standard Unix editor variable (fallback)
**Default**: None
**Fallback for**: `PRODIGY_EDITOR`

```bash
export EDITOR=nano
```

**Precedence**: `PRODIGY_EDITOR` takes precedence over `EDITOR` if both are set.

#### `PRODIGY_AUTO_COMMIT`

**Purpose**: Automatic commit after successful commands
**Default**: `true`
**Valid values**: `true`, `false`
**Overrides**: Global and project `auto_commit` settings

```bash
export PRODIGY_AUTO_COMMIT=false
```

### Storage Configuration

#### `PRODIGY_STORAGE_TYPE`

**Purpose**: Storage backend type
**Default**: `file`
**Valid values**: `file`, `memory`
**Overrides**: Storage `backend` setting

```bash
export PRODIGY_STORAGE_TYPE=file
```

#### `PRODIGY_STORAGE_BASE_PATH`

**Purpose**: Base directory for file storage
**Default**: `~/.prodigy`
**Overrides**: Storage `backend_config.base_dir` setting

```bash
export PRODIGY_STORAGE_BASE_PATH=/custom/storage/path
```

**Alternative names** (deprecated, use `PRODIGY_STORAGE_BASE_PATH`):
- `PRODIGY_STORAGE_DIR`
- `PRODIGY_STORAGE_PATH`

### Workflow Execution

#### `PRODIGY_AUTOMATION`

**Purpose**: Signal automated execution mode
**Default**: Not set
**Set by**: Prodigy when executing workflows

```bash
export PRODIGY_AUTOMATION=true
```

This variable is **set automatically** by Prodigy during workflow execution. It signals to Claude and other tools that execution is automated (not interactive).

#### `PRODIGY_CLAUDE_CONSOLE_OUTPUT`

**Purpose**: Force Claude streaming output regardless of verbosity
**Default**: Not set
**Valid values**: `true`, `false`

```bash
export PRODIGY_CLAUDE_CONSOLE_OUTPUT=true
```

When set to `true`, forces JSON streaming output even when verbosity is 0. Useful for debugging specific runs without changing command flags.

### Complete Example

Set up a complete Prodigy environment:

```bash
# API key (recommended method)
export PRODIGY_CLAUDE_API_KEY="sk-ant-api03-..."

# Logging
export PRODIGY_LOG_LEVEL=info

# Editor
export PRODIGY_EDITOR=code

# Behavior
export PRODIGY_AUTO_COMMIT=true

# Storage
export PRODIGY_STORAGE_TYPE=file
export PRODIGY_STORAGE_BASE_PATH=/Users/username/.prodigy

# Development/debugging
export PRODIGY_CLAUDE_STREAMING=true
export PRODIGY_CLAUDE_CONSOLE_OUTPUT=false
```

### Environment Files

You can use `.env` files (not committed to version control) to manage environment variables:

```bash
# .env (add to .gitignore)
PRODIGY_CLAUDE_API_KEY=sk-ant-api03-...
PRODIGY_LOG_LEVEL=debug
PRODIGY_AUTO_COMMIT=false
```

Load with:

```bash
# Using direnv
eval "$(cat .env)"

# Using dotenv tool
dotenv run prodigy run workflow.yml

# Manually
export $(cat .env | xargs)
```

### Security Best Practices

1. **Never commit API keys** to version control
2. **Use environment variables** for secrets (not config files)
3. **Use `.env` files** (gitignored) for local development
4. **Use secret managers** (AWS Secrets Manager, Vault) in production
5. **Rotate keys regularly** and use project-specific keys when possible

**Example `.gitignore`**:

```
.env
.env.*
!.env.example
.prodigy/config.local.yml
```

### Precedence Summary

For any given setting, the effective value comes from (highest to lowest):

1. **CLI flags** (if applicable)
2. **Environment variables** ← This level
3. **Project config** (`.prodigy/config.yml`)
4. **Global config** (`~/.prodigy/config.yml`)
5. **Defaults** (built-in values)

Example:

```yaml
# ~/.prodigy/config.yml
log_level: info
```

```yaml
# .prodigy/config.yml
log_level: warn
```

```bash
export PRODIGY_LOG_LEVEL=debug  # This wins
```

**Result**: `log_level: debug`

### Checking Environment Variables

To see which environment variables are active:

```bash
# List all PRODIGY_* variables
env | grep PRODIGY_

# Check effective configuration (merges all sources)
prodigy config show
```

### See Also

- [Configuration Precedence Rules]configuration-precedence-rules.md
- [Global Configuration Structure]global-configuration-structure.md
- [Project Configuration Structure]project-configuration-structure.md
- [Storage Configuration]storage-configuration.md