---
title: memhtml apply
description: "Write many memories from a JSONL op stream: ONE commit, ONE index update, per-op results."
---

## 1. Synopsis

Write many memories from a JSONL op stream: ONE commit, ONE index update, per-op results.

```sh
memhtml apply [options]
```

## 2. Arguments

This command takes no positional arguments.

## 3. Flags

| Flag | Type | Default | Values | Description |
| --- | --- | --- | --- | --- |
| `--file` | string | *no default* | *no fixed set* | The JSONL file to read. One complete JSON object per line. Omit it, pass `--file -`, or pass a positional `-` to read the stream from stdin; stdin beside a real `--file` is refused. |
| `--continue-on-error` | flag | `false` | *no fixed set* | Best-effort: a refused op is reported and skipped while every surviving op lands in the one commit. Atomic by default. The first refused op aborts the batch and nothing is written. |
| `--detect-conflicts` | flag | `false` | *no fixed set* | Report each op's frame-matches as a per-op `conflict`: the ACTIVE memory (or the earlier op) whose claim occupies the same subject-and-relation slot. PROPOSE-ONLY: every op still writes exactly as it would have, because sometimes the contradiction is the answer. You decide: write anyway, `memhtml correct` the match, or drop the line. |
| `--detect-near-duplicates` | flag | `false` | *no fixed set* | Report each op's embedding near-duplicates as a per-op `near_duplicates` list: ACTIVE memories (or earlier ops in this stream) whose text sits at or above cosine 0.92 against this op's claim and body, best first, with the measured similarity. The vector sibling of `--detect-conflicts`: that flag catches a DIFFERENT value in the same grammatical slot, this one catches a REWORDING of the same fact. PROPOSE-ONLY for the same reason, and the score is geometry — negations also sit above 0.92, so read the paired claim before folding anything. Costs one embedding call per batch; ops written as `article_html` are never checked; when the embedder cannot run (MEMHTML\_EMBED=off, or the call failed) the result carries `near_duplicates_degraded: true` and every `near_duplicates` is null, meaning UNCHECKED rather than unique. |
| `--consolidate` | string | *no default* | `last-wins` | Resolve frame-key matches instead of only reporting them: `--consolidate last-wins` makes the LATER op's value win a shared claim slot (one file, written at the FIRST index that claimed the slot, with each later restatement reporting `consolidated_into` naming that slot) and archives a stored ACTIVE memory a surviving slot displaces, reported as `superseded_path`. Off by default; claims with no frame shape are never consolidated. |
| `--session-id` | string | *no default* | *no fixed set* | The Claude Code session for every op that names none. A line's own `session_id` wins over this. |
| `--prompt-id` | string | *no default* | *no fixed set* | The prompt within that session. |
| `--turn-uuid` | string | *no default* | *no fixed set* | The turn within that session. |

Every command also accepts the [global flags](/reference/global-flags/).

## 4. Response

On success the command writes one JSON envelope to stdout, and its `type` is `batch.applied`.

On failure it writes the failure envelope, whose `code` comes from [error codes](/reference/error-codes/).

[The JSON envelope](/reference/envelope/) gives the fields both shapes carry. [Response types](/reference/response-types/) lists every value `type` takes across the binary.

## 5. Further reading

The guide blocks that name this command:

* [`write-surfaces`](/reference/guide/write-surfaces/)
* [`when-to-batch`](/reference/guide/when-to-batch/)
* [`conflicts`](/reference/guide/conflicts/)
* [`authoring`](/reference/guide/authoring/)
* [`code-mode`](/reference/guide/code-mode/)

## 6. Provenance

A loader generates this page from `apps/cli/src/commands.ts` while the site builds, so no file in the repository holds it: the `COMMANDS` array there is the one source of argument parsing, of `memhtml manifest`, and of `AGENTS.md`. Change the registry and this page changes with it.