---
name: demo-generate
description: Submit a billing data generation job for existing config(s).
---

# /demo-generate

You are submitting a billing data generation job for an SE. You validate
configs and submit — you never modify config files or wait for completion.

## Context

- **Workspace**: the current directory is a czbg-workspace created by `czbg init`
- **Configs**: YAML files organized as `configs/{demo-name}/{provider}/{category}/generate/` (created by `/demo-plan`)
- **Submit command**: `czbg generate run --config-path <path> --description "..."`
- **Monitor command**: `czbg jobs describe <job_id>`
- **Variance command**: `czbg variance run <dataset_id>` — applies realistic hourly/daily cost jitter

## Rules

1. **Never modify config files** — if changes are needed, tell the SE to use
   `/demo-plan` first.
2. **Always validate before submission** — run `czbg analyze config` and block
   if there are errors (ref_matches = 0, Unknown provider, etc.).
3. **Always confirm with the SE** before submitting — show what will be submitted.
4. **Never wait for job completion** — generation takes 10-60+ minutes. Report
   the job ID, monitoring commands, and any follow-up steps, then stop.
5. **Variance is for base configs only** — if the config path contains `/base/`,
   include the variance follow-up command in the report. Optimize, anomaly, and
   unit-econ configs already have intentional cost shapes that variance would distort.

## Arguments

`/demo-generate [config-path]`

- `config-path` — optional path to a config file, directory, or demo name.
  If omitted, list available demos in `configs/`.

The argument string is: $ARGUMENTS

## Workflow

### Step 1: Identify Configs

If the SE provided a config path in `$ARGUMENTS`, use it. If they provided
a demo name (e.g., `acme-corp`), resolve to `configs/acme-corp/`.

Otherwise, list available demos:

```bash
ls -d configs/*/
```

Show the demo names and ask the SE which one to submit. If `configs/`
is empty, tell the SE: "No configs found. Use `/demo-plan` to create one first."

### Step 2: Validate

Run the config analyzer with `--json` for structured output:

```bash
czbg analyze config <path> --json
```

Parse the JSON and enforce these gates. Any failure → BLOCK submission:

1. **Per-job**: for every job in `job_analyses`:
   - `job_config.reference_match_count == 0` → BLOCK. Tell SE: "Job '<name>'
     has zero reference matches — filters don't match reference data. Fix
     with `/demo-plan` before submitting."
2. **Per-provider aggregate**: sum `peak_month_line_items` across ALL jobs for
   each provider. If the total for any provider exceeds 10,000,000 → BLOCK.
   Tell SE: "Total peak line items for {provider} ({N:,}) exceed 10M limit.
   Reduce resource_count or narrow usage_types with `/demo-plan`."

If all gates pass, proceed. Also show the human-readable analysis:

```bash
czbg analyze config <path>
```

### Step 3: Confirm

Present a summary to the SE:

```
Ready to submit generation job:
  Config: configs/<name>.yaml
  Jobs: <N> generation jobs
  Providers: AWS, GCP
  Estimated peak line items: <N>
  Total cost: $<N>

Submit? (yes/no)
```

Wait for explicit confirmation before proceeding.

### Step 4: Submit

Build the description automatically from the config path and the SE's name:

```bash
# Get the SE's name (macOS full name, fallback to git, then username)
id -F 2>/dev/null || git config user.name 2>/dev/null || whoami
```

**Description format**: `{demo-name}: {category} {provider} ({se-name})`

Examples:
- `acme-corp: base AWS (Sarah Chen)`
- `acme-corp: optimize GCP, Azure (Sarah Chen)`

Show the SE the generated description and let them override it if they want.

```bash
czbg generate run --config-path <path> --description "<description>"
```

If the command fails, show the error and suggest remediation:
- Auth error → "Check AWS credentials: `aws sso login --profile ...`"
- Config parse error → "Config YAML may be malformed. Check with `/demo-plan`."
- API error → "The CZBG API may be unavailable. Try again in a few minutes."

### Step 5: Report

After successful submission, show the job ID and monitoring commands.

**If the config path contains `/base/`**, include the variance follow-up:

```
Job submitted successfully.
  Job ID: <job_id>

Monitor progress:
  czbg jobs describe <job_id>

Generation typically takes 10-60 minutes depending on config size.

After generation completes, run the variance pass to add realistic cost jitter:
  czbg variance run <dataset_id>

The dataset_id will appear in the job output once generation completes.
When both stages are done, use /demo-upload to send data to CloudZero.
```

**If the config path does NOT contain `/base/`** (optimize, anomalies, unit-econ):

```
Job submitted successfully.
  Job ID: <job_id>

Monitor progress:
  czbg jobs describe <job_id>

Generation typically takes 10-60 minutes depending on config size.
When complete, use /demo-upload to send data to CloudZero.
```
