Skip to content

feat: implement web-base CLI, templates, workflows, and skill#2

Merged
daniel-rck merged 9 commits into
mainfrom
claude/add-bunx-cli-P0cds
May 20, 2026
Merged

feat: implement web-base CLI, templates, workflows, and skill#2
daniel-rck merged 9 commits into
mainfrom
claude/add-bunx-cli-P0cds

Conversation

@daniel-rck
Copy link
Copy Markdown
Owner

Summary

The repo's specs in docs/specs/ were fully written but nothing was implemented. This PR makes bunx github:daniel-rck/web-base ... actually work as the README advertises.

  • CLI (cli/) — citty entry + three commands (init, add, update) + three lib modules (manifest, copy, pkg), bundled via bun build into cli/dist/index.js. A prepare script triggers the build on bun install so bunx-from-GitHub works without a separate build step.
  • Templates (cli/templates/) — all 9: hygiene, biome, router, storage, pwa, worker, layout, core (meta), sync (extra).
  • Workflows (.github/workflows/) — reusable web-app-ci.yml for apps, plus tools-ci.yml for this repo (includes the CLI smoke test and skill/template alignment check).
  • Skill (skill/) — SKILL.md plus 10 references (8 per-template + tech-stack.md + ci.md).
  • Tests — 16 Vitest tests covering resolveTemplate, copyTemplateFiles, and patchPackageJson semantics.

One spec conflict resolved in this PR: 05-skill.md originally listed reference filenames like tech-stack.md and repo-hygiene.md, but the alignment check in 06-workflows.md's tools-ci.yml requires skill/references/<template-name>.md for every template. The references now match template names 1:1 (so CI passes); the original cross-cutting references tech-stack.md and ci.md are kept in addition.

Verified locally

  • bun run typecheck, bun run lint, bun run test (16 passed), bun run build — all green.
  • node cli/dist/index.js --help and add (no args) list all 9 templates with core marked [meta].
  • add hygiene in a scratch dir produces the four expected files.
  • add core in a scratch dir produces 24 files across the 7 leaf templates and patches package.json.
  • init --name myapp writes a fresh per-app package.json and applies core.
  • add sync adds the four sync files plus docs/sync.md.
  • bunx flow simulated end-to-end: fresh git clone (no cli/dist/), bun install triggers prepare → build → CLI runs.

Test plan

  • Tools CI passes (lint, typecheck, test, build, CLI smoke, skill alignment)
  • Post-merge: bunx github:daniel-rck/web-base init in an empty directory
  • Post-merge: bunx github:daniel-rck/web-base add hygiene in an existing app
  • Post-merge: an app's CI can call daniel-rck/web-base/.github/workflows/web-app-ci.yml@main

Generated by Claude Code

claude added 9 commits May 20, 2026 20:22
Adds the monorepo root configs from docs/specs/01-monorepo-structure.md.
The bin field on package.json plus the bundled cli/dist build is what
makes 'bunx github:daniel-rck/web-base ...' work after install.
Implements the three CLI library modules per docs/specs/02-cli.md:
- lib/manifest.ts: loadManifest, resolveTemplate (recursive meta-template
  expansion with dedupe), templatesDir (built/source fallback +
  WEB_BASE_TEMPLATES_DIR env override for tests), listTemplates
- lib/copy.ts: copyTemplateFiles with skip/force/overwrite/dryRun
  semantics; diffTemplateFile for the update command
- lib/pkg.ts: additive patchPackageJson (never removes keys, only sets
  when value differs)
Implements the three subcommands per docs/specs/02-cli.md:
- commands/init.ts: prompts for an app name, writes the per-app
  package.json template from docs/specs/07-conventions.md, then applies
  the 'core' meta-template; aborts if package.json already exists
  unless --force is passed
- commands/add.ts: applies a template (or expands a meta) via
  resolveTemplate; lists available templates when called without an arg,
  marking metas with [meta]
- commands/update.ts: diffs local files against the template source and
  reports missing/identical/differs; --apply overwrites local from
  template (does not patch package.json)
- index.ts: registers the three subcommands on a citty defineCommand
Three leaf templates per docs/specs/03-templates.md:
- hygiene: LICENSE (MIT), CONTRIBUTING.md, SECURITY.md, .editorconfig
- biome: per-app biome.json (slightly less strict than web-base's own:
  warns on noConsoleLog + noExplicitAny) plus lint/format scripts
