docs
How to use cdbx
AI Chat

Using the AI Chat

The AI chat is a coding assistant built directly into the CDBX editor. It can read and write your files, fix errors, and generate entire applications from a description.

Opening the Chat

The AI Chat panel is in the left sidebar. Click the Copilot tab to open it, or use the Generate with AI prompt on the dashboard to open it automatically.

Sending Messages

Type in the input box at the bottom and press Enter (or Shift+Enter for a new line). The AI reads your currently open file for context and can read any other file in your app on demand.

Attaching Files

Click the "+" button next to the model picker and choose "Attach files" to attach a file to your message — images, text/code files (.py, .md, .json, and other common formats), and PDFs are all supported, on any message, not just your first one. You can also paste a screenshot (⌘V / Ctrl+V) or drag a file straight into the chat box. Images show a thumbnail with an "✕" to remove them before sending; other files show as a chip with the filename.

PDFs get special handling depending on which model is selected: a Claude model reads the PDF directly, including diagrams, tables, and layout — not just the text. OpenAI, Moonshot, and Grok models instead read the extracted text only.

Attaching a file here adds it to the conversation as context for the AI — it doesn't add it to your file tree. To add a file to your app itself, drag it into the file tree or use the tree's upload button.

What the AI Can Do

Read and Write Files

The AI has access to tools that let it read and rewrite files in your app:

  • Read — the AI reads a file to understand the current code before modifying it
  • Write — the AI rewrites one or more files with new content

When files are being read or written you'll see a progress indicator (e.g. "Writing App.jsx") above the response. With auto-accept enabled (the default), changes are applied immediately. With auto-accept off, changes are queued for you to review.

Reviewing AI changes

Turn off Auto-accept AI edits (AI settings) if you'd rather check each change before it lands. When it's off:

  • A banner appears in the chat, just above the message box, listing every file waiting for review — for example "2 files awaiting review".
  • Accept all applies every queued change and refreshes the preview. Reject all discards them.
  • You can also accept or reject one file at a time from the banner, or click a filename to open it in the editor and read the side-by-side diff before deciding.
  • The AI Chat icon in the sidebar shows a count badge while changes are waiting, so you don't miss them when you're working in another panel.

The banner only appears on the instant browser runtime. A server-backed app always applies AI changes straight away.

Fix Errors

When a build or runtime error appears in the log panel, an Auto-fix button appears next to the error entry on hover. Clicking it sends the error directly to the AI, which reads the relevant files and writes a targeted fix.

A Fix error shortcut also appears above the chat input for the most recent active error — one click without needing to find the entry in the log.

A Report button appears alongside it. Clicking Report opens the feedback form pre-filled with the error details so you can send a bug report to the cdbx team.

Generate From Scratch

Via the Vibe Coding flow, the AI can generate an entire app from a plain-English description, including picking the right template and writing all the files.

Model Selection

Use the model selector in the bottom-left of the chat input to switch between AI providers (Anthropic, OpenAI, Moonshot AI, and xAI) and models. The selected model applies to the current session, and the same choice carries over to the vibe input and the Planning Agent — they all share one preference.

Models are grouped into three tabs by cost:

  • Lite — fastest, cheapest models, best for small tweaks
  • Economy — a balance of speed and quality, best for most everyday builds
  • Power — higher-performance models for complex work

Each model shows its credit-weight multiplier (e.g. "4×") relative to the cheapest tier, and a "Recommended" tag on the best default per tab.

The exact list of models shown reflects what's currently enabled — new models can appear over time without requiring an update on your end.

Effort

For models that support it (currently Claude models with extended thinking), an Effort slider appears below the model list — Low through Max, five steps. Higher effort gives the model more room to reason before responding, at the cost of a bit more latency and, at the highest levels, a small amount of extra usage (flagged with a "+" or "+$"). Lower effort is faster and cheaper, best for simple requests.

When effort is on, a Building row shimmers above the response while the model is reasoning. Click it to expand and read the full thinking transcript — it collapses back to a static "Thought process" label once the turn finishes, staying available to reopen at any time.

API Keys (Bring Your Own Key)

To use AI features, you need to provide your own API key.

To add a key:

  1. Open the Settings menu (⚙ top-right) → AI → AI Settings Panel
  2. Under Bring Your Own Key, enter your Anthropic, OpenAI, Moonshot AI, or xAI API key and click Save

Keys are encrypted at rest (AES-256-GCM) and never exposed to the client. Once saved, you'll see a green checkmark next to the provider name. The chat footer shows a BYOK badge (green key icon) or Platform badge (blue shield) to confirm which key is active for the current provider.

You can remove a saved key at any time from the same panel.

Token Usage

