# Document

A Word-style document.

**What it is.** A Word-style document, made by an AI agent such as Claude Code or Codex in Artifacts (tryartifacts.com), the office for AI agents. **Ask for it** in plain words: “Write the Q3 product brief as an Artifacts document from these notes, with a contents list and a table of the milestones.” From its **More** menu it downloads as Word (`.docx`) or PDF. See one an agent made: [State of Mid-Market Distribution](/p/northwind-market-report), a real document with contents, charts and tables.

> Agents read this guide with the `guide` tool, topic `docs`, before they first make a document. It is shown here word for word, so people and their agents work from the same method.

| | |
| --- | --- |
| Guide topic | `docs` |
| Tools | [14 tools](/docs/reference/docs) |

An Artifacts document is a real Word-style document with pages (WordCraft): styles, headings, lists,
tables, pictures, charts, SmartArt diagrams, shapes and text boxes, page breaks, headers and footers
with page numbers, footnotes, a table of contents. A team edits it together live, comments on its
words and figures, and downloads it as Word (.docx) or PDF. Every change you make appears in
everyone's open document at once.

The tools: `create_doc`, `read_doc`, `render_doc`, `export_doc`, `doc_undo`, and WordCraft's own
editing tools: `doc_select_text`, `doc_type_text`, `doc_execute` (any command), `doc_batch` (several
commands in one call), `doc_insert_table`, `doc_get_text`, `doc_inspect_document`,
`doc_list_commands`, and `doc_page_layout` (a page as WordCraft laid it out). WordCraft's own
instructions for them are at the end of this guide: follow them.

## Order of work

1. Outline first: the title, the point in one or two sentences, then the sections a reader needs.
2. `create_doc` with the whole document in Markdown (headings, **bold**, *italic*, lists, tables,
   quotes, links), or from a file the person gave (.docx, .odt, .rtf, .html, .txt, .doc).
3. Shape it with commands: page breaks before new parts, a header or footer with page numbers, a
   table of contents for long documents.
4. `render_doc`: look at every page as it prints. Fix what reads badly (a heading alone at the foot
   of a page, a table cut awkwardly, an empty page), then hand it over with the link, naming any
   `[PLACEHOLDERS]` the person must fill.

## Changing a document

You work like a person at the keyboard: put the selection somewhere, then type or run commands on it.

- `doc_select_text` with words that are in the document selects them (`occurrence` for a later
  one). `doc_type_text` then replaces them, or types at the caret (`paragraphs: true` makes each
  line its own paragraph).
- `doc_execute` runs one command on the selection; `doc_batch` runs several in order. Common ones:
  `para.heading1`, `para.heading2`, `para.heading3`, `para.normal`, `para.style`, `format.bold`,
  `para.bullets`, `para.numbering`, `insert.pageBreak`, `insert.table` (rows, cols),
  `insert.header`, `insert.footer`, `insert.pageNumber`, `references.toc`, `references.footnote`,
  `layout.margins`, `layout.orientation`, `layout.size`. `doc_list_commands` with a word (`query`)
  lists the commands and the parameters each takes.
- Moving the caret: `caret.end` / `caret.home` (end and start of the line on screen), `caret.docStart`,
  `caret.docEnd`, `caret.paraDown`; `text.newParagraph` starts a new paragraph after the caret;
  `select.paragraph` selects the caret's paragraph. To add something after a paragraph: select its
  last words (`doc_select_text`), then `doc_batch` with `caret.right` (the caret goes to the end of
  the selection), `text.newParagraph` and the command or `text.insert` (`text`).
- Headers and footers: `insert.header` / `insert.footer` with `text` set the whole header or footer,
  and `insert.pageNumber` with `position: "bottom"` replaces the whole footer with a page number. For
  text and a page number together: `insert.editFooter`, type the text, `insert.pageNumber` with
  `position: "current"`. These, `references.footnote` and `insert.textBox` leave the caret in the
  header, footer, note or text box, and `doc_select_text` finds words only where the caret is: run
  `insert.closeHeader` to go back to the body before changing it again. A command run on a
  selection can replace the selected words (a footnote does): for a note after words, select them,
  then `caret.right`, then `references.footnote` with `text`.
- Figures (pictures, charts, SmartArt diagrams, shapes, text boxes): to add one, select words to
  replace (a placeholder paragraph) or put the caret where it goes, then `insert.picture` (`data`:
  the image in base64, `alt`), `insert.chart` (`type`, `data`, `title`), `insert.smartArt`
  (`layout`, `items`), `insert.shape` (`kind`) or `insert.textBox` (`text`). `read_doc` lists them
  in `figures`, each with its `index`, `kind`, `name` and `block` (the paragraph or table it is in).
  `select.objects` with `{index}` selects one; commands then act on it: `object.altText`,
  `picture.size`, `chart.editData`, `chart.title`, `smartArt.items`.
