create-sordo 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +52 -2
  3. package/bin/create-sordo.ts +11 -0
  4. package/package.json +36 -5
  5. package/src/index.ts +675 -0
  6. package/src/probes.ts +28 -0
  7. package/src/prompts.ts +141 -0
  8. package/src/readme.ts +74 -0
  9. package/src/ui.ts +207 -0
  10. package/src/versions.ts +3 -0
  11. package/templates/_backend/app/routes/api/todos.ts +27 -0
  12. package/templates/_claude/.claude/commands/sordo-init.md +64 -0
  13. package/templates/_claude/.claude/hooks/biome-check.sh +17 -0
  14. package/templates/_claude/.claude/rules/build-time-discovery.md +17 -0
  15. package/templates/_claude/.claude/rules/bun-native.md +28 -0
  16. package/templates/_claude/.claude/rules/filesystem-routing.md +31 -0
  17. package/templates/_claude/.claude/rules/islands.md +46 -0
  18. package/templates/_claude/.claude/rules/optional-ai.md +16 -0
  19. package/templates/_claude/.claude/rules/web-standards-boundary.md +25 -0
  20. package/templates/_claude/.claude/settings.json +22 -0
  21. package/templates/_claude/.claude/skills/sordo/SKILL.md +121 -0
  22. package/templates/_claude/.claude/skills/sordo-cli/SKILL.md +112 -0
  23. package/templates/_claude/CLAUDE.md +28 -0
  24. package/templates/_codex/.codex/README.md +10 -0
  25. package/templates/_codex/.codex/rules/build-time-discovery.md +17 -0
  26. package/templates/_codex/.codex/rules/bun-native.md +28 -0
  27. package/templates/_codex/.codex/rules/filesystem-routing.md +31 -0
  28. package/templates/_codex/.codex/rules/islands.md +46 -0
  29. package/templates/_codex/.codex/rules/optional-ai.md +15 -0
  30. package/templates/_codex/.codex/rules/sordo-cli.md +108 -0
  31. package/templates/_codex/.codex/rules/sordo-patterns.md +122 -0
  32. package/templates/_codex/.codex/rules/web-standards-boundary.md +25 -0
  33. package/templates/_codex/AGENTS.md +27 -0
  34. package/templates/_container/.dockerignore +7 -0
  35. package/templates/_container/Dockerfile +27 -0
  36. package/templates/_monorepo/packages/README.md +18 -0
  37. package/templates/_shared/sordo-patterns.md +122 -0
  38. package/templates/default/README-template.md +181 -0
  39. package/templates/default/app/islands/TodoApp.tsx +83 -0
  40. package/templates/default/app/routes/api/health.ts +8 -0
  41. package/templates/default/app/routes/index.tsx +29 -0
  42. package/templates/default/app/server.ts +28 -0
  43. package/templates/default/gitignore +9 -0
  44. package/templates/default/sordo.config.ts +5 -0
  45. package/templates/default/tsconfig.json +14 -0
  46. package/templates/ui-shadcn/components/button.tsx +63 -0
  47. package/templates/ui-shadcn/components/dialog.tsx +158 -0
  48. package/templates/ui-shadcn/demo/index.tsx +62 -0
  49. package/templates/ui-starter/_internal/cn.ts +6 -0
  50. package/templates/ui-starter/_internal/slot.ts +50 -0
  51. package/templates/ui-starter/_internal/variants.ts +1 -0
  52. package/templates/ui-starter/button.tsx +60 -0
  53. package/templates/ui-starter/card.tsx +92 -0
  54. package/templates/ui-starter/demo/TodoApp.tsx +86 -0
  55. package/templates/ui-starter/demo/index.tsx +45 -0
  56. package/templates/ui-starter/input.tsx +20 -0
  57. package/templates/ui-starter/label.tsx +18 -0
  58. package/templates/ui-starter/themes/neutral/tokens.css +46 -0
  59. package/templates/ui-starter/themes/slate/tokens.css +46 -0
  60. package/templates/ui-starter/themes/stone/tokens.css +46 -0
  61. package/templates/ui-starter/themes/zinc/tokens.css +46 -0
  62. package/templates/ui-starter/tokens.css +46 -0
