Docs
Start building
Code

Building with chat

The AI turn lifecycle and the blocks a response is made of.

3 min read · 6 sections

In Code you build by chatting. You describe what you want, and the AI agent (running inside your workspace container) writes files, runs commands, checks the preview, and streams its work back as a series of typed blocks.

The turn lifecycle

  1. You send a message (optionally with attachments or @file mentions).
  2. Modus prepares the turn: it picks up your session and container, resolves which tools are allowed, and assembles context.
  3. The agent works inside the container: writing files, running bash, checking the preview.
  4. Events stream back to the UI live: files, tool calls, thinking, and plans.
  5. The turn ends: Modus logs it, accounts for tokens, takes a preview screenshot, and makes a git checkpoint.
  6. Your workspace and preview refresh.

What the AI sees

Each turn, the agent is given rich context so it doesn't work blind: recent and relevant turns, project facts pulled from earlier output, the design handoff, any contracts, the docs and deploy state, your env vars, current build errors, a fingerprint of the workspace, and any files you @-mentioned.

Message blocks

A response is built from typed blocks, each rendered its own way:

BlockShows
textMarkdown output
fileA create / edit / delete with a diff
toolA tool call and its output (collapsible)
thinkingThe agent's reasoning (toggle)
planA to-do list with checkboxes
approvalA card asking you to approve a choice, a command, a plan, a form, or a wallet action
git-checkpointThe before/after commit for the turn
pipelineProgress through a multi-stage task
tokensToken usage for the turn
chapter-ctaA nudge to another chapter

Background tasks

Not every job needs to hold up the conversation. Ask for something self-contained ("fix the failing service", "add tests for the tip flow") and Modus can run it as a background task: the work happens on an isolated copy of the workspace while you keep chatting, so a background experiment can never scribble over what you're doing in the foreground.

  • Up to two tasks run at once; further ones queue with your consent.
  • When a task finishes, you review its changes and Apply or Discard them — nothing merges into your workspace without your say-so.
  • A short summary of each finished task lands back in the chat, so the main conversation knows what changed.

The @ menu

Typing @ in the composer opens one menu for both file mentions (pin a specific file into the agent's context) and session commands:

CommandDoes
ExportDownload the whole conversation as Markdown
UndoRoll the workspace back to the checkpoint before the last turn (with confirmation)
CompactSummarize the conversation so far to free up context

File ownership

Files are tagged by owner: AI, user, or template. The AI can write its own files and overwrite the initial template scaffold, but it won't overwrite files you uploaded. That keeps your hand-authored work safe from the agent.