Skip to content

Claude/nextjs spec kit setup pre xu#2620

Closed
Satcomx00-x00 wants to merge 5 commits into
github:mainfrom
Satcomx00-x00:claude/nextjs-spec-kit-setup-preXU
Closed

Claude/nextjs spec kit setup pre xu#2620
Satcomx00-x00 wants to merge 5 commits into
github:mainfrom
Satcomx00-x00:claude/nextjs-spec-kit-setup-preXU

Conversation

@Satcomx00-x00
Copy link
Copy Markdown

Description

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

claude added 5 commits May 18, 2026 07:47
Introduces a presets/nextjs/ preset that specializes Spec-Driven
Development for full-stack Next.js web applications. Encodes behaviors
(not a tech stack) across Frontend, Backend, Security, Performance,
TypeScript & Code Quality, and Infrastructure & Operations.

Every directive is tagged with a Phase (P1 Foundation, P2 MVP,
P3 Hardening, P4 Scale) and Criticality (Critical, High, Medium, Low)
so enforcement scales with the project's maturity.

Ships two artifacts:
- constitution-template.md: project directive with principles, phase
  framework, and the full behavior matrix; replaces the core template.
- agent-context.md: compressed always-on rules for the AI agent, ready
  to mirror into AGENTS.md / CLAUDE.md / copilot-instructions.md.
Introduces a sibling to /speckit.constitution that scans the repository
for evidence and exports a properly-structured constitution to
.specify/memory/constitution.md with a Sync Impact Report mapping
findings to every Critical directive.

Scanners (bash + PowerShell) walk the repo and emit a JSON inventory:
- Markdown files: path, size, head excerpt, and extracted headings.
- package.json: name/version, scripts, engines, deps/devdeps counts,
  framework/tooling/security signals (Next.js, React, TypeScript,
  validation libs, hash libs, OTel/Sentry, etc.).
- tsconfig.json: strict-flag posture (parses JSON-with-comments).
- Next.js structure: App vs Pages router, middleware presence,
  Route Handler count, "use client"/"use server" file counts, and
  server-only/client-only import counts (both side-effect-only and
  named-import forms).
- Tooling: ESLint, Prettier, Biome, Husky, CI workflow files.
- Environment: .env example files, pinned Node version (.nvmrc /
  .node-version / .tool-versions / package.json engines).
- Git metadata, existing constitution detection.

Schema is documented in scripts/SCHEMA.md (schema_version: "1.0") as
the stable contract between script and command. The command file
(commands/speckit.constitution.scan.md) runs the scan, reads relevant
.md docs, infers the operating phase (P1-P4) from evidence, fills the
Next.js constitution template without rewriting the behavior matrix,
and prepends a Sync Impact Report with per-directive status
(MET / NOT MET / PARTIAL / UNVERIFIED).
Replaces the prior "TypeScript & Code Quality Behaviors" section with a
comprehensive "TypeScript Engineering Behaviors" section. Introduces a
third tag — Scope (FE / BE / Both) — that applies specifically to
TypeScript directives, since the same code-quality rules can carry
different weight or scope on frontend versus backend.

New subsections:
- Compiler & Project Config — strict flags from day one; tsc errors
  block CI; @ts-ignore replaced by justified @ts-expect-error.
- Type System Discipline — unknown over any; satisfies / as const over
  casts; discriminated unions; branded IDs; user-defined type
  predicates; readonly inputs; constrained generics.
- SOLID — SRP/OCP for both layers; DIP/DI for backend; ISP/LSP for
  both; composition over inheritance.
- Clean Code & Functional Discipline — pure functions, immutability,
  Rule of Three, KISS/YAGNI, Law of Demeter, low complexity,
  early returns, no boolean-param soup, args <=3.
- Runtime Boundaries — parse don't validate; schema-validated input
  at every boundary; env validation at startup; DTOs decoupled from
  internal models; types generated from the source of truth;
  Result<T, E> for expected failures.
- Frontend Patterns — typed props/events/refs; discriminated-union
  variants; generic components; no leaked server-only types.
- Backend Patterns — server-only marking; typed service signatures;
  typed domain error unions; exhaustive switches with never; opaque
  IDs; domain / persistence / API types kept separate.
- Project Hygiene & DX — one linter + one formatter on pre-commit and
  CI; banned circular imports; naming conventions; co-located types;
  at most one barrel per public boundary; tests on the type contract;
  tsc performance budgeted; TSDoc on non-obvious types.