- `read_doc` shows the paragraphs and tables in order with their styles and formatting; read it again
  before a change that depends on what is there: people may have typed since.
- People may be typing while you work. Select by words (`doc_select_text`), not by position, right
  before each change.
- `doc_undo` takes back your own last change while nobody has changed the document since.

## Writing that reads as professional

- One title (Heading 1 or the Title style), then Heading 2 sections, Heading 3 inside them: never
  skip a level. Use the heading styles, not bold text, so the table of contents and navigation work.
- Lead with the point: the first paragraph says what the reader needs to know or decide.
- Short paragraphs (2–5 sentences); a list for steps or parallel items; a table to compare options
  across the same attributes. Bold the few words a skimmer must not miss, not whole sentences.
- Start a new page (`insert.pageBreak`) before a major part (an appendix, a new chapter), not to
  push text down with empty lines.
- Specific over vague: names, dates, amounts, owners. Facts you do not have are placeholders in
  brackets (`[DATE]`, `[OWNER]`, `[BUDGET]`), never invented. Link sources you used.
- End decision documents with what happens next: owners and dates.

## Comments

People comment on words or on a figure. `list_comments` shows each thread with its quoted words, or,
for a figure, its `label` and its `index` now (`null` when it is not in the document any more: it
was deleted, or its picture, chart data, diagram items or shape text changed). Select the words
(`doc_select_text`) or the figure (`select.objects` with its `index`), make the change, then
`reply_comment` and resolve. To start a thread, `comment` with `quote` (words exactly as they are
in the document) or `figure` (its `index` in `read_doc`'s figures).

## WordCraft's own instructions

What WordCraft itself tells an agent, word for word. Here its tools carry the `doc_` prefix and take the document's `item_id` (`execute` is `doc_execute`, `batch` is `doc_batch`, `page_layout` is `doc_page_layout`), and Artifacts keeps the file: for `new_document` and `open_document` use `create_doc`, for `render_page` use `render_doc`, for `save` use `export_doc`.

WordCraft is a word processor (a Microsoft Word clone). Every action is a command: find ids and parameters with list_commands and run them with execute (or several with batch). Plan the page before you write. page_layout shows a page as WordCraft laid it out, in points: its size, the text area, the columns the text runs through with where the text ends and the room left in each, and every element (paragraph, table, picture, chart, shape, text box) with its path and place. From that, decide what goes where: set the page up first (layout.size, layout.margins, layout.columns, section breaks), then write in order. Body text, headings and tables flow: WordCraft places them from their order, the columns and the breaks (text.columnBreak, text.pageBreak, para.keepNext), and tells you where they landed. A picture, chart, shape or text box can be put at a place and size of your choosing: arrange.bounds {page, x, y, width, height} with it selected. Every writing call answers with `layout`, the caret's page as it now stands: read where things landed and the room left before the next step, and fix what is out of place where it starts. Read the numbers as a typesetter would before you call a page done: one body font and size throughout, in tables too: `fonts` on a paragraph or a table lists more than one when it mixes them (set them on the style, styles.modify, not paragraph by paragraph; `fontShownAs` means the font is not installed, so choose one that is: font.missing lists them); the same space between every pair of paragraphs; space above and below every table and figure (a table whose last cell ends where the next paragraph's `top` begins is touching it: para.spacing {before} on that paragraph); a caption next to its table or figure; no heading as the last thing in a column; columns on a page ending near the same height. An element's path is its address: {story:"body", path:[block,(row,cell,block)...], off:byteOffset} in caret.set and select.range puts the caret there or selects it. Typical flow: new_document → page_layout → page setup → type_text (paragraphs:true for several) → execute para.style {style:"Heading 1"} → insert_table → page_layout on every page → render_page to look at the result → save {path:"out.docx"}. Several documents can be open: new_document and open_document open another one and make it active; list_documents gives their ids, and `doc` on execute, batch and the other document tools works on one without switching. Backend: headless session (no window). Community: https://discord.gg/artcraft · https://getartcraft.com/apps/wordcraft · https://github.com/storytold/wordcraft

## See it in use

- **Roles:** [AI for financial analysts](/roles/financial-analyst), [AI for lawyers](/roles/lawyer), [AI for sales managers](/roles/sales-manager), [AI for marketing managers](/roles/marketing-manager), [AI for operations managers](/roles/operations-manager), [AI for chief executives](/roles/chief-executive)
- **Articles:** [Business Proposal Template: What to Include, With a Full Example](/blog/business-proposal-template), [ChatGPT Canvas Removed: The Best Alternatives in 2026](/blog/chatgpt-canvas-alternatives), [Claude Artifacts vs ChatGPT Canvas: What Changed in 2026](/blog/claude-artifacts-vs-chatgpt-canvas)
- **Examples:** [24 pages agents made for a sample company](/examples)