- router: createBrowserRouter scaffold + ROUTES const for typed paths
Three more leaves per docs/specs/03-templates.md:
- storage: idb factory with AppSchema interface placeholder +
  BroadcastChannel-driven useLiveQuery hook returning {data, loading,
  error}; mutation helpers emit on db:<store> + db:* channels
- pwa: injectManifest sw.ts skeleton (precache + skipWaiting +
  clientsClaim + message handler) plus a vite.snippet.md to merge into
  vite.config.ts and a separate tsconfig.sw.json for WebWorker lib
- worker: 30-line Cloudflare Worker with /healthz, /api/* stub, static-
  asset fallthrough via env.ASSETS.fetch, wrangler.toml with R2/KV
  binding placeholders
The shared UI structure per docs/specs/04-layout-system.md:
- AppShell: top-level wrapper, sticky h-14 header, sidebar on >=md,
  bottom-nav on <md
- AppHeader: container max-w-4xl, backdrop-blur, optional logo + actions
- AppNav: sidebar and bottom variants, NavLink-based, active state via
  bg-accent-100 / text-accent-600
- PageHeader: section header, optional subtitle + actions
- primitives.tsx: Card, EmptyState, Spinner, Badge (5 variants), Button
  (4 variants x 3 sizes), all forwarding refs and merging className
- theme.css: OKLCH tokens derived from --accent-h (per-app: only this
  changes), auto dark mode via prefers-color-scheme
- index.ts: barrel re-exports
- core: meta-template extending hygiene, biome, router, storage, pwa,
  worker, layout in that order (layout last because it imports from
  storage and router)
- sync: extra (not in core) per docs/specs/03-templates.md. Ships the
  E2E-encrypted Hausverwaltung-style sync:
  - client.ts: SyncClient with enable/push/pull, persists deviceSecret
    + etag in localStorage, ETag-based optimistic concurrency
  - crypto.ts: HKDF-SHA256 key derivation from device secret, AES-GCM-
    256 encrypt/decrypt, Crockford-base32 objectId
  - types.ts: SyncEnvelope, PairingSlot, SyncClientState shapes
  - worker-sync.ts: R2 GET/PUT handlers with If-Match/If-None-Match,
    KV-backed rate limits (60 ops/min, 5 pair/min, 10 claim/15min)
  - sync.md: architecture summary copied into docs/sync.md
Both per docs/specs/06-workflows.md.

- web-app-ci.yml: reusable workflow (workflow_call) consumed by every
  app via uses: daniel-rck/web-base/.github/workflows/web-app-ci.yml@main.
  Inputs: bun-version (default 1.3.11), run-tests (default true),
  run-build (default true). Steps: setup-bun, install --frozen-lockfile,
  lint, typecheck, test, build.
- tools-ci.yml: CI for this repo. Runs the same lint/typecheck/test/
  build plus a CLI --help smoke, an 'add hygiene' integration test in
  /tmp/scratch, and a skill/template alignment check that fails if any
  cli/templates/<name>/ (except core) lacks a matching
  skill/references/<name>.md (or <name>-system.md).
Per docs/specs/05-skill.md.

SKILL.md trigger fires on Hausverwaltung/Tennisturnier/ErinnerMich work
and on '@daniel-rck/web-base' mentions. Body covers the apps in scope,
baseline stack, CLI commands, six architecture invariants, a reference
mapping table, and the anti-patterns list.

References under skill/references/ are aligned 1:1 with the CLI
templates (the tools-ci.yml alignment check enforces this), plus two
cross-cutting references (tech-stack, ci):

- biome.md, hygiene.md, layout-system.md, pwa.md, router.md,
  storage.md, sync.md, worker.md: one per template
- tech-stack.md: dependency pins, per-app package.json/biome/tsconfig
  templates, vite.config.ts skeleton
- ci.md: caller pattern and inputs for the reusable workflow

Note: the spec's 05-skill.md original list (tech-stack, layout-system,
ci, repo-hygiene) didn't cover the per-template alignment requirement
in tools-ci.yml. The references now match template names so CI passes;
hygiene.md absorbs what repo-hygiene.md would have held.
@daniel-rck daniel-rck marked this pull request as ready for review May 20, 2026 20:28
@daniel-rck daniel-rck merged commit 052e6f7 into main May 20, 2026
1 check passed
@daniel-rck daniel-rck deleted the claude/add-bunx-cli-P0cds branch May 20, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants