Documents
The doc command reads, checks, saves, creates, deletes and restores the files you edit in the app, such as flows, prompts, rules and config.yaml.
The app’s editors, Trajectories, Settings, Instructions, Missions and Probes, all read and write their files through one command, doc. You can use it too, for scripts or when you prefer the terminal. It never writes a file it has not checked, it keeps the previous version of everything it replaces, and it refuses to overwrite a change it has not seen.
Every doc call names an action and a kind of document:
astranize doc <action> <kind> [<name>] [flags] --workspace <name>This page explains the kinds first, then one section per action. Like every command, doc prints one JSON line and exits with code 1 on an error.
Kinds of documents
Section titled “Kinds of documents”| Kind | File | Name |
|---|---|---|
config |
config.yaml |
none |
rules |
rules.md |
none |
telemetry |
the telemetry section of ~/.astranize/settings.yaml |
none |
flow |
flows/<name>.yaml; default is flows/default.yaml, or workflow.yaml when that file is missing |
flow name |
prompt |
prompts/<name>.md |
prompt name |
context |
context/<name>.md, a repo map |
repo name |
mission |
missions/<name>.yaml |
mission name |
probe |
probes/<name>.yaml |
probe name |
config, rules and telemetry are single files: they take no name, and they cannot be created or deleted. Paths are relative to the workspace folder.
doc list
Section titled “doc list”Lists the documents of one kind, with whether each one is valid and its hash.
astranize doc list flow --workspace notes{"type":"documents","kind":"flow","documents":[{"kind":"flow","name":"default","title":"default","valid":true,"error":null,"hash":"sha256:9e7c8fdcc04d69ee29b47de25bfa03f54c9d384254d9181f6f750d2b79ec5a97","flow":{"steps":7,"isDefault":true,"openTasks":0,"v1":true}}]}title is the document’s label when it has one. For flows, flow adds the number of steps, whether it is the default for new tasks, how many open tasks use it and whether it is in the old version 1 format. An invalid document has valid: false and its first error in error.
List what can be restored
Section titled “List what can be restored”--deleted lists the documents that were deleted and whose last version is still in the history:
astranize doc list prompt --deleted --workspace notes{"type":"deleted_documents","kind":"prompt","documents":[{"kind":"prompt","name":"changelog","version":"2026-11-22T04-43-11.567Z","at":"2026-11-22T04:43:11.567Z"}]}Single files have nothing to list and answer with an error.
doc get
Section titled “doc get”Reads one document: its text, its hash and the result of checking it.
astranize doc get prompt changelog --workspace notes{"type":"document","kind":"prompt","name":"changelog","text":"# Instruções\n\nDescreva aqui o que o agente deve fazer, o que ele pode ler e o que deve entregar.\n","hash":"sha256:47409d6672f01490c5a1ff40a4ad429e9b403b9196ec79678d907a01648ccf44","validation":{"ok":true,"errors":[],"warnings":[]},"form":null,"legacyKeys":[],"keys":[]}Keep the hash: saving, restoring and deleting compare it with the file on disk. For YAML documents, form holds the parsed file, legacyKeys lists camelCase keys that would be renamed, and flows also get a descriptor with their steps. A document that does not exist has the hash absent.
Save a document
Section titled “Save a document”doc save replaces a document, as long as it has not changed since you read it. Pass the hash from doc get with --expect-hash, and the new content in one of two ways.
A --patch changes YAML keys in place and keeps your comments and layout. It is a JSON list of operations, set, remove or insert, each with a path:
astranize doc save flow fast --patch '[{"op":"set","path":["steps",1,"on_fail","max"],"value":2}]' --expect-hash sha256:803fcc1aae29a391cd5cfd83cc4a960e7cba202a69202a33dc2b524ffbdc6c4b --workspace notes{"type":"document_saved","kind":"flow","name":"fast","hash":"sha256:48364d86c212d26226f714e0572c21bae97eb0f0c2c5a45ab1b81128696ff81e","validation":{"ok":true,"errors":[],"warnings":[]}}--staged <id> replaces the whole text. The text does not go on the command line: write it to $ASTRANIZE_HOME/tmp/doc-<id>.txt, where <id> is 32 lowercase hex characters, and pass the id. The file is read once and deleted, and may be up to 256 KB.
id=$(openssl rand -hex 16)cat my-rules.md > ~/.astranize/tmp/doc-$id.txtastranize doc save rules --staged $id --expect-hash sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 --workspace notesBefore writing, Astranize checks the new text the same way the app does. An invalid result is refused and the file is left alone:
{"type":"error","message":"invalid: o documento não é válido","code":"invalid","validation":{"ok":false,"errors":[{"line":8,"field":"steps.gates","message":"onFail \"dev\" does not exist"}],"warnings":[]}}Warnings do not stop a save; they come back in validation.warnings. The version being replaced is kept in the history. Text documents (rules, prompt, context) take only --staged, and telemetry takes only --patch, so the rest of settings.yaml stays as it is.
doc validate
Section titled “doc validate”Checks text without saving it. It takes --staged and reports errors and warnings by line and field:
astranize doc validate flow fast --staged $id --workspace notes{"type":"document_validation","kind":"flow","name":"fast","ok":false,"errors":[{"line":2,"field":"name","message":"o nome \"quick\" não bate com o arquivo: use \"fast\""}],"warnings":[]}doc create
Section titled “doc create”Creates a document that does not exist yet. It starts from one of three sources:
--template <name>: a built-in template. Flows havedefaultandblank; prompts and missions haveblank; probes havescheduleandobserve. Without a source,blankis used, so a probe always needs--template.--duplicate <name>: a copy of another document of the same kind.--staged <id>: your own text.
astranize doc create flow quick --template default --workspace notes{"type":"document_saved","kind":"flow","name":"quick","hash":"sha256:a81a664a5d485cbfd255598746e99bcfc215f5ba5060e928a0b563451485605e","validation":{"ok":true,"errors":[],"warnings":[{"line":33,"field":"steps.video","message":"A etapa de vídeo precisa da seção vídeo do config"}]}}You can add --patch to change the source in the same step, so the document is checked once, already changed:
astranize doc create flow review-only --template blank --patch '[{"op":"set","path":["label"],"value":"Review only"}]' --workspace notesA flow’s name: is set to the new name for you. A flow in the version 1 format cannot be duplicated. Repo maps have no template; map writes them.
doc delete
Section titled “doc delete”Deletes a document. Its last text is kept in the history, so it can be restored.
astranize doc delete prompt changelog --workspace notes{"type":"document_deleted","kind":"prompt","name":"changelog","version":{"version":"2026-11-22T04-43-11.567Z","at":"2026-11-22T04:43:11.567Z","bytes":99}}Astranize refuses when something still needs the document, and lists who in users:
- a flow that is
default, named indefault_flow, used by an open task, or fired by a probe; - a prompt that a flow or a mission points at;
- a mission with an active run, a confirmation waiting for you, or a probe that fires it;
- a probe with an open decision or a fire waiting to be delivered.
{"type":"error","message":"in-use: \"quick\" está em uso: Trajetória padrão do workspace, Tag filter","code":"in-use","users":[{"kind":"config","id":"default_flow","label":"Trajetória padrão do workspace"},{"kind":"task","id":"t-0001","label":"Tag filter"}]}Deleting a mission or a probe also moves its state folder, such as a mission’s run history, to the trash.
doc history and restore
Section titled “doc history and restore”doc history lists the kept versions of a document, newest first:
astranize doc history flow fast --workspace notes{"type":"document_history","kind":"flow","name":"fast","versions":[{"version":"2026-11-22T04-46-50.553Z","at":"2026-11-22T04:46:50.553Z","bytes":241}]}doc restore writes a version back. It takes the version and the current hash, and keeps the current text as a new version first:
astranize doc restore flow fast 2026-11-22T04-46-50.553Z --expect-hash sha256:48364d86c212d26226f714e0572c21bae97eb0f0c2c5a45ab1b81128696ff81e --workspace notes{"type":"document_saved","kind":"flow","name":"fast","hash":"sha256:159fb1356a6a6cf8e9adfe957a76080755b174e9b2cb4ba226b5d4ecdc906b04","validation":{"ok":true,"errors":[],"warnings":[]}}To bring back a deleted document, pass --expect-hash absent.
When doc says no
Section titled “When doc says no”A refused request prints an error line whose message starts with a code, and repeats it as code. Some add users or validation.
| Code | Meaning |
|---|---|
changed-on-disk |
The file’s hash is not --expect-hash. Read it again. |
invalid |
The result would not be valid. validation lists why. |
in-use |
The document is still needed. users lists by whom. |
exists |
create on a document that already exists. |
not-found |
No such document, template or version. |
not-allowed |
Not possible for this kind, such as deleting rules, deleting the default flow, duplicating a v1 flow, or writing through a symbolic link. |
Mistakes in the command itself, such as an unknown kind or a missing flag, are plain error lines without a code.
| Flag | Actions | Meaning |
|---|---|---|
--expect-hash <hash> |
save, restore |
Required. The hash you read; absent for a file that does not exist. |
--patch <json> |
save, create |
A JSON list of set, remove and insert operations. YAML documents only. |
--staged <id> |
save, create, validate |
Reads and deletes $ASTRANIZE_HOME/tmp/doc-<id>.txt. Not together with --patch on save. |
--template <name> |
create |
Starts from a built-in template. |
--duplicate <name> |
create |
Starts from a copy of another document. |
--deleted |
list |
Lists deleted documents that can be restored. |
Next steps
Section titled “Next steps”- Edit instructions: the same actions in the app
- Trajectories: what a flow file holds
- Files and directories: where the history and the trash live
