@zero2webmaster/starter-kit 0.6.0 → 0.8.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # z2w-starter-kit
2
2
 
3
- **Version:** 0.6.0 | **Framework:** 2.13.0
3
+ **Version:** 0.8.0 | **Framework:** 2.13.0
4
4
 
5
5
  > Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
6
6
 
@@ -99,4 +99,4 @@ For licensing inquiries: kerry@zero2webmaster.com.
99
99
  ---
100
100
 
101
101
  *Scaffolded 2026-05-28 via the [[instantiate-z2w-project]] Claude Code skill v1; reconciled against the consolidated skill v1.1.0 (brief-first + Agent Coordination block) on 2026-05-29.*
102
- *Version: 0.6.0 | Last Updated: 2026-07-30*
102
+ *Version: 0.8.0 | Last Updated: 2026-07-30*
@@ -9,6 +9,8 @@ export interface ScaffolderOptions extends SubstitutionOptions {
9
9
  }
10
10
  export declare const STANDARDS_BLOCK_MARKER = "<!-- STANDARDS_BLOCK -->";
11
11
  export declare const AGENT_COORDINATION_BLOCK_MARKER = "<!-- AGENT_COORDINATION_BLOCK -->";
12
+ /** Always-on, unlike the coordination marker — every project gets this one. */
13
+ export declare const CAPTURE_LEARNINGS_BLOCK_MARKER = "<!-- CAPTURE_LEARNINGS_BLOCK -->";
12
14
  export declare const AGENTS_BODY_MARKER = "<!-- AGENTS_BODY -->";
13
15
  export declare function resolveBrandSpec(inputs: ScaffoldInputs): BrandPresetSpec;
14
16
  export declare function sub(template: string, inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): string;
@@ -16,6 +16,8 @@ import { buildFirstSessionPrompt, FIRST_SESSION_PROMPT_HEADING, } from "../first
16
16
  import { applySubstitutions } from "../substitute.js";
17
17
  export const STANDARDS_BLOCK_MARKER = "<!-- STANDARDS_BLOCK -->";
18
18
  export const AGENT_COORDINATION_BLOCK_MARKER = "<!-- AGENT_COORDINATION_BLOCK -->";
19
+ /** Always-on, unlike the coordination marker — every project gets this one. */
20
+ export const CAPTURE_LEARNINGS_BLOCK_MARKER = "<!-- CAPTURE_LEARNINGS_BLOCK -->";
19
21
  export const AGENTS_BODY_MARKER = "<!-- AGENTS_BODY -->";
