# create-cartwright

[![npm version](https://img.shields.io/npm/v/create-cartwright)](https://www.npmjs.com/package/create-cartwright)
[![npm downloads](https://img.shields.io/npm/dw/create-cartwright)](https://www.npmjs.com/package/create-cartwright)
[![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Teloz1870/cartwright-template/blob/main/LICENSE)
[![node >= 22](https://img.shields.io/badge/node-%E2%89%A5%2022-brightgreen)](https://nodejs.org)

**A real site — design, database, backend — live in minutes.**

CLI scaffolder for AI-first sites and webshops powered by [Cartwright](https://cartwright.app) —
the open-source Next.js 16 + React 19 + Prisma + Stripe engine with a built-in MCP server,
JSON-LD everywhere, and an admin your AI agent can drive.

## Quick start

```bash
npx create-cartwright@latest my-site
cd my-site
pnpm dev
```

That's it. The CLI installs dependencies, creates the database schema and seeds it —
the **admin login** is printed at the end of scaffolding and saved to `.admin-credentials`
(gitignored). Open `http://localhost:3000`, sign in at `/account/login`.

No prompts at all:

```bash
npx create-cartwright@latest my-shop --yes --db=turso --ai
```

Already in the folder you want (an editor such as Cursor or Claude Code opened on it)?
Scaffold right there. The folder may hold only `.git`, `.gitignore`, `README.md` or
`.DS_Store`, and the project is named after it:

```bash
npx create-cartwright@latest . --yes --no-git
```

Scaffolded with `--no-install`? Then run the steps yourself:
`pnpm install && pnpm db:setup && pnpm dev` (never `prisma migrate deploy` —
`db:setup` is the robust path and prints the admin login).

## See it in 26 seconds

![npx create-cartwright: one command to a running site — scaffold, seeded database, admin login, HTTP 200 and a rendered H1](https://cartwright.app/readme/cast-scaffold.gif)

*Real terminal recording, wait time cut: one command scaffolds, installs and seeds; `pnpm dev`; the homepage answers 200 with a designed H1.*

## See it live

Three production sites run on the exact engine you scaffold:

- 🕶️ [solbrillen.dk](https://solbrillen-dk-teloz1.vercel.app/da) — eyewear webshop, every feature flag on
- ☕ [demo.cartwright.app](https://demo.cartwright.app) — modern coffee-shop demo (View Transitions, 3D hero)
- 🏢 [cartwright.app](https://cartwright.app) — docs, design gallery, comparisons

## Choose Cartwright when — and when not

**Choose Cartwright** when you want a real website or webshop in your own repo (one command →
designed homepage, database, admin, checkout), an AI agent building and operating it (MCP +
tool registry + agent rules in the box), agentic-commerce protocols implemented rather than
promised, and no platform fee or lock-in.

**Prefer something else** when zero-ops hosted is the point (Shopify, Wix), you want
browser-only prompt-to-app (Lovable, bolt.new, v0), you need enterprise multi-channel B2B
(Saleor), or you're building a novel non-commerce app from scratch (create-next-app).
Honest long-form comparisons: [cartwright.app/compare](https://cartwright.app/compare).

## Profiles

One engine, three profile-aware outputs — choose only the surface your project needs.

| Profile | What you get |
|---|---|
| `light` (**default**) | The lean "real site in minutes" kit: website-mode default, a curated design set (`aurora-site`, `fable`, `stillwater`, `halo`, `jungle`, `meridian`, `brutalist`, `apex` + the structural `aurora-shop`/`studio`), full mode-gated webshop, builder/mixer, genome, MCP/JSON-LD discovery, admin, database. Heavy full-only modules are pruned from the scaffold: A2A/agent-marketplace, UCP identity-linking, hoptify, and the 16 non-curated design packs. WebMCP (in-browser agent tools) ships in full — **webshop templates scaffold with it ON** (the store is WebMCP-native out of the box); website-mode scaffolds keep it dormant behind the `webMcp` flag. |
| `full` | Everything the engine ships — identical to the pre-profile scaffold. Required for `--template agent-marketplace`. |
| `site` | A plain, deployable website with no database, admin, auth, catalogue, cart or checkout. The contact form is included by default; pass `--with none` for the bare site. Discovery advertises only interfaces that remain. |

```bash
npx create-cartwright@latest my-site                  # light (default)
npx create-cartwright@latest my-shop --profile full   # everything
npx create-cartwright@latest my-site --profile site   # no database or commerce
npx create-cartwright@latest my-site --profile site --with none
```

Pruned designs can be added back to a light project at any time:

```bash
npx cartwright design install <slug>
```

A design that imports a self-hosted font from `@/app/fonts/<family>/font` (brutalist,
editorial-ink and meridian do) also gets each of those `app/fonts/<family>/` folders,
fetched from the same template ref. A font folder you already have is never
overwritten; the output says which folders were added, which were already identical
and which were kept because they differ (or warns when your own folder lacks the
module the design imports).

## Health check: `cartwright doctor`

Run a read-only diagnosis from any Cartwright project root:

```bash
npx cartwright doctor          # human-readable report
npx cartwright doctor --json   # machine-readable { checks, ok }
```

Seven checks, no fixes, no mutations, no network:

| Check | What it looks at |
|---|---|
| Cartwright project | `brand.config.ts` + `prisma/schema.prisma` + `package.json` exist |
| Release marker | `.cartwright/release.json` — engine version, channel, release date |
| Engine up to date | marker version vs the latest template tag **this CLI build** knows (offline compare — an older CLI knows an older latest) |
| Scaffold profile | `.cartwright/profile.json` — light/full/site + retained modules or designs (absent = full or pre-profile, fine) |
| Node version | major ≥ 22 (the engine's `engines` requirement) |
| Environment | `.env.local` exists; `AUTH_SECRET` set (not a placeholder); `DATABASE_URL` or the `TURSO_DATABASE_URL` + `TURSO_AUTH_TOKEN` pair |
| Database baseline | runs the project's own `db:verify` gate (exit 2 = migration-baseline drift); skipped on older engines |

Exit code is `1` only when a check **fails** (warnings — e.g. an older engine — exit `0`).

## Flags

| Flag | Default | What it does |
|---|---|---|
| `--yes`, `-y` | false | Skip prompts, use defaults |
| `--profile=<light\|full\|site>` | `light` | Scaffold profile (see above) |
| `--with=<module>` | `contact-form` for `site` | Optional site-profile module; use `--with none` for bare core |
| `--template=<slug>` | `website-corporate` (light/site) / `generic` (full) | Mode + seed-data preset; site supports `website-corporate` only |
| `--look=<url>` | — | Scaffold wearing a shared look (see below) |
| `--help`, `-h` | — | Print usage |
| `--version`, `-v` | — | Print the CLI version and exit |
| `--db=<turso\|postgres\|sqlite>` | (prompt) | Database choice — drives next-steps guidance |
| `--ai` / `--no-ai` | (prompt) | Enable / disable the AI commerce features hint |
| `--ref=<stable\|next\|tag\|branch>` | `stable` | Template channel (see below) |
| `--pm=<pnpm\|npm\|yarn\|bun>` | auto-detect | Package manager for install |
| `--no-install` | false | Skip dependency install |
| `--no-git` | false | Skip `git init` + initial commit |
| `--github` | false | Create a **private** GitHub repo and push (needs `gh`). Required for non-interactive runs — `--yes` suppresses the prompt and never publishes on its own |
| `--no-github` | false | Don't offer to publish to GitHub |
| `--no-telemetry` | false | Skip the anonymous scaffold ping (see [Telemetry](#telemetry)) |

## Looks (`--look <url>`)

Every Cartwright shop can share its **look** — skin (design), palette, 3D scene and chrome —
as a `cartwright-composition-v1` JSON file via its public `GET /api/look` endpoint (the
shop owner enables the `lookSharing` flag). Scaffold a new project wearing that look:

```bash
npx create-cartwright@latest my-shop --yes --look https://that-shop.example/api/look
```

After the project is created and the database is seeded, the CLI applies the look:

- **skin** → `designSlug: "<skin>"` in `brand.config.ts` (part of the initial commit),
- **palette / scene / chrome** → the seeded database's branding settings — the same
  fields the engine's `composition.apply` tool writes.

The look **never carries copy**: voice/genome text and homepage layouts are not part of
the public sharing boundary, and the CLI ignores them if present.

Interaction with `--profile`: the light profile (default) ships a curated design set, so
if the look's skin isn't included, the CLI keeps the default design and tells you how to
get it — `npx cartwright design install <slug>` afterwards, or re-scaffold with
`--profile full`. The palette/scene/chrome still apply either way (every design is
palette-adaptive). Since the palette/scene/chrome live in the database, they're skipped
under `--no-install` (no seeded DB yet).

**Fail-soft by design:** an unreachable URL, invalid JSON, wrong schema, unknown design
or database hiccup prints one warning and the scaffold completes unchanged — a broken
look never breaks a scaffold.

## Telemetry

At the end of a successful scaffold the CLI sends **one anonymous, PII-free ping** so we can
tell real adoption apart from CI/bot noise in npm's download numbers. It contains only coarse
install facts: CLI version, template channel, profile, template slug, Node major version, OS
platform and database choice — **never** a project name, path, email or any identifier.

Opt out any of three ways: `--no-telemetry`, `CARTWRIGHT_TELEMETRY=0`, or the standard
`DO_NOT_TRACK=1`. The ping is fail-soft with a hard 1.5 s cap — it can never slow down or
break a scaffold. Receiver + storage: an aggregate-only Vercel Analytics event
([source](https://github.com/Teloz1870/cartwright-app/blob/main/apps/web/app/api/telemetry/scaffold/route.ts)) —
nothing is written to a database.

## Template channels

| Channel | What it is | When to use |
|---|---|---|
| `stable` (default) | Latest tagged release of the template. Battle-tested across the maintainer's canary deploys before tagging. | Production scaffolds. New shops. |
| `next` | Bleeding-edge: the public `next` branch on `cartwright-template`. | Trying features that haven't been cut into a stable release yet. Not for production. |
| `vX.Y.Z` (any tag) | Pin to a specific historical release. | Reproducing a known-good scaffold. |
| `<branch>` (any branch) | Pin to a branch on the mirror. | Power-user experimentation. |

Examples:

```bash
npx create-cartwright@latest my-shop                    # → stable (default)
npx create-cartwright@latest my-shop --ref next         # → bleeding-edge
npx create-cartwright@latest my-shop --ref v0.50.1      # → pin to a tag
```

The spinner shows the channel and the resolved ref so you can see exactly what you pulled — useful when reporting issues.

## What it does

1. Three prompts (project name, database, AI features) — skippable with `--yes`.
2. Downloads a sanitised snapshot from [`cartwright-template`](https://github.com/Teloz1870/cartwright-template) at the resolved `--ref` channel (default `stable`) and applies the selected profile.
3. Generates a random 32-byte `AUTH_SECRET` and writes `.env.local`.
4. Patches `brand.config.ts` — `storeName` (Title Case of project name) + `storeSlug` (kebab-case).
5. Optional: `git init` + initial commit.
6. Optional: install dependencies with the detected (or specified) package manager.
7. Prints database-aware next-steps with copy-pastable commands.

## Requirements

- Node.js ≥ 22
- (Optional) git, for the initial commit
- (Optional) pnpm/npm/yarn/bun, for dependency install

## Where the template comes from

The CLI scaffolds from [`cartwright-template`](https://github.com/Teloz1870/cartwright-template) — the public, MIT-licensed engine template repo, auto-synced on every release tag. No GitHub token required, and the code you scaffold is yours to fork, modify, and ship.

## Source and support

This CLI is part of the [`cartwright-app`](https://github.com/Teloz1870/cartwright-app) monorepo. PRs welcome.

- Engine or scaffold bug: [`cartwright-template` Issues](https://github.com/Teloz1870/cartwright-template/issues)
- CLI or documentation bug: [`cartwright-app` Issues](https://github.com/Teloz1870/cartwright-app/issues)
- Setup and support routes: [FAQ](https://cartwright.app/docs/faq) and [contact](https://cartwright.app/contact)
- Security report: follow [`SECURITY.md`](https://github.com/Teloz1870/cartwright-app/security/policy), never a public issue

## License

MIT
