# templating-vault Scripts Reference

All scripts are TypeScript CLIs in `.opencode/skills/templating-vault/scripts/`.

**Invocation pattern (all scripts):**
```bash
npx --yes tsx .opencode/skills/templating-vault/scripts/<script>.ts [flags]
```

## Common Flags (accepted by all scripts)

| Flag | Type | Default | Description |
|------|------|---------|-------------|
| `--config PATH` | string | (cascading) | Load a YAML config file |
| `--store-dir SPEC` | string | `/tmp/templating-vault` | Data store specifier (repeatable). See [configuration](../configuration/) |

## Scripts by Category

### Value Operations

| Script | Description | Reference |
|--------|-------------|-----------|
| `set.ts` | Store a value with literal/write-once/type enforcement | [set/](./set/) |
| `get.ts` | Retrieve a value; evaluates template keys lazily | [get/](./get/) |
| `extract.ts` | Extract a value from text via regex and store it | [extract/](./extract/) |
| `delete.ts` | Delete a key's value | [delete/](./delete/) |
| `list.ts` | List keys under a prefix | [list/](./list/) |

### Template Operations

| Script | Description | Reference |
|--------|-------------|-----------|
| `render.ts` | Render a Nunjucks template to file or as a prepared prompt | [render/](./render/) |
| `retrieve.ts` | Get a prepared prompt by ID (content + variable schema) | [retrieve/](./retrieve/) |

### Store Management

| Script | Description | Reference |
|--------|-------------|-----------|
| `init.ts` | Initialize/validate a data store from a YAML definition | [init/](./init/) |
| `export.ts` | Export a store's structure to a YAML definition | [export/](./export/) |

### Shared Module

| Module | Description |
|--------|-------------|
| `api.ts` | Shared library: config loading, Nunjucks env, file I/O, validation. Not standalone. |

## Literal vs Non-Literal Variable Flow

```
LLM wants to store a value
│
├─ Is the variable literal? (defined in meta.yaml or schema.yaml)
│   ├─ YES → Must use extract.ts with a regex
│   │         LLM provides the regex pattern
│   │         Script applies regex to source text and stores result
│   │         LLM never generates the raw value
│   │
│   └─ NO  → Can use set.ts directly
│             LLM provides the value
│
└─ Exception: admin access can set literals via set.ts
              (used during bootstrap from env vars)
```