@@ -0,0 +1,122 @@
1
+ # Sordo patterns — components & feature scaffolding
2
+
3
+ > Codex rule. The catalog and recipes below are shared verbatim with the
4
+ > Claude `/sordo` skill — both are generated from one source
5
+ > (`templates/_shared/sordo-patterns.md` in create-sordo), so they
6
+ > cannot drift. Read this when the user asks to add a component or scaffold a
7
+ > feature pattern.
8
+
9
+ ## When to use
10
+
11
+ Use this when the user wants to **add a UI component** or **scaffold a
12
+ feature pattern** (auth + RBAC, a CRM, a task board, a pivot table, a
13
+ dashboard). It covers scaffolding only — for running, building, deploying, or
14
+ managing secrets, use the `sordo-cli` skill instead.
15
+
16
+ Two capabilities:
17
+
18
+ 1. **Add a UI component** — a thin wrapper over the deterministic catalog.
19
+ 2. **Scaffold a feature pattern** — instruction-driven: you generate the files,
20
+ adapting names/fields/copy to the user's domain.
21
+
22
+ ## Add a component
23
+
24
+ Components are upstream shadcn/ui, stamped verbatim — never hand-author
25
+ component source; the shadcn registry is the source of truth.
26
+
27
+ 1. If `app/components/ui/_internal/` does not exist, the UI setup isn't
28
+ initialized — run `sordo ui init --shadcn` first (it wires the `@/*` alias
29
+ and `app/lib/utils.ts`).
30
+ 2. Run `sordo add @shadcn/<name>` (preview first with
31
+ `sordo add --view @shadcn/<name>` if the user wants to see the source).
32
+ 3. Import the stamped component from `app/components/ui/<name>.tsx` and use it.
33
+ Pages that render shadcn components must `export const hydrate = true`
34
+ (whole-tree hydration).
35
+
36
+ `sordo add` edits `package.json` (it never runs an install) and stamps source
37
+ into `app/components/ui/`. After adding, remind the user to run `bun install` if
38
+ new peer deps were added.
39
+
40
+ ## Scaffold a pattern
41
+
42
+ Pick a pattern below, `sordo add @shadcn/<name>` its components first, then
43
+ generate the listed files — adapting entity names, fields, columns, and copy to
44
+ the user's stated domain (e.g. "a CRM for veterinary clinics").
45
+
46
+ | Pattern | Goal | `@shadcn/<name>` components | Generated files (under `app/`) |
47
+ |---|---|---|---|
48
+ | **auth-rbac** | Login / logout + role-gated route | `input`, `label`, `button`, `card` | `routes/login.tsx` (native POST form), `routes/api/login.ts`, `routes/api/logout.ts`, `routes/admin.tsx` (gated by middleware), `app/middleware.ts` (gates `/admin`), `lib/auth.ts` (cookie session over mock users), `lib/rbac.ts` (role guard), `lib/mock-users.ts` |
49
+ | **crm** | Contacts list + detail / edit | `table`, `dialog`, `form`, `input`, `button`, `badge` | `routes/contacts/index.tsx` (table), `routes/contacts/[id].tsx` (detail), `islands/ContactForm.tsx`, `lib/mock-contacts.ts` |
50
+ | **task** | Task board / list | `card`, `checkbox`, `badge`, `dialog`, `button` | `routes/tasks.tsx`, `islands/TaskBoard.tsx` (columns + toggle), `lib/mock-tasks.ts` |
51
+ | **pivot** | Group-by / pivot over rows | `table`, `select`, `card` | `routes/pivot.tsx`, `islands/PivotTable.tsx` (pick row/col/measure), `lib/mock-rows.ts` |
52
+ | **dashboard** | Metrics overview | `card`, `chart`, `separator`, `sidebar` | `routes/dashboard.tsx` (cards + chart + sidebar shell), `lib/mock-metrics.ts` |
53
+
54
+ Per-pattern recipes:
55
+
56
+ - **auth-rbac** — sessions are a signed cookie over the mock user list. Because
57
+ pages can't read cookies or redirect (see Conventions), the gate lives in
58
+ `app/middleware.ts`: it checks the session + role and redirects unauthenticated
59
+ `/admin` hits to `/login`. The login page is a native `<form method="post"
60
+ action="/api/login">` (no `form` component) posting to `routes/api/login.ts`,
61
+ which sets the cookie and redirects; `routes/api/logout.ts` clears it. Make the
62
+ mock-only nature loud: a banner on the login page and a TODO at the top of the
63
+ auth module. Real auth needs persistence (a future DB spec).
64
+ - **crm** — the list uses `table` over `mock-contacts`; create / edit
65
+ happens in a `dialog` driven by a `form` island. The detail route reads the
66
+ same mock store by id.
67
+ - **task** — the board is an island holding `useState` columns; toggling a
68
+ `checkbox` moves a task between done / not-done. No persistence — state resets
69
+ on reload (call this out).
70
+ - **pivot** — an island lets the user pick a row dimension, a column dimension,
71
+ and a numeric measure from `select`s, then renders the aggregated `table`.
72
+ Aggregation runs client-side over the mock rows.
73
+ - **dashboard** — a static SSR shell (`sidebar` is `subtree`, `chart` hydrates)
74
+ with metric `card`s fed by `mock-metrics`; the chart is the one interactive
75
+ island.
76
+
77
+ Always `sordo add @shadcn/<name>` the listed components (running
78
+ `sordo ui init --shadcn` first if needed) before generating files that import
79
+ them. Only reference components that exist in the upstream shadcn registry.
80
+
81
+ ## Depth contract: UI + mock data
82
+
83
+ Every pattern is scaffolded at **"UI + mock data"** depth:
84
+
85
+ - **In scope:** SSR routes / pages, islands where interactivity is needed,
86
+ stamped UI components, and a typed in-memory seed in
87
+ `app/lib/mock-<entity>.ts` that the pages read from.
88
+ - **Out of scope:** `bun:sqlite`, migrations, a real persistence or auth
89
+ backend, network calls. The pattern *shows the shape*; the developer swaps the
90
+ mock data for a real source later.
91
+ - Every generated `mock-*` module starts with `// TODO: replace mock data with a
92
+ real source`, and the route / page carries a short note marking the mock
93
+ boundary.
94
+
95
+ Do not generate a database layer, migrations, or a real auth/network backend
96
+ from this skill — that is deferred to a future spec.
97
+
98
+ ## Conventions
99
+
100
+ - Pages live under `app/routes/*.tsx` (default-export a React component); API
101
+ handlers under `app/routes/api/*.ts` (named `GET`/`POST`/… returning a
102
+ `Response`, e.g. via `ctx.json()`). Dynamic segments use `[id]`. A `.ts` route
103
+ **must** be under `app/routes/api/` — anywhere else is a build error.
104
+ - **Pages get only `ctx.params`** — they can't read cookies, set headers, or
105
+ redirect. Push that work to an API route or to `app/middleware.ts` (the single
106
+ global `Middleware (req, ctx, next)`, the only place to gate a page). Mutation
107
+ forms use a native `<form method="post" action="/api/…">` posting to a `.ts`
108
+ handler.
109
+ - Islands (interactive client components) live under `app/islands/` and are
110
+ wrapped at the use site in `<Island name="…">…</Island>` from `sordo/render`.
111
+ `chart` and `form` are islands (they pull `recharts` / `react-hook-form`).
112
+ - **Styling is opt-in per page.** If `app/components/_head.tsx` exists, every new
113
+ page route must re-export it (`export { head } from "../components/_head.tsx";`)
114
+ or it renders unstyled. Run `bun run css` (or `bun run css:watch`) after adding
115
+ classNames; `dev`/`build` compile it for you.
116
+ - Mock data lives in `app/lib/mock-<entity>.ts`, typed, with the TODO marker.
117
+ - Never re-author component source — stamp from the catalog and import.
118
+
119
+ ## See also
120
+
121
+ - The `sordo-cli` skill — running, building, deploying the app.
122
+ - cli specs 11–15 (UI: `ui init`, `add`, `view`, `update`, registries).
@@ -0,0 +1,25 @@
1
+ # Web-standards boundary rule
2
+
3
+ The framework stays close to web standards at handler boundaries. Do
4
+ not paper over them with a custom request abstraction.
5
+
6
+ - **Handler signature:** `(req: Request, ctx: SordoContext) => Response | Promise<Response>`.
7
+ `req` is a standard web `Request`; the handler returns a standard web
8
+ `Response`. Streaming responses use `ReadableStream`.
9
+ - **`SordoContext` is the only framework-added affordance.** It
10
+ exposes `params`, `cookies`, `env`, `vars`, `url`, and the
11
+ short-circuit helpers `ctx.json(data, init?)`, `ctx.html(body, init?)`,
12
+ `ctx.redirect(to, status?)`. Keep it thin — don't expect a
13
+ Next-style `request.cookies.set(...)` API.
14
+ - **No Hono / Express / Fastify types.** If you find yourself reaching
15
+ for `MiddlewareHandler` from Hono, write the standard
16
+ `Middleware = (req, ctx, next) => Promise<Response>` instead.
17
+ - **React SSR uses `renderToReadableStream`** (the streaming web API).
18
+ Do not use `renderToString` or `renderToPipeableStream`.
19
+ - **Client hydration uses `hydrateRoot`** (React 19). Do not use
20
+ `ReactDOM.render`.
21
+
22
+ If a deployment target needs platform-specific wiring (Vercel edge
23
+ context, Cloudflare bindings, etc.), the framework's adapters under
24
+ `sordo/adapters` translate to/from these web-standard handlers — that
25
+ belongs in the adapter, not in your routes.
@@ -0,0 +1,27 @@
1
+ # {{name}}
2
+
3
+ Built with Sordo — a Bun-native full-stack meta-framework.
4
+
5
+ > Codex reads this file. The conventions below are split into focused
6
+ > files under `.codex/rules/`; treat the links here as authoritative —
7
+ > open each one when its topic is in scope for the task at hand.
8
+
9
+ ## Conventions
10
+
11
+ - [Bun-native](.codex/rules/bun-native.md) — reach for Bun primitives, not Node-era replacements.
12
+ - [Web-standards boundary](.codex/rules/web-standards-boundary.md) — handlers use standard Request / Response; `SordoContext` stays thin.
13
+ - [Filesystem routing](.codex/rules/filesystem-routing.md) — how `app/routes/` becomes URLs.
14
+ - [Islands](.codex/rules/islands.md) — when and how to use `app/islands/*.tsx`.
15
+ - [Build-time discovery](.codex/rules/build-time-discovery.md) — discovery happens at build time, not at request time.
16
+ - [Optional AI dependency](.codex/rules/optional-ai.md) — keep `@anthropic-ai/sdk` import-disjoint from non-AI code paths.
17
+ - [Sordo CLI](.codex/rules/sordo-cli.md) — `sordo dev / build / start / deploy / secret`.
18
+ - [Sordo patterns](.codex/rules/sordo-patterns.md) — add UI components and scaffold feature patterns (auth, CRM, task board, pivot, dashboard).
19
+
20
+ ## Live inventory
21
+
22
+ The section between the markers below is regenerated by `sordo dev`
23
+ and `sordo build` from the actual contents of `app/`. Everything
24
+ outside the markers is preserved across regenerations.
25
+
26
+ <!-- sordo:manifest-start -->
27
+ <!-- sordo:manifest-end -->
@@ -0,0 +1,7 @@
1
+ node_modules
2
+ .sordo
3
+ .git
4
+ *.log
5
+ Dockerfile
6
+ .dockerignore
7
+ README.md
@@ -0,0 +1,27 @@
1
+ # syntax=docker/dockerfile:1
2
+ # Multi-stage build for a Sordo app on the `bun` adapter.
3
+ # Build: docker build -t {{name}} .
4
+ # Run: docker run -p 3000:3000 {{name}}
5
+
6
+ FROM oven/bun:1.3 AS base
7
+ WORKDIR /app
8
+
9
+ # --- deps: install once, cached on package.json changes ---
10
+ FROM base AS deps
11
+ COPY package.json bun.lock* ./
12
+ RUN bun install
13
+
14
+ # --- build: produce the production server bundle in .sordo/ ---
15
+ FROM base AS build
16
+ COPY --from=deps /app/node_modules ./node_modules
17
+ COPY . .
18
+ RUN bunx sordo build --target bun
19
+
20
+ # --- release: minimal runtime image ---
21
+ FROM base AS release
22
+ ENV NODE_ENV=production
23
+ COPY --from=deps /app/node_modules ./node_modules
24
+ COPY --from=build /app/.sordo ./.sordo
25
+ COPY package.json ./
26
+ EXPOSE 3000
27
+ CMD ["bun", ".sordo/server/server-entry.js"]
@@ -0,0 +1,18 @@
1
+ # packages/
2
+
3
+ Shared code for this Bun workspace. Create a package per shared concern
4
+ (e.g. `packages/ui`, `packages/db`) with its own `package.json`, then depend
5
+ on it from an app under `apps/*` using the workspace protocol:
6
+
7
+ ```jsonc
8
+ // apps/<app>/package.json
9
+ {
10
+ "dependencies": {
11
+ "@{{name}}/ui": "workspace:*"
12
+ }
13
+ }
14
+ ```
15
+
16
+ Bun resolves `workspace:*` to the local package and runs scripts
17
+ topologically with `bun --filter`. This monorepo is intentionally
18
+ Bun-workspaces-only — no Turborepo / Nx.
@@ -0,0 +1,122 @@
1
+ <!--
2
+ Canonical source for the /sordo pattern catalog (cli spec 19).
3
+ Both the Claude skill (.claude/skills/sordo/SKILL.md) and the Codex rule
4
+ (.codex/rules/sordo-patterns.md) are generated from this body by
5
+ scripts/gen-sordo-skill.ts. Edit THIS file, then run
6
+ `bun run generate:sordo-skill`. Do not edit the generated files by hand.
7
+ -->
8
+
9
+ ## When to use
10
+
11
+ Use this when the user wants to **add a UI component** or **scaffold a
12
+ feature pattern** (auth + RBAC, a CRM, a task board, a pivot table, a
13
+ dashboard). It covers scaffolding only — for running, building, deploying, or
14
+ managing secrets, use the `sordo-cli` skill instead.
15
+
16
+ Two capabilities:
17
+
18
+ 1. **Add a UI component** — a thin wrapper over the deterministic catalog.
19
+ 2. **Scaffold a feature pattern** — instruction-driven: you generate the files,
20
+ adapting names/fields/copy to the user's domain.
21
+
22
+ ## Add a component
23
+
24
+ Components are upstream shadcn/ui, stamped verbatim — never hand-author
25
+ component source; the shadcn registry is the source of truth.
26
+
27
+ 1. If `app/components/ui/_internal/` does not exist, the UI setup isn't
28
+ initialized — run `sordo ui init --shadcn` first (it wires the `@/*` alias
29
+ and `app/lib/utils.ts`).
30
+ 2. Run `sordo add @shadcn/<name>` (preview first with
31
+ `sordo add --view @shadcn/<name>` if the user wants to see the source).
32
+ 3. Import the stamped component from `app/components/ui/<name>.tsx` and use it.
33
+ Pages that render shadcn components must `export const hydrate = true`
34
+ (whole-tree hydration).
35
+
36
+ `sordo add` edits `package.json` (it never runs an install) and stamps source
37
+ into `app/components/ui/`. After adding, remind the user to run `bun install` if
38
+ new peer deps were added.
39
+
40
+ ## Scaffold a pattern
41
+
42
+ Pick a pattern below, `sordo add @shadcn/<name>` its components first, then
43
+ generate the listed files — adapting entity names, fields, columns, and copy to
44
+ the user's stated domain (e.g. "a CRM for veterinary clinics").
45
+
46
+ | Pattern | Goal | `@shadcn/<name>` components | Generated files (under `app/`) |
47
+ |---|---|---|---|
48
+ | **auth-rbac** | Login / logout + role-gated route | `input`, `label`, `button`, `card` | `routes/login.tsx` (native POST form), `routes/api/login.ts`, `routes/api/logout.ts`, `routes/admin.tsx` (gated by middleware), `app/middleware.ts` (gates `/admin`), `lib/auth.ts` (cookie session over mock users), `lib/rbac.ts` (role guard), `lib/mock-users.ts` |
49
+ | **crm** | Contacts list + detail / edit | `table`, `dialog`, `form`, `input`, `button`, `badge` | `routes/contacts/index.tsx` (table), `routes/contacts/[id].tsx` (detail), `islands/ContactForm.tsx`, `lib/mock-contacts.ts` |
50
+ | **task** | Task board / list | `card`, `checkbox`, `badge`, `dialog`, `button` | `routes/tasks.tsx`, `islands/TaskBoard.tsx` (columns + toggle), `lib/mock-tasks.ts` |
51
+ | **pivot** | Group-by / pivot over rows | `table`, `select`, `card` | `routes/pivot.tsx`, `islands/PivotTable.tsx` (pick row/col/measure), `lib/mock-rows.ts` |
52
+ | **dashboard** | Metrics overview | `card`, `chart`, `separator`, `sidebar` | `routes/dashboard.tsx` (cards + chart + sidebar shell), `lib/mock-metrics.ts` |
53
+
54
+ Per-pattern recipes:
55
+
56
+ - **auth-rbac** — sessions are a signed cookie over the mock user list. Because
57
+ pages can't read cookies or redirect (see Conventions), the gate lives in
58
+ `app/middleware.ts`: it checks the session + role and redirects unauthenticated
59
+ `/admin` hits to `/login`. The login page is a native `<form method="post"
60
+ action="/api/login">` (no `form` component) posting to `routes/api/login.ts`,
61
+ which sets the cookie and redirects; `routes/api/logout.ts` clears it. Make the
62
+ mock-only nature loud: a banner on the login page and a TODO at the top of the
63
+ auth module. Real auth needs persistence (a future DB spec).
64
+ - **crm** — the list uses `table` over `mock-contacts`; create / edit
65
+ happens in a `dialog` driven by a `form` island. The detail route reads the
66
+ same mock store by id.
67
+ - **task** — the board is an island holding `useState` columns; toggling a
68
+ `checkbox` moves a task between done / not-done. No persistence — state resets
69
+ on reload (call this out).
70
+ - **pivot** — an island lets the user pick a row dimension, a column dimension,
71
+ and a numeric measure from `select`s, then renders the aggregated `table`.
72
+ Aggregation runs client-side over the mock rows.
73
+ - **dashboard** — a static SSR shell (`sidebar` is `subtree`, `chart` hydrates)
74
+ with metric `card`s fed by `mock-metrics`; the chart is the one interactive
75
+ island.
76
+
77
+ Always `sordo add @shadcn/<name>` the listed components (running
78
+ `sordo ui init --shadcn` first if needed) before generating files that import
79
+ them. Only reference components that exist in the upstream shadcn registry.
80
+
81
+ ## Depth contract: UI + mock data
82
+
83
+ Every pattern is scaffolded at **"UI + mock data"** depth:
84
+
85
+ - **In scope:** SSR routes / pages, islands where interactivity is needed,
86
+ stamped UI components, and a typed in-memory seed in
87
+ `app/lib/mock-<entity>.ts` that the pages read from.
88
+ - **Out of scope:** `bun:sqlite`, migrations, a real persistence or auth
89
+ backend, network calls. The pattern *shows the shape*; the developer swaps the
90
+ mock data for a real source later.
91
+ - Every generated `mock-*` module starts with `// TODO: replace mock data with a
92
+ real source`, and the route / page carries a short note marking the mock
93
+ boundary.
94
+
95
+ Do not generate a database layer, migrations, or a real auth/network backend
96
+ from this skill — that is deferred to a future spec.
97
+
98
+ ## Conventions
99
+
100
+ - Pages live under `app/routes/*.tsx` (default-export a React component); API
101
+ handlers under `app/routes/api/*.ts` (named `GET`/`POST`/… returning a
102
+ `Response`, e.g. via `ctx.json()`). Dynamic segments use `[id]`. A `.ts` route
103
+ **must** be under `app/routes/api/` — anywhere else is a build error.
104
+ - **Pages get only `ctx.params`** — they can't read cookies, set headers, or
105
+ redirect. Push that work to an API route or to `app/middleware.ts` (the single
106
+ global `Middleware (req, ctx, next)`, the only place to gate a page). Mutation
107
+ forms use a native `<form method="post" action="/api/…">` posting to a `.ts`
108
+ handler.
109
+ - Islands (interactive client components) live under `app/islands/` and are
110
+ wrapped at the use site in `<Island name="…">…</Island>` from `sordo/render`.
111
+ `chart` and `form` are islands (they pull `recharts` / `react-hook-form`).
112
+ - **Styling is opt-in per page.** If `app/components/_head.tsx` exists, every new
113
+ page route must re-export it (`export { head } from "../components/_head.tsx";`)
114
+ or it renders unstyled. Run `bun run css` (or `bun run css:watch`) after adding
115
+ classNames; `dev`/`build` compile it for you.
116
+ - Mock data lives in `app/lib/mock-<entity>.ts`, typed, with the TODO marker.
117
+ - Never re-author component source — stamp from the catalog and import.
118
+
119
+ ## See also
120
+
121
+ - The `sordo-cli` skill — running, building, deploying the app.
122
+ - cli specs 11–15 (UI: `ui init`, `add`, `view`, `update`, registries).
@@ -0,0 +1,181 @@
1
+ # {{name}}
2
+
3
+ Built with [Sordo](https://github.com/bihaviour/sordo) — a
4
+ Bun-native full-stack meta-framework.
5
+
6
+ <!-- if:type=fullstack -->
7
+ ## What you got
8
+
9
+ A full-stack Sordo app:
10
+
11
+ - `app/routes/index.tsx` — server-rendered page that mounts an island.
12
+ - `app/islands/TodoApp.tsx` — `useState`-based todo list, hydrated in the browser.
13
+ - `app/routes/api/health.ts` — a JSON API route (`GET /api/health` → `{ ok: true }`).
14
+ - `app/server.ts` — dev entry that wires the router into `Bun.serve`.
15
+ <!-- /if -->
16
+ <!-- if:type=frontend -->
17
+ ## What you got
18
+
19
+ A frontend Sordo app:
20
+
21
+ - `app/routes/index.tsx` — server-rendered page that mounts an island.
22
+ - `app/islands/TodoApp.tsx` — `useState`-based todo list, hydrated in the browser.
23
+ - `app/server.ts` — dev entry that wires the router into `Bun.serve`.
24
+ <!-- /if -->
25
+ <!-- if:type=backend -->
26
+ ## What you got
27
+
28
+ A backend Sordo app — API routes, no React UI:
29
+
30
+ - `app/routes/api/health.ts` — `GET /api/health` → `{ ok: true }`.
31
+ - `app/routes/api/todos.ts` — a sample in-memory `GET` / `POST` resource.
32
+ - `app/server.ts` — dev entry that wires the router into `Bun.serve`.
33
+ <!-- /if -->
34
+
35
+ ## Run it
36
+
37
+ ```sh
38
+ bun install # if you used --no-install
39
+ <!-- if:monorepo=yes -->bun --filter {{app_name}} dev # → http://localhost:3000<!-- /if -->
40
+ <!-- if:monorepo=no -->bunx sordo dev # → http://localhost:3000<!-- /if -->
41
+ ```
42
+
43
+ <!-- if:ui=yes -->
44
+ ## UI starter
45
+
46
+ Styled components are stamped into `app/components/ui/` (`button`, `card`,
47
+ `input`, `label`) with shared helpers in `app/components/ui/_internal/` and
48
+ design tokens in `app/styles/tokens.css`.
49
+
50
+ Add more components with `sordo add @shadcn/<component>` (e.g.
51
+ `sordo add @shadcn/dialog`), preview first with `sordo add --view @shadcn/<component>`, or ask your coding agent — see
52
+ the agent section below.
53
+
54
+ ### Styling
55
+
56
+ Sordo bundles no CSS, so the starter wires Tailwind for you:
57
+
58
+ - `app/styles/app.css` is pre-wired (`@import "tailwindcss"` + the token mapping).
59
+ - `bun run css` compiles it to `app/styles/app.generated.css` (gitignored).
60
+ `bun run dev` and `bun run build` run this first, so the app is styled on boot.
61
+ - `app/routes/api/styles.ts` serves the compiled sheet and `app/components/_head.tsx`
62
+ links it. Each page re-exports that `head` —
63
+ `export { head } from "../components/_head.tsx";` — so add the line to new pages.
64
+
65
+ While iterating on classNames, run the watcher in a second terminal so the sheet
66
+ rebuilds as you save:
67
+
68
+ ```sh
69
+ bun run css:watch
70
+ ```
71
+ <!-- /if -->
72
+
73
+ ## Project layout
74
+
75
+ <!-- if:monorepo=yes -->
76
+ ```
77
+ apps/
78
+ {{app_name}}/
79
+ app/
80
+ routes/ # filesystem-routed pages and API handlers
81
+ islands/ # interactive client components
82
+ server.ts # dev entry — wires the router into Bun.serve
83
+ sordo.config.ts
84
+ package.json
85
+ packages/ # shared workspace packages
86
+ package.json # Bun workspace root
87
+ ```
88
+
89
+ This is a Bun workspace. Run app scripts with `bun --filter <app> <script>`
90
+ (e.g. `bun --filter {{app_name}} build`) or from inside `apps/{{app_name}}/`.
91
+ Add more apps under `apps/` and shared code under `packages/`.
92
+ <!-- /if -->
93
+ <!-- if:monorepo=no -->
94
+ ```
95
+ app/
96
+ routes/ # filesystem-routed pages and API handlers
97
+ islands/ # interactive client components
98
+ server.ts # dev entry — wires the router into Bun.serve
99
+ sordo.config.ts
100
+ package.json
101
+ tsconfig.json
102
+ ```
103
+ <!-- /if -->
104
+
105
+ ## Build for production
106
+
107
+ ```sh
108
+ <!-- if:monorepo=yes -->bun --filter {{app_name}} run build<!-- /if -->
109
+ <!-- if:monorepo=no -->bun run build<!-- /if -->
110
+ ```
111
+
112
+ Build artifacts land in `.sordo/`. Run the server bundle with
113
+ `bun .sordo/server/server-entry.js`.
114
+
115
+ <!-- if:target=container -->
116
+ ## Deploy — container
117
+
118
+ A `Dockerfile` (+ `.dockerignore`) is included for the `bun` runtime:
119
+
120
+ ```sh
121
+ docker build -t {{name}} .
122
+ docker run -p 3000:3000 {{name}}
123
+ ```
124
+ <!-- /if -->
125
+ <!-- if:deploy=cloudflare -->
126
+ ## Deploy
127
+
128
+ This project is configured for **Cloudflare** deployment. See the
129
+ `@sordo/deploy-cloudflare` plugin docs for the next steps.
130
+ <!-- /if -->
131
+ <!-- if:deploy=vercel -->
132
+ ## Deploy
133
+
134
+ This project is configured for **Vercel** deployment. See the
135
+ `@sordo/deploy-vercel` plugin docs for the next steps.
136
+ <!-- /if -->
137
+ <!-- if:deploy=deno -->
138
+ ## Deploy
139
+
140
+ This project is configured for **Deno Deploy**. See the
141
+ `@sordo/deploy-deno` plugin docs for the next steps.
142
+ <!-- /if -->
143
+ <!-- if:deploy=netlify -->
144
+ ## Deploy
145
+
146
+ This project is configured for **Netlify Edge**. See the
147
+ `@sordo/deploy-netlify` plugin docs for the next steps.
148
+ <!-- /if -->
149
+
150
+ <!-- if:agent=claude -->
151
+ ## Claude Code is set up
152
+
153
+ `CLAUDE.md` describes the framework conventions. The `/sordo` skill
154
+ (`.claude/skills/sordo/`) adds components and scaffolds feature patterns
155
+ (auth, CRM, task board, dashboard, …). For a guided first scaffold, open a new
156
+ terminal and run:
157
+
158
+ ```sh
159
+ claude --permission-mode plan "/sordo-init"
160
+ ```
161
+ <!-- /if -->
162
+ <!-- if:agent=codex -->
163
+ ## Codex is set up
164
+
165
+ `AGENTS.md` describes the framework conventions and links
166
+ `.codex/rules/sordo-patterns.md`, which tells Codex how to add components and
167
+ scaffold feature patterns. Open Codex and ask it to scaffold a pattern.
168
+ <!-- /if -->
169
+ <!-- if:agent=none -->
170
+ ## No agent
171
+
172
+ Add UI components with `sordo add @shadcn/<component>`. Feature patterns
173
+ (auth, CRM, dashboard, …) are agent-driven — scaffold a project with
174
+ `--agent claude` or `--agent codex` to get the `/sordo` skill.
175
+ <!-- /if -->
176
+
177
+ ## Learn more
178
+
179
+ - Sordo docs: https://bun-patties.com
180
+ - Bun: https://bun.sh
181
+ - React 19: https://react.dev
@@ -0,0 +1,83 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+
5
+ interface Todo {
6
+ id: number;
7
+ text: string;
8
+ done: boolean;
9
+ }
10
+
11
+ export default function TodoApp() {
12
+ const [todos, setTodos] = useState<Todo[]>([
13
+ { id: 1, text: "edit app/routes/index.tsx", done: false },
14
+ { id: 2, text: "edit app/islands/TodoApp.tsx", done: false },
15
+ { id: 3, text: "delete this demo when you're ready", done: false },
16
+ ]);
17
+ const [draft, setDraft] = useState("");
18
+
19
+ function add(): void {
20
+ const text = draft.trim();
21
+ if (!text) return;
22
+ setTodos([...todos, { id: Date.now(), text, done: false }]);
23
+ setDraft("");
24
+ }
25
+
26
+ function toggle(id: number): void {
27
+ setTodos(todos.map((t) => (t.id === id ? { ...t, done: !t.done } : t)));
28
+ }
29
+
30
+ function remove(id: number): void {
31
+ setTodos(todos.filter((t) => t.id !== id));
32
+ }
33
+
34
+ return (
35
+ <section aria-label="Todo demo">
36
+ <form
37
+ onSubmit={(e) => {
38
+ e.preventDefault();
39
+ add();
40
+ }}
41
+ >
42
+ <input
43
+ type="text"
44
+ value={draft}
45
+ onChange={(e) => setDraft(e.target.value)}
46
+ placeholder="What needs doing?"
47
+ aria-label="New todo"
48
+ />
49
+ <button type="submit">Add</button>
50
+ </form>
51
+ <ul>
52
+ {todos.map((t) => (
53
+ <li key={t.id}>
54
+ <label>
55
+ <input
56
+ type="checkbox"
57
+ checked={t.done}
58
+ onChange={() => toggle(t.id)}
59
+ />
60
+ <span
61
+ style={{ textDecoration: t.done ? "line-through" : "none" }}
62
+ >
63
+ {t.text}
64
+ </span>
65
+ </label>
66
+ <button
67
+ type="button"
68
+ onClick={() => remove(t.id)}
69
+ aria-label="Remove"
70
+ >
71
+ ×
72
+ </button>
73
+ </li>
74
+ ))}
75
+ </ul>
76
+ <p>
77
+ <small>
78
+ {todos.filter((t) => !t.done).length} of {todos.length} remaining
79
+ </small>
80
+ </p>
81
+ </section>
82
+ );
83
+ }
@@ -0,0 +1,8 @@
1
+ import type { SordoContext } from "sordo/middleware";
2
+
3
+ // API routes live under app/routes/api/ and export named HTTP methods
4
+ // (GET/POST/…) that return a standard Response. `ctx.json()` is the thin
5
+ // SordoContext helper for JSON replies.
6
+ export function GET(_req: Request, ctx: SordoContext): Response {
7
+ return ctx.json({ ok: true });
8
+ }
@@ -0,0 +1,29 @@
1
+ import { Island } from "sordo/render";
2
+ import TodoApp from "../islands/TodoApp.tsx";
3
+
4
+ export const meta = {
5
+ title: "Welcome to Sordo",
6
+ description: "A Bun-native full-stack meta-framework.",
7
+ };
8
+
9
+ export default function Index() {
10
+ return (
11
+ <main>
12
+ <h1>Welcome to Sordo</h1>
13
+ <p>
14
+ This page is server-rendered. The list below is a client island —{" "}
15
+ <code>app/islands/TodoApp.tsx</code> — hydrated in the browser.
16
+ </p>
17
+ <Island name="TodoApp">
18
+ <TodoApp />
19
+ </Island>
20
+ <hr />
21
+ <p>
22
+ <small>
23
+ When you're ready, replace this page — or run <code>/sordo-init</code>{" "}
24
+ to scaffold your first real feature.
25
+ </small>
26
+ </p>
27
+ </main>
28
+ );
29
+ }