This is the operational playbook for agents editing Noma documents. The rule is simple: read scoped context, discover IDs, choose the smallest stable patch, prove the edit, apply it only after the proof passes, validate the result, and never rewrite a whole file unless the user explicitly asks for a migration.
Agent contract
If you are an agent, treat the .noma source as the artifact's audit log. Your job is to preserve surrounding bytes, keep block IDs stable, and make the next human review smaller.
Dry-run the patch and render diagnostics, hashes, diff, source preservation, LLM context, ID registry, and a post-patch preview.
5. Patch
noma patch file.noma --ops ops.json --inplace
Apply the same transaction after the proof is accepted.
6. Re-check
noma check file.noma
Confirm the edit did not introduce errors.
7. Render
noma render file.noma --to html --strict --out artifact.html
Produce a safe published artifact.
Use noma prove file.noma --ops ops.json --inplace --out proof.html when the proof artifact and source update should be one guarded operation. The command writes the source only if the simulated post-patch document has no validation errors.
Browser proof surface
The web workbench exposes the same product contract for no-install review:
paste one patch op or an ops array into Agent Proof
click Review -> Prove
inspect hashes, diagnostics, source preservation, ops, and post-preview in
the Proof output tab
click Apply only when the proof is writable
copy Share Proof when a reviewer needs proof metadata without the source
Workbench table and dataset edits also travel through this path. The visual grid generates granular patch ops, runs a proof, and only writes the browser draft when post-validation has no errors.
Space maintenance
For multi-page documentation, books, papers, or agent memory packs, treat the book manifest as the project boundary:
The generated Noma Space is reader-facing, but it also gives agents useful orientation: _assets/search-index.json lists page titles, paths, tags, status, owners, updated dates, summaries, and plain text; page sidebars expose related pages and backlinks; cross-chapter [[id]] links use the same scoped ID/alias map as validation. Edits still go through source patches against .noma files, not HTML rewrites.
Choose the smallest operation
User intent
Preferred op
Replace an entire semantic block
replace_block
Change only the prose/body
replace_body
Rename a section title but keep links stable
update_heading
Add or resolve a review note
add_comment / resolve_comment
Add a Word-compatible footnote or endnote
add_footnote / add_endnote
Propose a tracked Word review edit
add_change_request
Change one body cell in an ID-bearing ::table
update_table_cell
Change one header cell in an ID-bearing ::table
update_table_header_cell
Add or remove one body row in an ID-bearing ::table
insert_table_row / delete_table_row
Add or remove one column in an ID-bearing ::table
insert_table_column / delete_table_column
Change one body cell in an ID-bearing ::dataset
update_dataset_cell
Add or remove one data row in an ID-bearing ::dataset
insert_dataset_row / delete_dataset_row
Add or remove one data column in an ID-bearing ::dataset
insert_dataset_column / delete_dataset_column
Reorder or re-home an existing semantic block
move_block
Insert evidence, a task, or a new card
add_block
Remove obsolete material
delete_block
Change confidence, status, owner, or source
update_attribute
Clear stale metadata
remove_attribute
Change a canonical ID and retarget references
rename_id
Transaction shape
Patch files should use the transaction wrapper when an edit has more than one operation or when validation should guard the write.
Do not scrape rendered HTML when --to llm can provide scoped context.
Prefer noma prove before noma patch when the edit is user-visible,
multi-operation, or needs an audit artifact.
Prefer replace_body over replace_block when attributes and children should survive.
Prefer update_heading over text replacement for section titles.
Use rename_id only when the user accepts a breaking ID change.
Preserve aliases unless the user asks to remove them.
Validate fragments before insertion.
Use --strict for published/team artifacts.
Keep raw ::html, ::svg, and ::script out of agent-generated content unless explicitly requested.
Minimal agent prompt
Code
agent-safe-edit-prompt
language text
You are editing a Noma document. First discover IDs with `noma ids`. Choose the smallest patch operation. Prove the edit with `noma prove --ops --out proof.html`. Apply edits with `noma patch --ops` only after the proof passes. Run `noma check` after the patch. Do not rewrite the whole file unless explicitly requested.
When to ask a human
Ask before editing when:
The requested target has no stable ID.
Multiple aliases could refer to different sections.
A patch would delete evidence, citations, or accepted decisions.
The edit requires raw HTML/script escape hatches.
Validation fails after a patch and the fix is not mechanical.
MCP and SDK status
The MCP server exposes read_doc, list_ids, validate_doc, and patch_block over stdio. The Agent SDK wraps that server and remains experimental until the protocol annexes graduate. Treat the CLI and schemas as the stable contract; treat SDK ergonomics as subject to change during v0.x.
MCP host setup
Use the published stdio server from any MCP host that accepts command-based server definitions:
The server should be pointed at absolute file paths by the caller. It does not invent edits: agents still need to discover IDs, choose a small patch operation, and validate after the patch.
SDK workflow
Use the SDK when an agent integration needs a typed client and retry-aware source patches:
safePatch reads the current SHA before patching and retries only on sha_mismatch. Same-file patches inside one workflow are serialized so two local agent tasks do not race each other.