# Using Elicit.js with coding agents

> Source: https://elicitjs.github.io/start/agents/ · Elicit.js 0.5.0-alpha.0

An agent can ask you with a chart instead of a question in words. In a chat, it shows an Elicit.js card, you answer by dragging, drawing or clicking, and it reads your answer as rows. In a codebase, it writes Elicit.js into your app. The `elicitjs-mcp` server and the agent skill that ships with the package give it both.

## Quick start

Paste this into your agent. It sets up the server, checks it, and asks you a first question.

```text
Help me set up Elicit.js for my agent.

1. Add the Elicit.js MCP server to my client. It runs with: npx -y elicitjs-mcp
   Set ELICITJS_MCP_MODE to "chat" if you will ask me questions in this chat,
   or "build" if you are writing Elicit.js into this project.
2. If we are in a project folder, run: npx -y elicitjs-mcp setup
   so every agent here reads the Elicit.js skill.
3. Check it works: list the Elicit.js widgets.
4. Then ask me something with a chart: how I split my week between
   work, sleep, people and play.
```

To set it up by hand, see [Install and configure](#install).

## What you can ask

Each chat below is live. Answer the card: the line under it is what the agent reads while you work, and **Submit** sends it as your next message.

### Split a budget

You: We have $100k for next quarter. Ask me how I'd split it across hiring, marketing, tools and travel.

Agent: Drag each bar to set its share. The four always add up to 100.

```json
{
  "widget": {
    "type": "allocation",
    "question": "How would you split next quarter’s budget?",
    "categories": [
      "Hiring",
      "Marketing",
      "Tools",
      "Travel"
    ],
    "total": 100
  }
}
```

### Draw a forecast

You: I have a hunch about our sign-ups for the next ten weeks. Let me draw it instead of typing numbers.

Agent: Draw your forecast on the card. I'll compare it with the real numbers as they come in.

```json
{
  "title": "Weekly sign-ups, the next 10 weeks",
  "caption": "Draw the line from left to right. Draw again to redo a stretch.",
  "width": 440,
  "height": 300,
  "margins": {
    "top": 14,
    "right": 16,
    "bottom": 30,
    "left": 40
  },
  "data": [],
  "schema": {
    "s": {
      "type": "categorical"
    },
    "week": {
      "type": "quantitative",
      "domain": [
        1,
        10
      ]
    },
    "signups": {
      "type": "quantitative",
      "domain": [
        0,
        500
      ]
    }
  },
  "marks": [
    {
      "type": "lineY",
      "stroke": "#50AEB7",
      "strokeWidth": 3,
      "curve": "catmullRom",
      "channels": {
        "series": {
          "field": "s"
        },
        "x": {
          "field": "week"
        },
        "y": {
          "field": "signups"
        }
      },
      "edits": [
        {
          "type": "line.draw",
          "along": "x",
          "value": "y",
          "series": "s",
          "samples": 10
        }
      ]
    }
  ]
}
```

### Show a feeling

You: The launch is next week. Ask me how I'm feeling about it.

Agent: Shape the face until it looks the way you feel.

```json
{
  "title": "How do you feel about the launch?",
  "caption": "Drag the mouth up or down, and an eye sideways.",
  "width": 300,
  "height": 320,
  "margins": {
    "top": 12,
    "right": 12,
    "bottom": 12,
    "left": 12
  },
  "data": [
    {
      "valence": 0,
      "arousal": 0
    }
  ],
  "schema": {
    "valence": {
      "type": "quantitative",
      "domain": [
        -1,
        1
      ]
    },
    "arousal": {
      "type": "quantitative",
      "domain": [
        -1,
        1
      ]
    }
  },
  "marks": [
    {
      "type": "face",
      "channels": {
        "mouthCurve": {
          "field": "valence",
          "edit": {
            "type": "slide",
            "axis": "y",
            "increase": "up"
          }
        },
        "eyeScale": {
          "field": "arousal",
          "edit": {
            "type": "slide",
            "axis": "x",
            "increase": "right"
          }
        }
      }
    }
  ]
}
```

### Point to a likelihood

You: How likely is it that we ship by March? Ask me in words, not percentages.

Agent: Point the needle at how likely you think it is.

```json
{
  "title": "Will we ship by March?",
  "caption": "Drag the needle.",
  "width": 380,
  "height": 255,
  "margins": {
    "top": 64,
    "right": 80,
    "bottom": 20,
    "left": 80
  },
  "axes": false,
  "overflow": "visible",
  "data": [
    {
      "chance": "Toss-up"
    }
  ],
  "schema": {
    "chance": {
      "type": "ordinal",
      "domain": [
        "Very unlikely",
        "Unlikely",
        "Somewhat unlikely",
        "Toss-up",
        "Somewhat likely",
        "Likely",
        "Very likely"
      ]
    }
  },
  "marks": [
    {
      "type": "axisRadial",
      "outerRadius": 110,
      "bands": true,
      "bandWidth": 22,
      "tickSize": 0,
      "tickPadding": 18,
      "fontSize": 8,
      "channels": {
        "theta": {
          "field": "chance",
          "scale": {
            "range": [
              180,
              0
            ]
          }
        },
        "fill": {
          "field": "chance",
          "scale": {
            "scheme": "dddiverging"
          }
        }
      }
    },
    {
      "type": "needle",
      "length": 95,
      "fill": "#EE7B5E",
      "channels": {
        "theta": {
          "field": "chance",
          "scale": {
            "range": [
              180,
              0
            ]
          },
          "edit": {
            "type": "rotate",
            "pivot": "mark",
            "fold": false,
            "pick": "direct"
          }
        }
      }
    },
    {
      "type": "text",
      "fontSize": 14,
      "dy": 32,
      "channels": {
        "text": {
          "field": "chance"
        },
        "textAnchor": {
          "value": "middle"
        },
        "lineAnchor": {
          "value": "middle"
        }
      }
    }
  ]
}
```

### Build a diagram together

You: Help me map what drives churn. Start a diagram and I'll add to it.

Agent: Here's a start with three ideas. Add yours, link what causes what, and rename anything.

```json
{
  "title": "What drives churn?",
  "caption": "Drag a node to move it. Click empty space to add one. Shift-drag from one node to another to link them. Double-click a label to rename it.",
  "width": 460,
  "height": 300,
  "margins": {
    "top": 24,
    "right": 24,
    "bottom": 24,
    "left": 24
  },
  "axes": false,
  "schema": {
    "structure": "network",
    "tables": {
      "nodes": {
        "id": {
          "type": "categorical",
          "key": true,
          "open": true
        },
        "label": {
          "type": "categorical",
          "open": true
        },
        "x": {
          "type": "quantitative",
          "domain": [
            0,
            100
          ]
        },
        "y": {
          "type": "quantitative",
          "domain": [
            0,
            100
          ]
        }
      },
      "links": {
        "source": {
          "type": "ref"
        },
        "target": {
          "type": "ref"
        }
      }
    }
  },
  "data": {
    "nodes": [
      {
        "id": "n1",
        "label": "Price",
        "x": 20,
        "y": 72
      },
      {
        "id": "n2",
        "label": "Onboarding",
        "x": 22,
        "y": 26
      },
      {
        "id": "n3",
        "label": "Churn",
        "x": 78,
        "y": 50
      }
    ],
    "links": [
      {
        "source": "n1",
        "target": "n3"
      }
    ]
  },
  "marks": [
    {
      "type": "link",
      "inset": 3,
      "stroke": "#94A5B3",
      "strokeWidth": 1.5
    },
    {
      "type": "node",
      "size": 10,
      "fill": "#50AEB7",
      "edits": [
        {
          "type": "network.connect",
          "when": "shift"
        },
        {
          "type": "create",
          "defaults": {
            "label": "New idea"
          }
        },
        {
          "type": "remove",
          "when": "alt"
        }
      ],
      "channels": {
        "x": {
          "field": "x",
          "edit": {
            "type": "move",
            "channels": [
              "x",
              "y"
            ],
            "when": "noShift"
          }
        },
        "y": {
          "field": "y"
        },
        "text": {
          "field": "label",
          "edit": {
            "type": "editText"
          }
        }
      }
    }
  ]
}
```

### Write it into your app

In `build` mode the agent writes the card into your code and tests it with `check_spec` before it hands it over.

You: Add a question to our onboarding survey where people rank five features.

Agent: I've added it to the survey. Here's the code, and the card it draws:

```javascript
import { Elicit, compile } from "elicitjs";

const chart = Elicit(compile({
  widget: {
    type: "ranking",
    question: "Rank these features by how much you would use them",
    items: ["Offline mode", "Shared lists", "Reminders", "Dark theme", "Export"],
  },
}));
document.querySelector("#feature-rank").append(chart.dom());

// The rows are the answer: save them with the rest of the survey.
chart.on("change", (rows) => survey.save("featureRank", rows));
```

```json
{
  "widget": {
    "type": "ranking",
    "question": "Rank these features by how much you would use them",
    "items": [
      "Offline mode",
      "Shared lists",
      "Reminders",
      "Dark theme",
      "Export"
    ]
  }
}
```

## What the server provides

- **Ask in a chat** (`ask_with_visual`, `read_chart`, `update_chart`): Shows a card in the conversation. The agent reads the chart as you leave it and can change it too; your edits and its edits show on the same card. Submit carries on the chat without typing. The card can go full screen or float.
- **Look it up** (`elicitjs_docs`): The skill, a keyword, a docs page or example, or a search, by one string.
- **Check and test** (`check_spec`): Builds a spec headlessly, lists what to fix, answers it as a person would, and renders it to PNG.
- **Export** (`export_html`): Writes a page with the card and the library, which opens from disk.
- **Prompts** (`author_elicit_chart`, `design_elicitation`): Slash commands in hosts that list prompts: ask with a card, or design a new way to ask.

`ELICITJS_MCP_MODE` picks the tools:

- `chat` asks a person in a chat host, such as Claude Desktop: `ask_with_visual`, `read_chart`, `update_chart` and `elicitjs_docs`.
- `build` is for an agent writing Elicit.js into an app: `elicitjs_docs`, `check_spec` and `export_html`.

Leave out `ELICITJS_MCP_MODE` for all six tools. Specs are JSON, the form `compile()` reads. The server is alpha.

## Install and configure

In Claude Code, add the server in `build` mode:

```bash
claude mcp add elicitjs-build -e ELICITJS_MCP_MODE=build -- npx -y elicitjs-mcp
```

In Claude Desktop, add it in `chat` mode to `claude_desktop_config.json`, then restart the app:

```json
{
  "mcpServers": {
    "elicitjs": {
      "command": "npx",
      "args": ["-y", "elicitjs-mcp"],
      "env": { "ELICITJS_MCP_MODE": "chat" }
    }
  }
}
```

Other clients take the same command, `npx -y elicitjs-mcp`. For PNG rendering in `check_spec`, also run `npx playwright install chromium` once.

## The skill

The `elicit` skill is a short `SKILL.md` with reference files: how to write a spec, ask well, design a new technique, and build Elicit.js into an app. It ships inside the npm package, so an agent reads the version that matches the library you installed: `node_modules/elicitjs/skills/elicit/SKILL.md`.

To tell every agent that works in a project to read it, run this in the project's folder:

```bash
npx -y elicitjs-mcp setup
```

It adds a short block to the project's `AGENTS.md`, and to its `CLAUDE.md` when that file does not already read `AGENTS.md`. Running it again refreshes the block and leaves the rest of the file alone.

To add the skill to your agent's own skills folder instead:

```bash
npx skills add elicitjs/elicitjs --skill elicit
```

`skills add` copies the skill from the GitHub repository, so it follows the latest source rather than your installed version.

## The docs as Markdown

The site publishes three plain-text forms of these pages:

- [`/llms.txt`](https://elicitjs.github.io/llms.txt) lists every page with a one-line description, grouped as the sidebar groups them.
- [`/llms-full.txt`](https://elicitjs.github.io/llms-full.txt) holds every page in one file.
- Each page's route plus `.md` is that page alone: its prose, each example's title and code, and its API reference. This page is [`/start/agents.md`](https://elicitjs.github.io/start/agents.md).

The examples name keywords bare and call the docs' `mount(node)`. [Reading the examples](https://elicitjs.github.io/start.md#examples) shows how they map to your own code.
