# Neueface, for coding agents

Neueface is a Mac app: an infinite canvas where a project's real React components and pages run as live cards. Nothing to install in the project. It reads two things:

- **`*.canvas.tsx` files** beside components. Each named export is one card: a no-argument React component that renders one variant.
- **`.canvas/` folder**: `config.json` (pages, options), `setup.tsx` (wraps every card) and `layout.json` (where each card sits: see [Arranging cards](#arranging-cards)).

Cards update live as files are saved. Only React components can be cards; a site without React (Astro, Vue, Svelte) can still show its pages.

## 1. What to make: no questions

Never ask the user what to put on the canvas. Do what they asked; if they asked nothing, it's one of three cases:

**1. A new project** (made with Neueface's **New Project…**: `src/routes/index.tsx` is the Hello world page below). It's ready: the Hello world page is already on the canvas. Change nothing, add the `AGENTS.md` lines (see Hand over), and ask in one line what they'd like to build.

**2. A project with pages**: show its **pages** (see Pages below): routes, shown full size. A page's sections (hero, features, footer…) stay inside the page: no cards for them, they'd be copies. Add component cards only when the user asks for them. No Hello world page.

**3. A project with no pages yet** (empty, or only the framework's template screen): add Neueface's **Hello world page** as its home page, exactly as below, so it looks the same as in a new project:

- The page: the `HelloNeueface` component below, unchanged, as the home route (TanStack Router: `src/routes/index.tsx` with `createFileRoute("/")`; Next.js: `app/page.tsx` exporting it as default; React Router: the `/` route; no router: what `App` renders). It replaces the template's own home screen and its unused files (logos, its CSS).
- The favicon: save the logo as `public/favicon.svg`:

  ```svg
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="#171717"/><g fill="#fff" transform="translate(8 7) scale(1.125)"><path d="M0 6h2v3H0zm0 7h2v3H0zM3 5h2v9H3zM6 0h2v11H6zM9 4h2v9H9zM12 3h2v3h-2z"/></g></svg>
  ```

  and link it: `<link rel="icon" type="image/svg+xml" href="/favicon.svg" />` in `index.html` (Next.js: save it as `app/icon.svg` instead).
- `.canvas/config.json` with `{ "pages": true }`.

```tsx
// Neueface's hello world: one page, its styles in it. Ask your agent to
// replace it with your first real page.
function HelloNeueface() {
  return (
    <main className="nf">
      <style>{styles}</style>
      <div className="nf-content">
        <svg className="nf-logo" viewBox="0 0 32 32" width="56" height="56" role="img" aria-label="Neueface">
          <rect width="32" height="32" rx="7" fill="#171717" />
          <path
            fill="#fff"
            transform="translate(8 7) scale(1.125)"
            d="M0 6h2v3H0zm0 7h2v3H0zM3 5h2v9H3zM6 0h2v11H6zM9 4h2v9H9zM12 3h2v3h-2z"
          />
        </svg>
        <h1>Hello, world</h1>
        <p className="nf-lead">
          This page is live on your Neueface canvas. Ask your coding agent for what to build, and watch it
          show up here as it works.
        </p>
        <ul className="nf-points">
          <li>
            <strong>Pages</strong>
            Every screen of your app is a card, at its real size.
          </li>
          <li>
            <strong>Live</strong>
            Save a file and the canvas updates at once.
          </li>
          <li>
            <strong>Components</strong>
            Ask for one and it gets a card of its own.
          </li>
        </ul>
        <p className="nf-foot">
          Made with <a href="https://neueface.com">Neueface</a>
        </p>
      </div>
    </main>
  );
}

const styles = `
.nf {
  --nf-bg: #ffffff;
  --nf-text: #111113;
  --nf-muted: #6b6b73;
  --nf-line: #e6e6ea;
  box-sizing: border-box;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 64px 24px;
  background: var(--nf-bg);
  color: var(--nf-text);
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  .nf {
    --nf-bg: #0e0e10;
    --nf-text: #f2f2f3;
    --nf-muted: #9a9aa3;
    --nf-line: #26262b;
  }
}
.nf-content { width: 100%; max-width: 600px; text-align: center; }
.nf-logo { display: block; margin: 0 auto; }
.nf-logo rect { stroke: var(--nf-line); stroke-width: 1; }
.nf h1 { margin: 28px 0 0; font-size: 44px; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.nf-lead { max-width: 440px; margin: 14px auto 0; font-size: 17px; line-height: 1.55; color: var(--nf-muted); }
.nf-points {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 48px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}
.nf-points li {
  padding: 16px;
  border: 1px solid var(--nf-line);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--nf-muted);
}
.nf-points strong { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--nf-text); }
.nf-foot { margin: 56px 0 0; font-size: 13px; color: var(--nf-muted); }
.nf-foot a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--nf-line); }
@media (max-width: 640px) {
  .nf-points { grid-template-columns: 1fr; }
}
`;
```

Then say in one line what you made, and that they can ask for any page next.

Neueface's starter uses TanStack Router: a page is a file in `src/routes`. Creating a project yourself, use Vite + React + TypeScript with a router (or what they asked for), `{ "pages": true }`, and the Hello world page as its home page.

## 2. Do it, small

**Components** (when asked): a canvas file beside each one, with a few meaningful variants. Pass real props and safe sample data. Reusable parts only (buttons, inputs, cards), not a page's sections.

```tsx
// src/components/button.canvas.tsx
import { Button } from "./button";

export const Primary = () => <Button>Continue</Button>;
export const Disabled = () => <Button disabled>Continue</Button>;
```

**Pages**: every screen of the app is a page card. `.canvas/config.json` with `{ "pages": true }`, or a list: `{ "pages": ["/", "/pricing"] }`. Works with Next.js, React Router, TanStack Router, Gatsby and Astro. A route behind a dynamic segment may not show: use a canvas file instead.

**Setup**: add `.canvas/setup.tsx` only when cards need it: global CSS, fonts, providers (theme, router, React Query, i18n), or mocks so cards render something real instead of a loading state.

```tsx
// .canvas/setup.tsx
import "../src/index.css";
import type { ReactNode } from "react";

export default function Setup({ children }: { children: ReactNode }) {
  return <ThemeProvider>{children}</ThemeProvider>;
}
```

Don't change product code, remove files or install packages without asking (except when creating a new project). Keep existing `.canvas/` settings.

## 3. Hand over

- Tell the user what you added. A project from Neueface's New Project is already open: the cards change as you save. A project you created yourself: open it in Neueface, with `open -a Neueface <project folder>`. An existing project set up from Neueface's setup card opens by itself once `.canvas/` has files. Otherwise they open the folder: **Open a Project…**, or drag it onto the window.
- Add these lines to the project's `AGENTS.md` (or `CLAUDE.md`), so later sessions know:

  ```md
  ## Neueface canvas
  Cards are `*.canvas.tsx` files beside components; pages and setup live in `.canvas/`.
  How it works: https://neueface.com/canvas/agents.md
  ```

## Arranging cards

Positions live in `.canvas/layout.json`, one line per card, keyed `file#Export` (pages: `@routes#/path`). You can edit it while the canvas is open: the app moves the cards within a second and keeps your positions.

```json
"src/components/button.canvas.tsx#Primary": { "x": 0, "y": 0, "w": 480 }
```

- `x`, `y`: the card's top-left corner on the canvas, in pixels (y grows down). `w`: its width. Optional `size`: `[width, height]`, height `0` for a component (its content decides).
- A card marked `"gone": "<date>"` was deleted: it's not in the code or on the canvas anymore. Don't count it as a page or component that exists; the line only keeps its place in case its code comes back.
- Change only the cards you're asked to move. Keep every other line as it is, including cards marked `"gone"`.
- Leave about 24 px between cards. New cards you don't place, the app places by folder.
- If the user drags a card at the same moment, the last write wins: re-read the file before writing again.

## When something's wrong

| What you see | Why, and the fix |
|---|---|
| Card unstyled, wrong font, or text moving on zoom | Global CSS or fonts aren't loaded for the canvas: import them in `.canvas/setup.tsx` (not only in the app's `<head>`). |
| Card crashes or stays empty | A provider is missing, or it waits for data or a user: add them in `setup.tsx`. |
| Anything else | Ask the user for **Help ▸ Copy Debug Report** in Neueface: it holds the errors. |

Neueface needs Node.js 20.19+ or 22.12+.
