Skip to content

The Snap Assistant

Dory Azar edited this page Dec 4, 2026 · 2 revisions

The assistant of Snap answers what a person types, says or attaches on /assistant, and it answers with your cards. Much of it needs no model. It understands "What can I do?", the name of a card or of a shortcut, and "delete it" on what is on screen. With an Anthropic API key, Claude understands anything else, looks things up with the read-only capabilities the person may call, and answers with cards. The assistant never changes data, because a change always comes back as its Confirm. It exists since 2.23.0.


With Claude

/caligrafy-quill:assistant

Claude sets up Snap, writes about in application/config/snap.php, and asks you for an Anthropic API key if you want the assistant to understand free text.

Check

  • php caligrafer.php snap shows the model on the Assistant model line, or [--] without a key.
  • On /assistant, "What can I do?" lists every card you may use.

By hand

  1. Without a key, the assistant works at once. Add Route::snap(); in web.php and run php caligrafer.php snap install.
  2. With Claude, add the key to .env.
    ANTHROPIC_API_KEY=
    You get a key from console.anthropic.com, under API keys. The model is claude-opus-5-5 at low effort, and SNAP_MODEL and SNAP_EFFORT in .env change them. The anthropic-ai/sdk package must be installed. It is in Caligrafy's composer.json since 2.23.0, so after an update run composer install or rebuild the Docker image.
  3. Say what the app is in application/config/snap.php.
    'about' => 'a library app: the books of a catalog, their authors, and the books lent to people',
    about and APP_NAME in .env tell the assistant what it is the assistant of.

How a request is answered

The assistant uses the first answer that fits.

  1. At once, without a model (Caligrafy\Snap\Shell, API).
    • "What can I do?" (also what else can i do, what can you do, help, menu, ?, options) shows the menu, every card this person may start, by family.
    • The title of one of their shortcuts runs that shortcut.
    • The title or the name of a card ("the catalog", "lend a book", "list_loans") opens that card.
    • A follow-up on the record on screen is a verb with "it", "this", "that", "this one", "that one" or "this book". The verbs delete/remove, change/edit/update/fix, lend/loan, return and open/show/see open delete_<thing>, update_<thing>, lend_<thing>, return_<thing> or get_<thing> for that record. Anything longer ("lend it to Sam") goes to the model, with the conversation's memory.
  2. Claude (Caligrafy\Snap\Planner, API), when it is on. It reads the request with the conversation so far, what is on screen and what the person chose. It may look things up with the read-only capabilities the person may call, as tools run with their permissions, in 6 steps at most. It answers with show_cards, which names the capability, its values and one sentence of caption.

What the model may never do is enforced in code, not in the prompt. Every card it names goes through Snap\Flow like any other. A read runs, and a change comes back as an Ask Confirm card whose token only the person's click sends. The model never sees a token and never runs a change. Tool results and attached files are the app's data, never instructions.

Attachments. The + button attaches up to 3 files, 5 MB in all. The accepted types are PNG, JPEG, GIF, WebP, PDF, plain text, CSV and Markdown. Without the model, attached files get a message instead of an answer.

The keyboard. Press ⌥K / Alt+K to type and ⌥M / Alt+M to talk.


Testing

Fake the model with Caligrafy\Snap\Planner::$transport, and set it back to null in tearDown. Call snap_ask with $this->action(), because it is a web-only capability. The Snap tables must be in the test database, so run platform install with the test settings.

Caligrafy\Snap\Planner::$transport = function (array $request) {
    return (object) array('stopReason' => 'tool_use', 'content' => array((object) array('type' => 'tool_use', 'id' => 't1',
        'name' => 'show_cards', 'input' => array('caption' => 'Here it is.', 'cards' => array(array('capability' => 'list_books'))))));
};
$answer = $this->action('snap_ask', array('text' => 'show me the catalog'), $this->user(1))->describe()['data'];

The designed cards have their own fake, Caligrafy\Snap\Designer::$transport. You can also keep them to the rules with Caligrafy\Snap\Designer::$model = false (since 2.24.1).


Common mistakes

  • The assistant only answers the names of cards (G156). ANTHROPIC_API_KEY is missing, or the anthropic-ai/sdk package is not installed.
  • Forcing a tool in your own calls to Claude (toolChoice of type tool or any) answers 400 on the current Claude models. Snap uses a structured output instead (G161).
  • A test that fakes the planner on 2.24.0 also received the designer's requests. Since 2.24.1 the designer has its own fake (G162).
  • /assistant throws LogicException because Route::snap() needs Auth::authentication(...) above it (G154).

Related pages

Caligrafy. Describe it. Approve it. Ship it. An open-source framework that bridges the server and the client. Every feature is built once in PHP, for web pages, Vue apps, phone apps, a REST API and AI agents.

Start here

Why Caligrafy, with the benefits, the measurements and what it is not yet

  1. Quickstart with Claude to describe it, approve it and ship it

    or the Quickstart, the same three steps by hand in 5 minutes

  2. How Caligrafy works, the ideas in 5 minutes
  3. Your first capability, a feature with its page

Capabilities

Experiences

Data and people

  1. Models
  2. Relationships
  3. Queries with filters, paging and related rows
  4. Sign-in, users and tokens

Built-in features

Put it online

Build with AI

Reference

Clone this wiki locally