Skip to content

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What this is

Nexus Forge — a static "rebuild specification" workbench for GitNexus: PRD, architecture, feature catalog, pipeline DAG, graph schema, MCP/CLI surfaces, and a 14-milestone rebuild playbook. It was exported from Grok's App Builder ("Export from Grok" commit), so the repo is a Grok App Builder template (TanStack Start + React 19 + Tailwind v4) with the app's content layered on top.

There is no backend usage: auth and database are OFF (.grok/app-env.json → VITE_AUTH_ENABLED: "false", deploy.database: false). The only persisted state is the playbook checklist in localStorage via zustand (src/lib/playbook-store.ts).

AGENTS.md is the Grok sandbox contract (written for the Grok Build agent at /workspace). Its sandbox-specific rules (preview proxy, startup.sh, "user can't see a terminal") don't apply here, but its template invariants do — see "Template invariants" below.

Commands

npm run dev          # Vite dev server on 0.0.0.0:8080 (via scripts/with-app-env.mjs)
npm run build        # vite build (nitro, vercel preset) + db:migrate (no-op here: no migrations)
npm run typecheck    # tsc --noEmit  (checkJs is on; covers src/ and server/)
npm run lint         # eslint .
npm run format       # prettier --write .
npm run test         # node --test scripts/**/*.test.mjs + two src/lib tests via --experimental-strip-types
npm run preview:restart   # serve built output on 127.0.0.1:8081 (frees the port first)
npm run preview:stop

Run a single test:

node --test scripts/preview.test.mjs
node --experimental-strip-types --test src/lib/auth/gate-identity.test.ts

Browser smoke check (Playwright; desktop + mobile screenshots + JSON verdict; fails on blank root or console errors):

node scripts/browser-smoke.mjs [url] [out.png] [--baseline prior-verdict.json]
# defaults: http://127.0.0.1:8080/ and /workspace/screenshots/app-builder-preview.png

Note: browser-smoke.mjs restricts screenshot/verdict output paths to /workspace (via browser-guard.mjs), and startup.sh hardcodes cd /workspace — both are Grok-sandbox assumptions that won't hold on a local checkout without adjustment.

Always start Vite through the npm scripts, never npx vite — only scripts/with-app-env.mjs injects .grok/app-env.json into the env, and npm run check:auth / the smoke script fail if a running dev server disagrees with the build about VITE_AUTH_ENABLED.

Architecture

Content-as-data. Every page renders typed constants from src/data/*.ts (prd, features, pipeline, schema, models, surfaces, languages, stack, packages, playbook, quality, architecture). Shared types live in src/data/types.ts; src/data/nav.ts holds APP metadata (name, GitNexus version/snapshot, stars) and the NAV list that drives the sidebar, overview cards, and section IDs. src/data/search.ts builds SEARCH_INDEX by flattening all of these — adding content to a data file means also adding it to the search index if it should be findable via ⌘K.

Routing. TanStack Start file routes in src/routes/ — one flat route per NAV section. src/routeTree.gen.ts is generated by the router plugin (eslint-ignored; don't hand-edit). src/router.tsx must keep the named getRouter() export and defaultErrorComponent. src/routes/__root.tsx is the document shell: <PreviewHostBridge /> → <AuthProvider> → <Shell> → <Outlet />.

Shell & components. src/components/shell.tsx exports Shell (sticky header, responsive sidebar nav, ⌘K palette toggle) plus PageHead and Panel primitives used by every route. command-palette.tsx searches SEARCH_INDEX. Path alias @/* → src/*.

Styling. Tailwind v4 with the theme declared in src/styles.css @theme: color tokens void / plate / inset / paper / muted / signal / line / glow, IBM Plex Sans/Mono, tiny radii. Use these token classes (bg-plate, text-signal, border-line, …) rather than raw Tailwind palette colors to stay consistent with the existing pages.

Pre-wired but unused platform layer. src/lib/db.ts (Neon when DATABASE_URL is set, else embedded PGLite; migrations from migrations/*.sql), src/lib/auth/* (Better Auth, authMiddleware for server functions), src/lib/app-data/* (viewer connector data gate), src/lib/multiplayer/*. None of this is imported by the app's routes. Per AGENTS.md §0.5: don't import @/lib/db or authMiddleware in an auth-off app (the dev user resolves only in preview; deployed it rejects every visitor). Flip .grok/app-env.json and follow .grok/references/data-and-auth.md if that ever changes.

Build/deploy plumbing (vite.config.ts). Plugin order matters: pgliteBootstrapPlugin (dev; skipped when migrations/ has no globbed files) → authPopupPlugin (dev /auth/popup) → appEnvPlugin (dev /__app-env) → grokPwaPlugin → tailwind → tanstackStart → nitro({ preset: "vercel", serverDir: "./server" }) on build/preview only → react. Target is Vercel: no runtime FS writes, no server-only Node APIs at import time.

Template invariants (from AGENTS.md — keep these)

  • Don't recreate vite.config.ts / tsconfig.json; keep the 8080/8081 port contracts, the build-gated nitro plugin, and grokPwaPlugin().
  • Never delete/overwrite public/__grok/, server/, scripts/grok-pwa-*, or the src/lib helpers. App server routes go in src/routes/, never server/.
  • Keep <PreviewHostBridge /> and <AuthProvider> in __root.tsx; don't put og:* / twitter:card meta there (the PWA injector overwrites them). Share-card config is src/lib/og/site.json.
  • Never create src/routes/auth/popup.tsx — /auth/popup is served by the Vite plugin.
  • Never create a .env; only VITE_-prefixed vars reach the browser.
  • The "Created with Grok" branding injection (server/middleware/grok-pwa.ts) is a platform setting, not something to strip in code.