# export — Export a Store to a YAML Definition

**Script name:** `export`

**Script location:** [`scripts/export.ts`](../../../scripts/export.ts)

**Invoke:**
```bash
npx --yes tsx .opencode/skills/templating-vault/scripts/export.ts \
  --store-dir DATA_DIR [--output FILE] [--include-values]
```

**CRITICAL:** Always invoke the script using bash and the format noted above.

## Synopsis

```
export.ts --store-dir PATH [--output PATH] [--include-values]
```

Reads a data directory and produces a YAML definition suitable for `init.ts`.
Captures `.store.yaml` defaults and all per-key `meta.yaml` content.

## Arguments

| Flag | Type | Default | Description |
|------|------|---------|-------------|
| `--store-dir PATH` | string | required | Data directory to export |
| `--output PATH` | string | stdout | Write YAML to this file instead of stdout |
| `--include-values` | flag | false | Include the actual values in the export (use with caution for credential stores) |

## Output

Without `--output`: YAML written to stdout.
With `--output`: JSON status to stdout:
```json
{"exported": true, "output": "/tmp/exported.yaml", "key_count": 12}
```

## Usage Examples

```bash
# Export to a file (metadata only, no values)
npx --yes tsx .opencode/skills/templating-vault/scripts/export.ts \
  --store-dir /tmp/globals --output /tmp/globals-def.yaml

# Export with values (for template stores, NOT credential stores)
npx --yes tsx .opencode/skills/templating-vault/scripts/export.ts \
  --store-dir /app/data/templates --output /tmp/templates-def.yaml --include-values
```

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | Fatal error |