Updates the operating framework intro to declare the new Scope tag,
refreshes agent-context with the expanded discipline (do / don't),
and updates the /speckit.constitution.scan compliance mapping so the
Sync Impact Report distinguishes Compiler, Type System, and runtime
directives instead of one rolled-up TypeScript bucket.
Introduces a behavioral audit that challenges the codebase against the
TypeScript and Next.js directives in the constitution.

Rule engine (scripts/bash/audit-codebase.sh + powershell mirror):
- 23 high-signal rules across six sections (TS, FE, BE, SEC, PERF, INFRA).
- TS / Compiler & Project Config: strict, noUncheckedIndexedAccess,
  exactOptionalPropertyTypes (Critical) plus noImplicitOverride,
  noFallthroughCasesInSwitch, noImplicitReturns,
  forceConsistentCasingInFileNames (High).
- TS / Type System: any usage, @ts-ignore, unchecked `as` casts
  (with const/unknown exemption), untyped catch.
- BE: DAL modules missing `import 'server-only'`; process.env reads
  outside the env validator module.
- FE: `"use client"` at page/layout/template roots; raw <img> in TSX;
  raw <a href="/..."> in app routes; pages missing metadata exports.
- SEC: localStorage session/token writes; dangerouslySetInnerHTML;
  NEXT_PUBLIC_*SECRET/TOKEN/KEY/PASSWORD; SQL template literals with
  ${...} interpolation.
- PERF: console.log in production source.
- INFRA: CI workflows missing tsc/typecheck step.

Each finding carries rule_id, severity, section, phase, scope,
directive, remediation, file:line, and a snippet. Designed for big
codebases: single file enumeration; parallel grep via xargs -P (bash)
and per-file Select-String (PowerShell); --paths / --rules / --sections
filters; --max-findings-per-rule cap; --list-rules for catalog
introspection; --severity floor.

Commands:
- /speckit.audit — runs the rule engine, persists JSON under
  .specify/audits/, produces a human-readable report grouped by
  severity and section with prioritized actions.
- /speckit.audit.deep — same plus four additional layers: tsc
  --noEmit (treats diagnostics as TS.COMPILER.tsc-diagnostic),
  eslint (TS.LINT.<rule>), npm audit (SEC.DEPS.cve-<pkg>), and
  LLM file-level confirmation that reads flagged files in full,
  marks false positives, correlates cross-file patterns, and
  inspects every "use server" file for the parse -> authorize ->
  ownership -> DTO recipe (BE.ACTION.recipe-violation).

Schema (scripts/SCHEMA.md, schema_version: 1.0) is the stable contract
between the scripts and the commands. Severity maps 1:1 to
constitution criticality so audit reports plug into the same waiver
and exception model.
…scaffold.dal, /speckit.docs.sync commands

Adds five Next.js-specific workflow commands to the preset:

- /speckit.plan: decomposes a feature into routes, RSC/client boundaries,
  Server Actions, DAL methods, schemas, caching strategy, prerendering,
  metadata, accessibility, error handling, and a security checklist — all
  tagged with Phase and Criticality.

- /speckit.tasks: generates dependency-ordered implementation tasks from a
  plan (schema → DAL → actions → route scaffold → RSC → client islands →
  route handlers → metadata → skeletons → tests), each with Next.js-idiomatic
  titles, acceptance criteria, and constitution directive references.

- /speckit.scaffold.route: scaffolds page.tsx (RSC + generateMetadata),
  layout.tsx, loading.tsx (accessible skeleton), error.tsx ("use client"
  boundary), not-found.tsx — with --auth, --no-layout, --title flags.

- /speckit.scaffold.dal: scaffolds lib/dal/<entity>.ts with
  import 'server-only', typed Result<T> envelope, schema-validated inputs,
  CRUD method stubs, and a DTO mapper. Supports --db (prisma/drizzle/kysely/pg),
  --methods, --schema, --no-result-envelope.

- /speckit.docs.sync: syncs AGENTS.md / CLAUDE.md /
  .github/copilot-instructions.md / GEMINI.md from agent-context.md template.
  Conflict detection for custom additions; --dry-run, --force, --targets flags.

Also updates preset.yml (v0.1.0 → v0.2.0) and README.md with a command
reference section and typical workflow.
Copilot AI review requested due to automatic review settings May 18, 2026 14:49
@Satcomx00-x00 Satcomx00-x00 requested a review from mnriem as a code owner May 18, 2026 14:49
@Satcomx00-x00 Satcomx00-x00 deleted the claude/nextjs-spec-kit-setup-preXU branch May 18, 2026 14:50
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