# `CliSubprocessCore.OutputSchemaFile`
[🔗](https://github.com/nshkrdotcom/cli_subprocess_core/blob/v0.9.3/lib/cli_subprocess_core/output_schema_file.ex#L1)

Materializes a structured-output JSON Schema onto disk for provider CLIs that
take the schema as a **file path**.

`codex exec` types `--output-schema` as a path and exits non-zero when it
cannot read the file, so passing the schema inline is not a degraded mode —
it is a hard failure. This module owns the file's whole life: creation,
the path handed to argv, and removal.

Removal is guaranteed by `CliSubprocessCore.EphemeralFiles`, which monitors
the process that asked for the file. The returned cleanup function is the
ordinary path; the monitor covers the case where the owner never gets to run
it.

# `cleanup`

```elixir
@type cleanup() :: (-&gt; :ok)
```

# `create`

```elixir
@spec create(term(), pid()) :: {:ok, String.t() | nil, cleanup()} | {:error, term()}
```

Writes `schema` to a temporary JSON file owned by `owner`.

Returns `{:ok, nil, cleanup}` for a `nil` schema so callers can use one
shape unconditionally. Fails closed: if the file cannot be written, or if no
owner can guarantee its removal, no file is left behind and no path is
returned.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
