# delete — Delete a Key's Value

**Script name:** `delete`

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

**Invoke:**
```bash
npx --yes tsx .opencode/skills/templating-vault/scripts/delete.ts \
  --key KEY [--owner ID] [--recursive] [--config PATH] [--store-dir SPEC...]
```

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

## Synopsis

```
delete.ts --key KEY [--owner ID] [--recursive] [--config PATH] [--store-dir SPEC...]
```

Removes a key's `value` and `meta.yaml` files. Cleans up empty parent directories.

## Arguments

| Flag | Type | Default | Description |
|------|------|---------|-------------|
| `--key KEY` | string | required | Key to delete |
| `--owner ID` | string | — | Must match key's owner if set |
| `--recursive` | flag | false | Delete all keys under this prefix too |

## Enforcement

- **Write-once keys** cannot be deleted (hard reject)
- **Owner check**: if the key has an `owner` in metadata and `--owner` is specified, they must match
- **Readonly stores**: deletion rejected

## Output (stdout)

Single key: `{"deleted": true, "key": "session.old_value"}`
Recursive: `{"deleted": true, "count": 5, "errors": ["key.x: write-once, cannot delete"]}`
Rejected: `{"deleted": false, "error": "Key is write-once, cannot delete"}`

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success or rejection (check `deleted` field) |
| 1 | Fatal error |