The input/output token count for the current chat session is shown next to the model selector. This gives you a sense of context window usage across the conversation.

Dashboard Assistant

When you're on your dashboard (not inside an app), a chat bubble in the bottom-right corner opens a lightweight AI assistant. It answers questions about cdbx — features, how things work, where to find settings — and can direct you to the right docs page.

It is separate from the editor AI Chat and does not have access to your code. To send feedback or report an issue, click the Send Feedback button at the bottom of the assistant panel.

App Context (AGENTS.md)

Every new app includes an AGENTS.md file at the root of the file tree. The AI reads this file at the start of every conversation, so anything you write there applies without you having to repeat it.

Open AGENTS.md and fill in the sections that are relevant to your app:

  • Purpose — what the app is building; gives the AI goal alignment
  • Conventions — coding style, component patterns, libraries to use or avoid
  • Off-limits — files or sections the AI should never modify

Example:

## Purpose
A drag-and-drop kanban board for personal task tracking.
 
## Conventions
- Tailwind CSS only — no inline styles
- Functional components with hooks
- Keep all state in App.jsx for now
 
## Off-limits
Never modify index.tsx

The file is pre-filled with template-specific defaults (React conventions for a React app, Go conventions for a Go app, etc.). Edit or delete any section — if the file is blank or deleted, the AI simply uses its default behaviour.

Long tasks and picking up where it left off

A single AI turn can take a limited number of steps — reading a file, writing one, checking something — before it has to stop. A big request can use them all up before the work is done.

cdbx continues on its own. When a turn runs out of steps part-way through, it starts again from where it stopped, up to three times, so a large build carries on without you doing anything. You'll see it keep working rather than stopping mid-way. It also carries on if a build finishes but your app's main file still shows the starter placeholder — and if it still isn't wired up after that, the chat tells you so and asks you to send "continue".

Two cases where it stops and waits for you instead:

  • The turn was taking too long. Carrying on would just run out of time again, so it tells you and suggests asking for something smaller — one page or one component at a time.
  • It didn't manage to change anything. That usually means it's stuck rather than unfinished, and repeating would waste credits.

Anything already written is kept and still revertable in every case.

Undoing a turn

For a server-backed app, before the AI changes its first file, cdbx saves the previous version of every file it is about to touch. If the result isn't what you wanted, click Revert this turn on that message and those files go back to exactly how they were.

This works even when a turn goes wrong half-way through — a lost connection, or a turn that ran past the five-minute limit. The changes it did make are kept and still revertable, so you're never left with a half-finished edit you can't undo.

A few things to know:

  • Revert is one-use per turn. Once you've reverted, that snapshot is gone.
  • It only covers files that turn touched — your other work is untouched.
  • Snapshots live in the app's own container, so a turn can't be reverted after the container has restarted.

What a turn costs

Every AI message shows its cost as it runs — token counts and a credit figure that updates each round, not just at the end. A ⚡ figure means part of the conversation was served from cache, which is why follow-up messages usually cost much less than the first one.

You can cap a single turn under Settings → AI Settings → Per-turn credit limit. A turn that reaches the limit stops cleanly and tells you; anything it already changed is kept, and revertable.

Connectors

When you have services connected via Settings → Connectors, the AI can use them automatically. If your request is relevant — searching Notion, reading a GitHub file, checking a Slack channel — the AI calls the connector on its own. You'll see a progress indicator (e.g. "Searching Notion…") above the response.

You can also pre-fetch specific content by typing an @-mention in your message:

SyntaxWhat it does
@github:owner/repo/path/to/file.tsInjects that file's content into the message
@notion:search termSearches Notion and injects the top results
@google-drive:search termSearches Drive and injects matching file info
@slack:channel-nameInjects recent messages from that channel

The AI also supports push actions when GitHub is connected: "create a repo called…" or "open a PR on owner/repo" trigger the appropriate GitHub flow and return a link.

Actions that change something

Reading from a connected service happens automatically. Anything that writes — posting to Slack, opening a GitHub issue, creating a Notion page — does not. The AI proposes it, you see the exact action and all of its arguments, and it only runs when you click Run it.

This is deliberate. Content the AI reads back from a connected service is written by other people, and text hidden in a page or a message could otherwise talk the AI into doing something on your behalf. cdbx labels everything it reads from a service as content, not instructions, and puts you in the loop before anything leaves your app.

See Connectors for the full setup guide.

Tips

  • Be specific — "add a dark mode toggle to the header" works better than "add dark mode"
  • The AI always re-reads the current file before writing, so it works with your existing code
  • For large changes across multiple files, ask the AI to do them all in one message
  • If the AI gets something wrong, just describe the correction — it has the full conversation history
  • Put app-wide rules in AGENTS.md so you don't have to repeat them every chat