20
22
  export function resolveBrandSpec(inputs) {
21
23
  return getBrandSpec(inputs.brand, inputs.customBrand, inputs.githubOrg);
@@ -473,7 +475,7 @@ ${STANDARDS_BLOCK_MARKER}
473
475
 
474
476
  ---
475
477
 
476
- ${AGENT_COORDINATION_BLOCK_MARKER}## Generic AGENTS — 3-layer system reference
478
+ ${AGENT_COORDINATION_BLOCK_MARKER}${CAPTURE_LEARNINGS_BLOCK_MARKER}## Generic AGENTS — 3-layer system reference
477
479
 
478
480
  The canonical AGENTS body for framework v{{framework_version}} is embedded below by the writer at scaffold time. The project-specific guidance above takes precedence on conflict.
479
481
 
@@ -900,6 +902,11 @@ out/
900
902
  .env
901
903
  .env.local
902
904
  .env*.local
905
+ # Vercel CLI local state. .vercel/project.json pins this checkout to ONE Vercel
906
+ # project id, so a committed copy makes a fork or a staging project silently
907
+ # deploy to the original. Note \`vercel link\` appends a bare \`.vercel\` line
908
+ # itself — if you see a duplicate, that is where it came from.
909
+ .vercel/
903
910
  `,
904
911
  "python-service": `.DS_Store
905
912
  __pycache__/
@@ -6,4 +6,4 @@ export declare function scaffoldNextjs(inputs: ScaffoldInputs, opts?: Scaffolder
6
6
  * they can assert / require the canonical SEO baseline file list without
7
7
  * hardcoding the paths in two places.
8
8
  */
9
- export declare const NEXTJS_SEO_BASELINE_PATHS: readonly ["app/layout.tsx", "app/page.tsx", "app/sitemap.ts", "app/robots.ts", "lib/seo/canonical-host.mjs", "app/opengraph-image.tsx", "lib/analytics/utm.ts", "lib/analytics/Analytics.tsx", "lib/analytics/RouteTracker.tsx", "SEO-CHECKLIST.md", ".env.example"];
9
+ export declare const NEXTJS_SEO_BASELINE_PATHS: readonly ["app/layout.tsx", "app/page.tsx", "app/sitemap.ts", "app/robots.ts", "lib/seo/canonical-host.mjs", "lib/seo/page-metadata.ts", "app/opengraph-image.tsx", "lib/analytics/utm.ts", "lib/analytics/Analytics.tsx", "lib/analytics/RouteTracker.tsx", "SEO-CHECKLIST.md", ".env.example"];
@@ -6,6 +6,11 @@
6
6
  // 1. SSR/SSG — App Router pages are server-rendered by default.
7
7
  // 2. Per-page metadata — root `metadata` in app/layout.tsx + per-page
8
8
  // `metadata` in app/page.tsx with unique title, description, OG, Twitter.
9
+ // Built by the `pageMetadata()` helper in lib/seo/page-metadata.ts, because
10
+ // Next.js merges metadata SHALLOWLY per top-level key: a hand-written
11
+ // `openGraph: { title, description }` REPLACES the layout's whole openGraph
12
+ // object and silently deletes og:type / og:site_name, and the matching
13
+ // `twitter: {}` downgrades the card to a small square.
9
14
  // 3. Exactly one <h1> per page + semantic HTML — app/page.tsx wires it.
10
15
  // 4. Image alt text — the page template uses next/image with `alt=""` /
11
16
  // descriptive alt where appropriate (placeholder content uses semantic
@@ -59,6 +64,7 @@ npm run build && npm start # production build
59
64
 
60
65
  - \`app/layout.tsx\` — root \`metadata\` with \`title.template\`, \`title.default\`, \`description\`, \`openGraph\`, \`twitter\`, \`metadataBase\`; mounts \`<Analytics />\`; JSON-LD Organization schema.
61
66
  - \`app/page.tsx\` — per-page \`metadata\` (unique title + description; never inherit defaults); exactly one \`<h1>\`; semantic HTML.
67
+ - \`lib/seo/page-metadata.ts\` — \`pageMetadata()\`, the ONE builder for every page's \`metadata\`. **Use it for every new page.** Next.js merges metadata shallowly per top-level key, so a hand-written partial \`openGraph\` replaces the layout's whole object and silently drops \`og:type\` / \`og:site_name\`, and a partial \`twitter\` downgrades the card to a small square.
62
68
  - \`lib/analytics/{utm.ts,Analytics.tsx,RouteTracker.tsx}\` — Fathom (per [[fathom-analytics]]); the RouteTracker fires \`trackPageview()\` on route change + captures first-touch UTM. Gated on \`NEXT_PUBLIC_FATHOM_SITE_ID\`.
63
69
  - \`app/sitemap.ts\` — sitemap generator; lists indexable pages. \`lastModified\` is deliberately omitted until you have a real content timestamp.
64
70
  - \`app/robots.ts\` — robots generator. Indexable requires BOTH a production deployment AND a real canonical domain in \`NEXT_PUBLIC_SITE_URL\`; anything else emits \`Disallow: /\`. **Both files are prerendered at build time, so changing \`NEXT_PUBLIC_SITE_URL\` needs a redeploy.**
@@ -289,6 +295,135 @@ export const config = {
289
295
  matcher: ["/((?!_next/|api/health).*)"],
290
296
  };
291
297
  `;
298
+ /**
299
+ * The `pageMetadata()` helper — one builder for every page's `metadata` export.
300
+ *
301
+ * Exists because Next.js merges metadata SHALLOWLY, per TOP-LEVEL KEY. A page
302
+ * that sets `openGraph: { title, description }` does not extend the layout's
303
+ * openGraph — it REPLACES the whole object, deleting `og:type` and
304
+ * `og:site_name`; the matching `twitter: {}` deletes
305
+ * `card: "summary_large_image"` so a 1200x630 image renders as a small square.
306
+ * Nothing warns: `next build` is happy and the source reads as if it composes.
307
+ * (Reported by `site-control` 2026-07-29, who introduced it while FIXING the
308
+ * `<title>Home</title>` defect in this same file pair and caught it only by
309
+ * re-diffing served HTML.)
310
+ *
311
+ * Two design choices worth not "tidying" away:
312
+ *
313
+ * 1. `title: { absolute: ... }`. The layout's `title.template` reaches CHILD
314
+ * segments only, never app/page.tsx — the exact asymmetry behind the
315
+ * `<title>Home</title>` defect. `absolute` opts out of the template
316
+ * everywhere, so a page built by this helper renders the same title whether
317
+ * it lives at the root or six segments deep. One code path, verified once.
318
+ * The template stays in the layout for pages that don't use the helper.
319
+ * 2. `openGraph.url` is the PAGE path, not the site root. Next resolves it
320
+ * against `metadataBase`. The pre-helper layout hardcoded the site URL, so
321
+ * every page shared one og:url.
322
+ */
323
+ const PAGE_METADATA_MODULE_TEMPLATE = `// Build EVERY page's \`metadata\` export with pageMetadata(). Do not hand-write
324
+ // an \`openGraph\` or \`twitter\` object in a page.
325
+ //
326
+ // WHY: Next.js merges metadata SHALLOWLY, per top-level key. A page that sets
327
+ // \`openGraph: { title, description }\` REPLACES the root layout's whole
328
+ // openGraph object — og:type and og:site_name silently disappear — and a
329
+ // matching \`twitter: { title, description }\` drops
330
+ // \`card: "summary_large_image"\`, so a 1200x630 image renders as a small
331
+ // square. \`next build\` reports nothing; the source reads as if it composes.
332
+ // The only way to see it is to diff the served HTML.
333
+
334
+ import type { Metadata } from "next";
335
+
336
+ /** Brand name, appended to page titles and emitted as og:site_name. */
337
+ export const SITE_NAME = "{{brand_name}}";
338
+
339
+ /**
340
+ * The site-wide OG image, served by app/opengraph-image.tsx.
341
+ *
342
+ * Set explicitly on every page because declaring \`openGraph\` at all SUPPRESSES
343
+ * the inherited opengraph-image file convention. Verified against served HTML:
344
+ * a child page that declares openGraph and omits \`images\` ships NO og:image —
345
+ * so "just leave images out" silently costs every child page its social card.
346
+ * (A colocated opengraph-image.tsx in the SAME segment does survive, which is
347
+ * why the home page looked fine and hid this.)
348
+ */
349
+ export const DEFAULT_OG_IMAGE = "/opengraph-image";
350
+
351
+ export type PageMetadataInput = {
352
+ /**
353
+ * The page-specific part of the title, e.g. "About" or "Frog Species Guide".
354
+ * " | " + SITE_NAME is appended for you — do NOT include the brand here
355
+ * unless you also pass \`brandSuffix: false\`.
356
+ */
357
+ title: string;
358
+ /** Set false when \`title\` already carries the brand (the home page does). */
359
+ brandSuffix?: boolean;
360
+ /** Unique, page-specific. Never reuse the site description. */
361
+ description: string;
362
+ /** Root-relative path, e.g. "/" or "/about". Becomes the canonical URL. */
363
+ path: string;
364
+ /** "article" for posts and news; "website" for everything else. */
365
+ ogType?: "website" | "article";
366
+ /**
367
+ * A page-specific OG/Twitter image. Defaults to the site-wide
368
+ * DEFAULT_OG_IMAGE — do NOT omit it expecting inheritance, there is none
369
+ * (see DEFAULT_OG_IMAGE above).
370
+ *
371
+ * Pass \`null\` in the one case where that is wrong: this segment has its OWN
372
+ * colocated opengraph-image.tsx. An explicit \`images\` value REPLACES the file
373
+ * convention rather than adding to it, so without \`null\` the page would ship
374
+ * the site-wide image and silently ignore the one sitting next to it. (Not a
375
+ * duplicate — a substitution, which is harder to notice.)
376
+ */
377
+ images?: NonNullable<Metadata["openGraph"]>["images"] | null;
378
+ };
379
+
380
+ export function pageMetadata({
381
+ title,
382
+ brandSuffix = true,
383
+ description,
384
+ path,
385
+ ogType = "website",
386
+ images = [DEFAULT_OG_IMAGE],
387
+ }: PageMetadataInput): Metadata {
388
+ const fullTitle = brandSuffix ? \`\${title} | \${SITE_NAME}\` : title;
389
+
390
+ // Shared between openGraph and twitter so the two can never drift apart.
391
+ const shared = {
392
+ title: fullTitle,
393
+ description,
394
+ // \`null\` means "this segment has its own opengraph-image.tsx" — omit the
395
+ // key so the colocated file convention supplies the image instead.
396
+ ...(images === null ? {} : { images }),
397
+ };
398
+
399
+ return {
400
+ // \`absolute\` opts out of the layout's title.template. The template applies
401
+ // to CHILD segments only and never to app/page.tsx, so composing here
402
+ // instead is what makes root and nested pages behave identically.
403
+ title: { absolute: fullTitle },
404
+ description,
405
+ alternates: { canonical: path },
406
+ // Complete object, every time — this is the whole point of the helper.
407
+ openGraph: {
408
+ ...shared,
409
+ // Written as a branch rather than \`type: ogType\` because Next's
410
+ // OpenGraph type is a discriminated union; a widened string does not
411
+ // typecheck.
412
+ ...(ogType === "article" ? { type: "article" as const } : { type: "website" as const }),
413
+ siteName: SITE_NAME,
414
+ // Relative — Next resolves it against metadataBase, so each page gets its
415
+ // OWN og:url rather than the site root.
416
+ url: path,
417
+ },
418
+ twitter: {
419
+ ...shared,
420
+ // Dropping this is the silent half of the shallow-merge trap: the card
421
+ // degrades from a 1200x630 banner to a small square.
422
+ card: "summary_large_image",
423
+ },
424
+ };
425
+ }
426
+ `;
292
427
  const TSCONFIG_TEMPLATE = `{
293
428
  "compilerOptions": {
294
429
  "target": "ES2022",
@@ -314,6 +449,11 @@ const TSCONFIG_TEMPLATE = `{
314
449
  const APP_LAYOUT_TEMPLATE = `// Root layout — SEO baseline wiring per Z2W standing org requirement
315
450
  // 2026-05-30. Every indexable page MUST export its own \`metadata\`; do not
316
451
  // rely on these defaults to fill in per-page values.
452
+ //
453
+ // ⚠️ These \`openGraph\` / \`twitter\` objects are DEFAULTS, not a base to extend.
454
+ // Next.js merges metadata shallowly per top-level key, so any page declaring a
455
+ // partial \`openGraph\` REPLACES the whole object below. Build page metadata with
456
+ // pageMetadata() from lib/seo/page-metadata.ts and this never comes up.
317
457
 
318
458
  import type { Metadata, Viewport } from "next";
319
459
  import { Analytics } from "@/lib/analytics/Analytics";
@@ -335,6 +475,10 @@ export const metadata: Metadata = {
335
475
  title: "{{brand_name}} — {{slug}}",
336
476
  description: "{{description}}",
337
477
  type: "website",
478
+ // Present here as well as in pageMetadata(), so a hand-written page that
479
+ // sets no openGraph at all still inherits og:site_name. Verified missing
480
+ // from the served HTML of such a page before this line existed.
481
+ siteName: "{{brand_name}}",
338
482
  url: siteUrl,
339
483
  },
340
484
  twitter: {
@@ -531,23 +675,28 @@ const APP_PAGE_TEMPLATE = `// Home page — per-page \`metadata\` is mandatory p
531
675
  // the title + description with intentional, page-specific copy (do NOT
532
676
  // inherit the root defaults).
533
677
  //
534
- // ⚠️ The root layout's \`title.template\` does NOT apply to this file, so this
535
- // title must be COMPLETE — brand included. Next.js applies a template to CHILD
536
- // segments only, and app/page.tsx shares the ROOT segment with app/layout.tsx.
537
- // A bare fragment here (the old \`title: "Home"\`) renders literally as
538
- // \`<title>Home</title>\` on the most-linked page on the site, and it fails
539
- // silently: \`next build\` is happy and the metadata source reads as if it
540
- // composes. Pages in CHILD segments DO get the suffix and should not repeat
541
- // the brand. Do not "tidy" this back to a fragment for consistency with them.
542
- // (Found by \`site-control\` dogfooding this scaffold, 2026-07-28.)
678
+ // ⚠️ Build metadata with pageMetadata(). Do NOT hand-write an \`openGraph\` or
679
+ // \`twitter\` object here: Next.js merges metadata SHALLOWLY per top-level key,
680
+ // so a partial \`openGraph\` REPLACES the layout's whole object and silently
681
+ // deletes og:type / og:site_name, while a partial \`twitter\` drops
682
+ // \`card: "summary_large_image"\`. See lib/seo/page-metadata.ts.
683
+ //
684
+ // ⚠️ \`brandSuffix: false\` because this title already carries the brand. It has
685
+ // to: the root layout's \`title.template\` applies to CHILD segments ONLY, and
686
+ // app/page.tsx shares the ROOT segment with app/layout.tsx, so a bare fragment
687
+ // here (the old \`title: "Home"\`) rendered literally as \`<title>Home</title>\` on
688
+ // the most-linked page on the site — silently, with \`next build\` happy. Pages
689
+ // in CHILD segments pass a fragment and let pageMetadata() append the brand.
690
+ // (Both traps found by \`site-control\` dogfooding this scaffold, 2026-07-28/29.)
543
691
 
544
- import type { Metadata } from "next";
692
+ import { pageMetadata } from "@/lib/seo/page-metadata";
545
693
 
546
- export const metadata: Metadata = {
694
+ export const metadata = pageMetadata({
547
695
  title: "{{brand_name}} — {{slug}}",
696
+ brandSuffix: false,
548
697
  description: "{{description}}",
549
- alternates: { canonical: "/" },
550
- };
698
+ path: "/",
699
+ });
551
700
 
552
701
  export default function HomePage() {
553
702
  return (
@@ -682,7 +831,9 @@ Per Z2W standing org requirement 2026-05-30. Run before adding a new page AND be
682
831
  ## Per-page checklist (every new page)
683
832
 
684
833
  - [ ] Page exports its own \`metadata\` — unique title, unique description, canonical URL
685
- - [ ] OG + Twitter Card tags present (set on \`metadata.openGraph\` / \`metadata.twitter\` or inherited intentionally)
834
+ - [ ] Metadata built with \`pageMetadata()\` from \`lib/seo/page-metadata.ts\` — **never hand-write \`openGraph\` or \`twitter\` in a page.** Next.js merges metadata SHALLOWLY per top-level key: a partial \`openGraph: { title, description }\` REPLACES the layout's whole object (deleting \`og:type\` and \`og:site_name\`) and a partial \`twitter\` drops \`card: "summary_large_image"\`, so a 1200×630 image renders as a small square. Nothing warns — \`next build\` passes and the source reads as if it composes. Verify by diffing the served HTML, not the source.
835
+ - [ ] Title composition correct: a page in a CHILD segment passes a fragment (\`title: "About"\`) and lets \`pageMetadata()\` append the brand; \`app/page.tsx\` passes \`brandSuffix: false\` because the root layout's \`title.template\` cannot reach it
836
+ - [ ] OG image reaches the page. \`pageMetadata()\` sets it for you; the trap it closes is that declaring \`openGraph\` at all SUPPRESSES the inherited \`app/opengraph-image.tsx\`, so a child page that declares openGraph without \`images\` ships **no** \`og:image\`. If the segment has its own colocated \`opengraph-image.tsx\`, pass \`images: null\` — an explicit value replaces the file convention rather than adding to it, so the page would otherwise use the site-wide image and silently ignore the one next to it
686
837
  - [ ] Page-specific OG image set if branding differs from default
687
838
  - [ ] Exactly one \`<h1>\` stating the page's primary topic
688
839
  - [ ] Heading hierarchy logical (H1 → H2 → H3, no skipped levels)
@@ -709,7 +860,8 @@ Per Z2W standing org requirement 2026-05-30. Run before adding a new page AND be
709
860
  ## Wired at instantiation by \`@zero2webmaster/starter-kit\`
710
861
 
711
862
  - ✅ \`app/layout.tsx\` — root metadata + JSON-LD Organization
712
- - ✅ \`app/page.tsx\` — per-page metadata template
863
+ - ✅ \`app/page.tsx\` — per-page metadata template, built with \`pageMetadata()\`
864
+ - ✅ \`lib/seo/page-metadata.ts\` — the one metadata builder; closes the shallow-merge trap by emitting a COMPLETE \`openGraph\` + \`twitter\` object on every page
713
865
  - ✅ \`app/sitemap.ts\`
714
866
  - ✅ \`app/robots.ts\` (indexable requires production **and** a real canonical domain — see \`lib/seo/canonical-host.mjs\`)
715
867
  - ⚠️ \`robots.txt\` + \`sitemap.xml\` are PRERENDERED at build time. Until \`NEXT_PUBLIC_SITE_URL\` is your real domain this site is \`Disallow: /\` **by design**; setting the env var requires a **redeploy** to take effect. Verify with \`curl https://your-domain/robots.txt\`.
@@ -806,6 +958,10 @@ export function scaffoldNextjs(inputs, opts) {
806
958
  path: "lib/seo/canonical-host.mjs",
807
959
  content: sub(CANONICAL_HOST_MODULE_TEMPLATE, inputs, opts, spec),
808
960
  },
961
+ {
962
+ path: "lib/seo/page-metadata.ts",
963
+ content: sub(PAGE_METADATA_MODULE_TEMPLATE, inputs, opts, spec),
964
+ },
809
965
  { path: "tsconfig.json", content: sub(TSCONFIG_TEMPLATE, inputs, opts, spec) },
810
966
  { path: "app/layout.tsx", content: sub(APP_LAYOUT_TEMPLATE, inputs, opts, spec) },
811
967
  { path: "app/page.tsx", content: sub(APP_PAGE_TEMPLATE, inputs, opts, spec) },
@@ -863,6 +1019,11 @@ export const NEXTJS_SEO_BASELINE_PATHS = [
863
1019
  // indexability gate in app/robots.ts and the alias redirect in next.config.mjs
864
1020
  // both read it — a scaffold missing it has no indexability gate at all.
865
1021
  "lib/seo/canonical-host.mjs",
1022
+ // The one metadata builder. Part of the baseline because a scaffold without
1023
+ // it has no defence against Next's shallow per-top-level-key metadata merge —
1024
+ // the second page added to the project silently strips og:type / og:site_name
1025
+ // and downgrades the Twitter card.
1026
+ "lib/seo/page-metadata.ts",
866
1027
  "app/opengraph-image.tsx",
867
1028
  // Fathom (SEO baseline item 7) — the three-file pattern; the loader alone
868
1029
  // (data-auto="false" with no RouteTracker) records zero pageviews.
@@ -51,7 +51,24 @@ export interface StandardsResolution {
51
51
  * family — the safe default for anything else with `has_web_ui=true`.
52
52
  */
53
53
  export declare function fathomEnvVarFor(projectType: ProjectType): string;
54
- export declare const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.15";
54
+ export declare const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.16";
55
+ /**
56
+ * The canonical **Capture Learnings** block, emitted VERBATIM into every
57
+ * scaffolded `CLAUDE.md`.
58
+ *
59
+ * Owned by `zero2webmaster/cursor-project-templates`; canonical source is
60
+ * `Resources/CAPTURE_LEARNINGS_BLOCK.md` in the Templates folder this CLI
61
+ * already reads (OP #1). Do NOT paraphrase it here — the paraphrase is the
62
+ * failure mode this block exists to prevent, exactly as it was for the Agent
63
+ * Coordination block, and `capture-learnings.test.ts` byte-diffs the two.
64
+ *
65
+ * Why it must be emitted into CLAUDE.md rather than left in the framework body:
66
+ * the step was canonical from framework v2.13.0 but lived only in `AGENTS_v*.md`,
67
+ * which is NOT loaded into agent context. 25 of 41 Z2W projects were measured
68
+ * missing it on 2026-07-27 — including every project this CLI has scaffolded.
69
+ * Reported as an ACTION by `z2w-observability-bridge` (2026-07-27); closed here.
70
+ */
71
+ export declare const CAPTURE_LEARNINGS_BLOCK_VERSION = "v1.0.0";
55
72
  /**
56
73
  * Resolve which standards apply to `inputs` and render the standards markdown
57
74
  * body suitable for `.replace()`-ing into the `<!-- STANDARDS_BLOCK -->`
@@ -81,3 +98,12 @@ export declare function applyStandardsBlock(claudeMd: string, resolution: Standa
81
98
  * Returns the input verbatim if the marker isn't present (safe on any file).
82
99
  */
83
100
  export declare function applyAgentCoordinationBlock(claudeMd: string, resolution: StandardsResolution): string;
101
+ /**
102
+ * Fill the `<!-- CAPTURE_LEARNINGS_BLOCK -->` marker with the verbatim canonical
103
+ * Capture Learnings block.
104
+ *
105
+ * UNCONDITIONAL, unlike {@link applyAgentCoordinationBlock} — the step applies to
106
+ * every Z2W project regardless of bulletin participation, DB, or web UI. It is a
107
+ * top-level `##` section, so it sits outside `## Standards block`.
108
+ */
109
+ export declare function applyCaptureLearningsBlock(claudeMd: string): string;
package/dist/standards.js CHANGED
@@ -309,7 +309,8 @@ const SENTRY_BODY = `### Sentry runtime-error tracking (customer-facing web app)
309
309
  > 2. **DSN lives in config, NOT an env var.** The DSN is a publishable identifier (not a secret) — hard-code it in the Sentry config files the wizard generates; do NOT introduce a \`NEXT_PUBLIC_SENTRY_DSN\`. The one real secret is \`SENTRY_AUTH_TOKEN\` (build-time source-map upload) — scope it **Production-only** in Vercel and keep it out of the client bundle.
310
310
  > 3. **Feature-flag defaults:** Tracing sample rate 1.0 (100%) at Z2W volume; Session Replay 10% of sessions / 100% of sessions-with-errors; Logs on; \`sendDefaultPii: true\` — with the caveat that a Sentry payload then carries user IP + request headers, so never forward it verbatim into a shared surface (e.g. the bulletin \`## Incidents\` pipe strips to summary + link + timestamp).
311
311
  > 4. **Smoke it, then delete the smoke.** Add a throwaway auth-gated server-throw route (\`/api/boom\` style), confirm the error + replay land in Sentry and the alert email fires, then DELETE the route and the wizard's noisy example page (it's a honeypot that inflates your error count). Ship this cleanup as its own small commit.
312
- > 5. **2025 Sentry-UI quirks that waste time:** issue **alert rules** live at \`/alerts/rules/\` (NOT \`/monitors/alerts/\`); the "Test Notification" button does NOT auto-save the rule (save explicitly or it evaporates); the wizard's example page throws on every load until you remove it.
312
+ > 5. **The wizard writes \`silent: !process.env.CI\`, so a missing \`SENTRY_AUTH_TOKEN\` is SILENT LOCALLY and LOUD ON CI.** Quiet on your machine is by configuration, not by design — \`CI\` is unset locally and Vercel sets \`CI=1\`, where the plugin warns **three times, once per runtime**. So do NOT conclude from a clean local build that source-map upload emits nothing: **grep the deployed build log for \`No auth token provided\`** — a free check that beats a manual dashboard visit. (Reported by \`site-control\` 2026-07-30 after documenting the opposite in five places from a local measurement. The general shape, which is worth more than the Sentry detail: **a fact established under one configuration silently changes meaning under another** — so print or fetch what actually resolved, in the environment that will run it.)
313
+ > 6. **2025 Sentry-UI quirks that waste time:** issue **alert rules** live at \`/alerts/rules/\` (NOT \`/monitors/alerts/\`); the "Test Notification" button does NOT auto-save the rule (save explicitly or it evaporates); the wizard's example page throws on every load until you remove it.
313
314
  >
314
315
  > **When to SKIP (do not wire Sentry):** WordPress sites (error tracking via Z2W Admin Suite Diagnostics + FluentSMTP logs); CLI libraries and protocol repos (no request surface); Cloudflare Workers / node-service / python-service that are API-only (the \`-i nextjs\` wizard doesn't fit — revisit per-runtime later); internal-only admin tools with a single operator who sees errors directly. The rule of thumb: wire it for any public-or-customer-facing Next.js / CF-Pages app that will have real users.
315
316
  >
@@ -325,7 +326,48 @@ const NEON_CAREFUL_BODY = `### Neon-careful (Neon Postgres)
325
326
  // `zero2webmaster/z2w-agent-coordination`'s AGENT_PROTOCOL.md when the embedded
326
327
  // block's mechanics change (drift-detection Signal A greps for this exact token).
327
328
  // When you sync a newer canonical block below, bump this to match its comment.
328
- export const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.15";
329
+ export const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.16";
330
+ /**
331
+ * The canonical **Capture Learnings** block, emitted VERBATIM into every
332
+ * scaffolded `CLAUDE.md`.
333
+ *
334
+ * Owned by `zero2webmaster/cursor-project-templates`; canonical source is
335
+ * `Resources/CAPTURE_LEARNINGS_BLOCK.md` in the Templates folder this CLI
336
+ * already reads (OP #1). Do NOT paraphrase it here — the paraphrase is the
337
+ * failure mode this block exists to prevent, exactly as it was for the Agent
338
+ * Coordination block, and `capture-learnings.test.ts` byte-diffs the two.
339
+ *
340
+ * Why it must be emitted into CLAUDE.md rather than left in the framework body:
341
+ * the step was canonical from framework v2.13.0 but lived only in `AGENTS_v*.md`,
342
+ * which is NOT loaded into agent context. 25 of 41 Z2W projects were measured
343
+ * missing it on 2026-07-27 — including every project this CLI has scaffolded.
344
+ * Reported as an ACTION by `z2w-observability-bridge` (2026-07-27); closed here.
345
+ */
346
+ export const CAPTURE_LEARNINGS_BLOCK_VERSION = "v1.0.0";
347
+ const CAPTURE_LEARNINGS_BODY = `## Capture Learnings (session end)
348
+
349
+ <!-- cursor-project-templates capture-learnings-block ${CAPTURE_LEARNINGS_BLOCK_VERSION} -->
350
+
351
+ *(↓ copy this section, including this heading AND the HTML fingerprint comment above, verbatim into each project's \`CLAUDE.md\` and \`AGENTS.md\`. The fingerprint lets \`grep\` detect drift across projects. Canonical source: \`Resources/CAPTURE_LEARNINGS_BLOCK.md\` in \`zero2webmaster/cursor-project-templates\`.)*
352
+
353
+ **At the end of every session, decide whether anything you learned this session should become a skill — and state the verdict in your recap.** This fires by default, unasked. It is **never** a question you put to the project owner ("want me to make a skill?"); it is a decision you make and report.
354
+
355
+ **The bar is high.** One fix or gotcha that cost more than ~15 minutes, or that was non-obvious enough that the next agent would re-derive it from scratch. Don't capture the obvious or the already-documented.
356
+
357
+ **Route it:**
358
+
359
+ | The learning is… | Where it goes |
360
+ |---|---|
361
+ | one-off, this project only | a \`TROUBLESHOOTING.md\` line — or nothing |
362
+ | recurring, this project only | a directive / this \`CLAUDE.md\` (self-anneal) |
363
+ | recurring **and** portfolio-general | the **Skill Vault** — extend an existing skill before creating a new one |
364
+
365
+ **Report the verdict even when it's negative.** "Nothing worth capturing this session" is a valid and expected outcome, and saying it out loud is the point: a reflex nobody can see is indistinguishable from a reflex nobody ran.
366
+
367
+ **If you notice this step missing from another project, do not just fix that one file.** Two or more projects missing it means the *enrollment* step is the bug, not the rows. File it with \`cursor-project-templates\` (owns the canonical block), \`z2w-starter-kit\` (owns the scaffold/\`init\` path), and \`z2w-agent-coordination\` (owns \`scripts/check-fingerprint-drift.sh\`, the only propagation checker in this ecosystem that has demonstrably worked).
368
+
369
+ Full routing rubric, worked examples, and the Skill Vault's own commit conventions: the **\`capture-learning\`** skill.
370
+ `;
329
371
  /**
330
372
  * The Agent Coordination section, emitted as its own TOP-LEVEL `## Agent
331
373
  * Coordination` section (NOT a `###` standards subsection). The bulk is the
@@ -625,3 +667,51 @@ export function applyAgentCoordinationBlock(claudeMd, resolution) {
625
667
  }
626
668
  return claudeMd.replace(marker, `${section}\n\n---\n\n`);
627
669
  }
670
+ /**
671
+ * Fill the `<!-- CAPTURE_LEARNINGS_BLOCK -->` marker with the verbatim canonical
672
+ * Capture Learnings block.
673
+ *
674
+ * UNCONDITIONAL, unlike {@link applyAgentCoordinationBlock} — the step applies to
675
+ * every Z2W project regardless of bulletin participation, DB, or web UI. It is a
676
+ * top-level `##` section, so it sits outside `## Standards block`.
677
+ */
678
+ export function applyCaptureLearningsBlock(claudeMd) {
679
+ const filled = claudeMd.replace(/<!-- CAPTURE_LEARNINGS_BLOCK -->/g, `${CAPTURE_LEARNINGS_BODY.trimEnd()}\n\n---\n\n`);
680
+ // DEDUPE, and this is why the call happens AFTER the AGENTS body is spliced
681
+ // in: the canonical framework body (AGENTS_v2.17.0+) carries this same block,
682
+ // which would leave the scaffold with TWO copies. Two is a real failure, not
683
+ // cosmetic — the capture-learning skill's own check is
684
+ // `grep -c "capture-learnings-block v1.0.0" CLAUDE.md` expecting exactly 1,
685
+ // so a duplicate reads as drift to every sweep that looks for it.
686
+ //
687
+ // Keep the FIRST occurrence (the marker position, near the session-end
688
+ // material where the canonical source says it belongs) and drop the rest —
689
+ // the later one is buried deep in the "Generic AGENTS" reference, which the
690
+ // scaffolded CLAUDE.md itself labels as framework guidance that the
691
+ // project-specific sections above override.
692
+ const lines = filled.split("\n");
693
+ const heads = [];
694
+ for (let i = 0; i < lines.length; i++) {
695
+ if (/^## Capture Learnings \(session end\)\s*$/.test(lines[i]))
696
+ heads.push(i);
697
+ }
698
+ if (heads.length < 2)
699
+ return filled;
700
+ const drop = new Set();
701
+ for (const head of heads.slice(1)) {
702
+ let end = lines.length;
703
+ for (let i = head + 1; i < lines.length; i++) {
704
+ if (/^## /.test(lines[i])) {
705
+ end = i;
706
+ break;
707
+ }
708
+ }
709
+ // Also swallow a trailing `---` separator + blank lines the block leaves behind.
710
+ while (end > head + 1 && (lines[end - 1].trim() === "" || lines[end - 1].trim() === "---")) {
711
+ end--;
712
+ }
713
+ for (let i = head; i < end; i++)
714
+ drop.add(i);
715
+ }
716
+ return lines.filter((_, i) => !drop.has(i)).join("\n");
717
+ }
package/dist/writer.js CHANGED
@@ -26,7 +26,7 @@ import fsExtra from "fs-extra";
26
26
  import { AGENT_COORDINATION_BLOCK_MARKER, AGENTS_BODY_MARKER, STANDARDS_BLOCK_MARKER, } from "./scaffolders/common.js";
27
27
  import { buildProSeoExtension, proSeoApplies, } from "./scaffolders/pro-seo-extension.js";
28
28
  import { scaffoldByType } from "./scaffolders/index.js";
29
- import { applyAgentCoordinationBlock, applyStandardsBlock, resolveStandards, } from "./standards.js";
29
+ import { applyAgentCoordinationBlock, applyCaptureLearningsBlock, applyStandardsBlock, resolveStandards, } from "./standards.js";
30
30
  import { resolveAgentsTemplate, } from "./templates.js";
31
31
  export class WriterError extends Error {
32
32
  constructor(message) {
@@ -225,6 +225,10 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
225
225
  let claudeContent = applyStandardsBlock(claudeFile.content, resolution);
226
226
  claudeContent = applyAgentCoordinationBlock(claudeContent, resolution);
227
227
  claudeContent = claudeContent.replace(AGENTS_BODY_MARKER, agentsBody);
228
+ // Always-on: applies to every project type, bulletin participant or not.
229
+ // MUST run AFTER the AGENTS body splice — the canonical framework body carries
230
+ // this same block, and this call is what dedupes it down to one.
231
+ claudeContent = applyCaptureLearningsBlock(claudeContent);
228
232
  checkNoUnfilledMarkers(claudeContent, "CLAUDE.md");
229
233
  files[claudeIdx] = { path: claudeFile.path, content: claudeContent };
230
234
  // Append promotions follow-up file if any standard was promoted.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zero2webmaster/starter-kit",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.",
5
5
  "author": {
6
6
  "name": "Dr. Kerry Kriger",