# AI authoring

<PageBadges />

:::warning

AI authoring is in preview. Commands, provider availability, prompts, and the mutation protocol can
change before a stable release. Review generated calculations and event JavaScript.

:::

AI authoring adds a conversational schema-authoring mode to form0-cli. It works with ordinary form0
schemas: the final file contains no conversation history, provider configuration, or mutation data.

Start directly with a schema, or enter AI mode from the interactive shell:

```bash
form0 ai [schema]
```

```ansi
form0> serve
form0(server)> ai
form0(server,ai)> Add a calculated total from quantity and unit price
```

AI mode does not start the preview server. When a server is already running, validated drafts are
broadcast to the browser with an **AI draft** source label without being written to disk.

## How authoring works

1. The selected model receives the complete current form and the installed core authoring catalog.
2. The agent proposes a coherent batch of semantic mutations rather than replacing the schema file.
3. form0-core applies the batch to a clone and validates the complete result.
4. A valid draft can be inspected, revised, discarded, or explicitly applied.
5. Apply checks the on-disk revision again and writes the schema atomically.

Invalid proposals never become drafts. Exiting or discarding restores the committed schema in the
browser. The output remains an ordinary form0 schema with no automatic AI metadata additions.

## Explore this section

- [Getting started](/cli/ai-authoring/getting-started) covers setup and a first authoring session.
- [Providers and models](/cli/ai-authoring/providers-models) explains Pi authentication and model persistence.
- [Authoring workflow](/cli/ai-authoring/authoring-workflow) covers drafts, validation, approval, and conflicts.
- [Commands and status](/cli/ai-authoring/commands-status) documents every AI-mode command and busy behavior.
- [Privacy and security](/cli/ai-authoring/privacy-security) defines data boundaries and cloud policy.
- [Limitations and troubleshooting](/cli/ai-authoring/limitations-troubleshooting) describes preview constraints and common failures.

For schema-level agent guidance and cloud controls, see [AI metadata](/core/ai-metadata).
