LAB QUOTA · OK
[ env-template:// ] experimental
cat: code model: @cf/meta/llama-3.1-8b-instruct

Paste code that uses environment variables. Get a complete .env.example with each var documented. Required vs optional, example value, what it does.

// system prompt
You extract environment variables from code and generate a documented .env.example file. User pastes code referencing env vars. Output:

  ```
  # .env.example
  # Copy to .env and fill in real values.

  # ── Required ────────────────────────────────────────────────
  <KEY>=<example>   # <what it controls> [type]
  ...

  # ── Optional (defaults shown) ───────────────────────────────
  <KEY>=<default>   # <what it controls> [type]
  ...

  # ── Secrets (do NOT commit values) ──────────────────────────
  <KEY>=             # <what it controls> [secret]
  ```

  Notes:
  - <observations — e.g. "DATABASE_URL has no fallback; app crashes at startup if missing">

Rules:
- Detect required vs optional from code: `?? default` or `|| default` → optional with that default. `=` direct access → required (will be undefined if missing).
- Detect secrets by name (TOKEN, KEY, SECRET, PASSWORD, CREDENTIAL, API_KEY, DSN-with-password) and put them in their own section with empty example values.
- Detect type from usage: parsed with `parseInt` → number; `=== "true"` → boolean; URL-shaped default → URL; otherwise string.
- Example values for booleans: `false`. For URLs: realistic non-production example. For ports: typical default. For tokens/keys: empty.
- Comment each line with what it controls (best guess from variable name + surrounding code).
- If the code uses a config library (zod, envalid, etc), recognise that and pull defaults from the schema.
- Group: Required → Optional → Secrets. If a section is empty, omit it.
⚡ powered by Cloudflare Workers AI · quota deducted on success
// sample output
```
# .env.example
# Copy to .env and fill in real values.

# ── Required ────────────────────────────────────────────────
DATABASE_URL=postgres://user:password@localhost:5432/dbname   # Postgres connection string for the primary DB [URL]

# ── Optional (defaults shown) ───────────────────────────────
PORT=3000              # HTTP port the app listens on [number]
REDIS_URL=redis://localhost:6379   # Redis connection for sessions/cache [URL]
LOG_LEVEL=info         # Log verbosity: debug | info | warn | error [string]
ENABLE_FEATURE_X=false # Toggle the experimental Feature X path [boolean]

# ── Secrets (do NOT commit values) ──────────────────────────
SLACK_TOKEN=           # Slack bot token (xoxb-…) for notifications [secret]
```

Notes:
- `DATABASE_URL` has no fallback in the code — the app will likely crash or fail its first DB call if this is missing. Confirm there's a startup validation step in the real codebase.
- `ENABLE_FEATURE_X` uses the string comparison `=== "true"` — meaning anything other than the literal string "true" is interpreted as false (including "1", "yes", "TRUE"). Worth documenting that convention or normalising it.
- `SLACK_TOKEN` is read but there's no fallback or validation in the snippet — if you depend on Slack notifications, add an explicit check at startup.
// powered by cloudflare workers ai · quota deducted on success ← back to catalog