> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nika.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# capture

> Contract, placement, related fields and source examples for this Nika YAML field.

[Language reference](https://docs.nika.sh/reference/language/overview.md) / `capture`

## Meaning and placement

### exec

Which stream becomes the task's output · `stdout` (default) · `stderr` · `combined` · `structured` = `{ stdout, stderr, exit_code }`. This is the SOURCE; `decode:` is how that string becomes a value.

| Property | Declaration |
| - | - |
| Requirement | Optional in this object |
| Schema location | `/$defs/exec/properties/capture` |
| type | `"string"` |
| enum | declaration below |

<details>
  <summary>`enum` schema declaration (spec source, not a lesson)</summary>

  ```json theme={"system"}
  [
    "stdout",
    "stderr",
    "combined",
    "structured"
  ]
  ```
</details>

**In the same object:** [command](https://docs.nika.sh/reference/language/words/command.md) · [cwd](https://docs.nika.sh/reference/language/words/cwd.md) · [decode](https://docs.nika.sh/reference/language/words/decode.md) · [env](https://docs.nika.sh/reference/language/words/env.md) · [shell](https://docs.nika.sh/reference/language/words/shell.md) · [stdin](https://docs.nika.sh/reference/language/words/stdin.md)

[Schema source (use the pointer above)](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/schemas/workflow.schema.json)

## In a source template

Excerpt from `templates/human-gated-ship.nika`, source lines 109–118. This is a fragment, not a runnable workflow.

```yaml illustration theme={"system"}
    # A COMMAND gate · a test suite, a CLI probe · argv form, never a shell.
    exec:
      command: ["echo", "ok"]        # SLOT: gate 2 · the program must be in permits.exec
      capture: structured
    on_error:
      # Golden rehearsal · `nika test` refuses exec (NIKA-SEC-001 · the mock
      # plane simulates the model, not effects). Catch-all ON PURPOSE — never
      # `on_codes: [NIKA-SEC-001]`: that code is also a real blocklist stop,
      # and a narrow forgiveness would swallow a security refusal. The shape
      # matches `capture: structured` so the gates expression reads it.
```

### Templates containing this field

| Template | Source |
| - | - |
| `templates/human-gated-ship.nika` | [Line 112](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/human-gated-ship.nika#L112) |

These are literal key occurrences in the source files, not an execution or conformance claim. [How to instantiate a template](https://docs.nika.sh/guides/templates.md).

## Contract and implementation

This page projects the named specification revision. Check [released engine status](https://docs.nika.sh/reference/status.md) and [the validation workflow](https://docs.nika.sh/guides/agent-authoring.md) before running a file. An optional field is not evidence that every engine supports every value.

Canonical identity: `language:word:capture`. Spec revision: [`5c40ba456c53`](https://github.com/supernovae-st/nika-spec/tree/5c40ba456c53a4ab663a949d44003078e161305d).

[How documentation stays connected](https://docs.nika.sh/reference/knowledge-system.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.