# Alignment Page — youtube-description-optimizer

When this skill produces durable deliverables (research, specs, plans, reports, prototypes, or any document output), build a full-depth HTML alignment page at `alignment/youtube-description-optimizer-{topic}.html`. Use a normalized topic slug derived from the app, feature, research subject, report subject, or output filename.

**Visual rendering tier.** Each alignment page declares a rendering tier:
- `document` (default) — text, tables, approval gates. No charts or interactive elements.
- `visual` — adds inline charts, diagrams, and spatial layouts rendered via self-contained Canvas/SVG. Data is embedded as inline JSON. No external fetches.
- `prototype` — adds functional interactive components (clickable flows, live CSS previews, drag interactions). Prototypes are ephemeral previews, not production code.

The tier is set per skill via `visual_tier` in SKILL.md frontmatter (or detected by the upgrade script). The bundled ALIGNMENT-PAGE.md receives tier-appropriate rendering guidance from the generator.

**Context intake.** This skill declares `context_intake: artifact_only` (Artifact-driven). Work from concrete artifacts, data, logs, or existing instructions by default; ask concise clarification questions only when the available artifacts are missing, contradictory, or unsafe to interpret.

**Alignment lifecycle.** Alignment pages have three lifecycle states. `review` is the draft/pre-approval page: it contains the complete deliverable preview, evidence, required inline gate questions, section feedback controls, local section-feedback YAML only after a section feedback choice is selected, and one bottom `Compile Responses` control. `confirmed` is the post-approval page after the agent has consumed final compiled response YAML, made any approved user-requested edits, and written or updated the approved canonical artifacts. A confirmed page is finished and current for the completed alignment cycle, but it remains amendable when later research changes or extends the conclusions. `amended` is a future revision of a confirmed page: archive the previous confirmed page first, mark what changed, preserve the prior approval record, and highlight the new evidence, decisions, or scope that changed the earlier conclusion.

**Central alignment index.** When a research-producing skill writes or updates an HTML alignment page, also maintain the repository's central alignment index. Look for `alignment/index.html` at the repository root; if the target repo documents a different central alignment-index path, use that path and report it. If the index does not exist, create it as a self-contained HTML page that works from `file://`, links to every active `alignment/*.html` page except itself, and includes the newly written page. Every index entry must include the page's alignment date in a muted meta span after the link, formatted `YYYY-MM-DD`, for example `<a href="page.html">Title</a> <span class="meta">2026-06-09</span>`. The alignment date is the review or confirmed date written inside the page itself; new pages use today's date. If the index exists, update it instead of blindly appending: preserve valid existing entries, metadata, and entry dates; remove duplicate entries for the same page path; keep links repo-relative; and include the new or updated page. When updating an existing index, add a date only to entries that are missing one, deriving it from the page's internal alignment date, or from file history when the page has no internal date. If a `new` marker is used, combine it with the date as `<span class="meta">new · YYYY-MM-DD</span>`, and remove stale `new` markers from entries that are no longer the latest addition.

**Alignment index categories.** The index groups alignment pages into five categories. Each alignment page belongs to exactly one category. When writing or updating the index, assign each page to a category and render the index grouped by category in the order listed below.

1. **Research** (`research`) — market research, competitive analysis, investigative reports. Skill prefixes: `devtool-positioning`, `devtool-adoption`, `devtool-monetization`, `devtool-user-map`, `devtool-workflow`, `devtool-dx-journey`, `devtool-integration-map`, `deep-research`, `repo-glossary`.
2. **Product Design & Spec** (`product-design`) — product scoping, idea briefs, design plans, specifications. Skill prefixes: `idea-scope-brief`, `fork-idea-branch`, `animation-design-planner`, `skills-showcase`, `skills-inventory`.
3. **Utility & Maintenance** (`utility`) — diagnostics, triage, incident investigation, infrastructure maintenance. Skill prefixes: `investigate`, `session-triage`, `prompt-history-backfill`.
4. **QA & Meta-Skill Improvement** (`qa-meta`) — code review, benchmarking, skill building/fixing, expert review. Skill prefixes: `expert-review`, `benchmark`, `targeted-skill-builder`, `devtool-docs-audit`.
5. **Ops & Session Analysis** (`ops-analysis`) — operational intelligence, session history analysis, cost/token/workflow analysis. Skill prefixes: `analyze-sessions`, `canonical-workflow`, `run-batch`.

**Category assignment rule.** Match the skill name that produced the alignment page against the prefix lists above; use the first matching category. When no prefix matches, read the page title and summary to assign the best-fit category. When the category is ambiguous, default to **Research**.

**Visual tier badge.** When writing or updating the alignment index, display a visual tier badge next to each linked page: `[doc]` for document tier, `[visual]` for visual tier (pages with charts/diagrams), `[proto]` for prototype tier (interactive pages). Read the tier from the alignment page's `data-visual-tier` attribute on the `<html>` element. When the attribute is missing, default to `[doc]`.

**Category data attribute.** Set `data-alignment-category` on the `<html>` element of each alignment page with the category slug (`research`, `product-design`, `utility`, `qa-meta`, or `ops-analysis`). Also set `data-visual-tier` on the `<html>` element with the rendering tier (`document`, `visual`, or `prototype`). When an existing alignment page lacks the attribute, infer the category from the skill-name prefix or page content and add it on the next update. The index should read this attribute when available; when it is missing, apply the prefix-matching rule to assign a category for display.

**Category and product-path grouping.** In product-line or product-path repositories, identify product from `research/.progress.yaml` `product_paths[]`, active `research/{slug}/` or `specs/{slug}/` scopes, page metadata, page title, or the alignment page path. Group index entries by category first, then by product/product path within each category, with the repo's existing secondary sort preserved when clear. In flat repositories, group by category, then preserve the existing index organization within each category or use a clear newest-first or title order when creating a new index.

**Research quality contract.** For research-producing outputs, do not synthesize research findings, recommendations, candidate rankings, or working packets until the user approves the research scope from the `review` alignment page's final compiled response YAML. Before scope approval, do only minimal discovery needed to propose the research scope, source plan, assumptions, output paths, and approval questions; label any observed files or source availability as scope evidence, not findings. After scope approval, perform the synthesized research and separate and label `claims` (what the report concludes), `evidence` (source, repo artifact or file path, quote or observation, date, and confidence), `inference` (why that evidence supports the claim), `assumptions` (what remains unproven), and `decision impact` (what the user should approve, reject, or correct). Do not collapse evidence and inference into unsupported summary prose.

**Revision hygiene for research artifacts.** When feedback asks to remove, replace, or reduce emphasis on content, update the page and any proposed artifacts toward the requested final state. Keep corrected or rejected claims out of findings, recommendations, synthesis narratives, and forward-looking instructions. If provenance is needed, put it in a concise revision note or archive record rather than repeating it in the canonical narrative.

**Embed prohibition.** Do not use `<object>`, `<iframe>`, `<embed>`, or "open working packet" / "view full document" links as the primary rendering of any proposed deliverable, evidence matrix, interview log, or manifest entry. The alignment page HTML must contain the rendered content directly. Embedded or linked external documents are permitted only as supplemental references alongside the fully rendered content already present in the page. **Exception:** Self-contained inline `<canvas>` and `<svg>` elements are permitted for charts and diagrams within the same HTML file.

**Visual accessibility contract.** Every chart or diagram in a `visual` or `prototype` tier alignment page must include: (1) a `<table>` or text fallback rendering the same data, (2) an `aria-label` attribute on every `<canvas>` and `<svg>` element describing the chart type and data summary, and (3) a "View as table" toggle button that swaps between the chart and its table fallback. The toggle must default to showing the chart, with the table hidden via a `hidden` attribute that is toggled by the button.

**Inline chart contract.** Visual and prototype tier pages must inline all chart rendering code as a `<script>` block within the HTML file. No external CDN references, relative file imports, or `<script src="...">` tags for chart libraries. Use the alignment chart snippet library (`scripts/alignment-chart-snippets.js`) as the reference implementation — copy the needed functions directly into the page's `<script>` block. Charts must read CSS variables (`--chart-1` through `--chart-8`) for colors and adapt to the dark-mode palette.

**No context loss rule.** The alignment page must contain the complete content of every proposed markdown deliverable -- every section, every finding, every detail, every list item -- plus the decision-relevant substance from search logs, interview logs, source notes, repo scans, and approval notes. If a fact, source, caveat, uncertainty, alternative, rejected or lower-confidence finding, or decision rationale appears in a proposed deliverable or research log, it must either appear in the HTML page or be explicitly linked from the exact section that depends on it. The page is a thorough interactive review document, not a summary. Render the full deliverable content in clean, readable HTML with appropriate hierarchy, styling, and navigation. If the skill writes multiple scoped deliverables in one run, build one alignment page that contains all deliverables with anchor-linked navigation. Durable tracker artifacts, such as `research/assumption-tracker.md`, remain canonical markdown outputs but must also be fully rendered into the alignment page before approval.

**Page layout contract.** After the page title and short summary, include a top-of-page "Table of Contents" section with anchor links to the major review sections and the bottom compile section. Keep the Table of Contents in normal document flow. Do not use a sidebar, side rail, drawer, split-shell layout, or sticky navigation for the Table of Contents unless the user explicitly asks for that layout. Do not place compile, copy, feedback, or answer controls in a sticky or fixed bottom banner/footer. Bottom compile controls must appear as ordinary content in a bottom compile section, so they scroll with the page and do not cover content at high zoom.

**Research translation requirements.** For research outputs, the HTML page must include an evidence matrix, confidence/assumption register, alternatives considered, rejected or lower-confidence findings, source coverage gaps, and downstream implications. The evidence matrix must map each major claim to source or repo evidence, inference, confidence, assumption status, and decision impact. The confidence/assumption register must show which conclusions are evidence-backed, which are provisional, and what evidence would change them.

**Dark-mode styling.** Use a dark color scheme by default. Base CSS variables: `--bg: #0d1117; --surface: #161b22; --border: #30363d; --text: #c9d1d9; --text-muted: #8b949e; --accent: #58a6ff; --green: #3fb950; --red: #f85149; --orange: #d29922; --purple: #bc8cff;`. Data visualization palette (for `visual` and `prototype` tier pages): `--chart-1: #58a6ff; --chart-2: #3fb950; --chart-3: #d29922; --chart-4: #bc8cff; --chart-5: #f85149; --chart-6: #79c0ff; --chart-7: #f0883e; --chart-8: #a5d6ff;`. Apply `background: var(--bg); color: var(--text);` on body. Use `--surface` for cards, the top Table of Contents, and table headers. Use `--border` for all borders. Use `--purple` for question blocks and gate headings. Use `--accent` for links and section headings. Keep headings `color: #fff` or `var(--accent)` for hierarchy. Question block backgrounds should use `#1c2333`.

**Responsive layout.** Include `<meta name="viewport" content="width=device-width, initial-scale=1">` in the head. Use at most two breakpoints: `@media (max-width: 860px)` for tablet and `@media (max-width: 560px)` for phone. Wrap every `<table>` in a `<div style="overflow-x: auto">` so tables scroll horizontally instead of breaking layout. All interactive elements (buttons, radio labels, feedback controls) must have a minimum touch target of `44px` height and at least `10px 16px` padding. Use `rem` for font sizes and respect the user's base font size — do not set a fixed `font-size` on `html` or `body`. Flex containers that place a heading beside controls (`display: flex; justify-content: space-between`) must include `flex-wrap: wrap; gap: 8px` so controls drop below the heading on narrow screens. Grid layouts must use `minmax(min(210px, 100%), 1fr)` instead of bare `minmax(210px, 1fr)` to prevent horizontal overflow when the viewport is narrower than the minimum. Set `max-width: 100%; overflow-wrap: break-word;` on `main` and any fixed-width container so no element forces a horizontal scrollbar at any zoom level.

**Alignment gates.** In `review` pages, treat gates as explicit review sections inside the HTML page. A gate blocks finalization only while the page is in `review`, until its required inline questions are answered and compiled into YAML. Include every gate that applies to the skill output, and include these gate types whenever relevant: evidence coverage, assumptions/confidence, scope/non-goals, candidate/verdict decisions, artifact destination, proposed file changes, coverage checkpoint, and post-approval route. In `confirmed` pages, preserve the gate decisions as read-only approval records instead of active approval controls.

**Output gate semantics and de-duplication.** The `artifact destination` gate approves the durable or review artifact location, such as the alignment page, working packet, report, spec, plan, prototype, or document path. The `proposed file changes` gate approves downstream mutation scope, timing, and the allowed file set after review. Keep these as separate approval concepts. If both gate concepts ask only the same path-destination question, render one combined visual section such as `Artifact Destination & Proposed File Changes` instead of duplicating path-only sections. If the decisions differ, render separate gates. Do not duplicate YAML entries solely because one visual section title names both concepts: emit separate YAML items only when the page asked separate decisions, and keep each item's `gate_type` equal to the decision it controls (`artifact destination` or `proposed file changes`).

**Research completeness gate.** For research outputs, include a research completeness gate with inline questions asking whether the evidence is sufficient for the recommendation, which claims need more support, and whether missing context could change the recommendation. Place these questions directly under the evidence matrix or recommendation section they govern.

**Source coverage expectations.** For web research, organize source coverage by category rather than citation list alone; use categories such as competitors, pricing, user sentiment, positioning, integrations, and recent activity when relevant to the topic. For repo or codebase research, include file/path evidence and clearly distinguish observed code facts from inferred product, workflow, or user conclusions.

**Report-only research gates.** For report-only or pre-approval research skills, the first `review` alignment page must explicitly contain proposed research scope, source plan, assumptions/confidence, recommended output path, proposed file changes, and approval gates before synthesized research begins and before any working packet, canonical research, spec, or task file is created or updated.

**Staged research workflow.** Heavy report-first research uses a scope-first three-stage approval workflow. Stage 1 is minimal scope discovery only: inspect enough repository, user, and source context to propose research scope, source plan, assumptions, output paths, and approval questions. Build the `review` alignment page before synthesized research. The page must render the proposed scope, available source categories, known context, assumptions/confidence, proposed working-packet and canonical output paths, research-scope approval gates, and a `Stage 2 Preview / Expected Review Format` section that shows the future Stage 2 review shape before research starts. Stop for final compiled response YAML approval of the research scope. Do not synthesize findings, rank candidates, recommend a path, or create working packets, canonical research, spec, or task files in Stage 1. Stage 2 starts only after final compiled response YAML approves the research scope with no unresolved `needs-clarification`, unresolved `down` feedback, or other unresolved negative feedback. Perform the synthesized research, run required source/code checks, and write only a non-canonical working packet. Flat mode uses `research/_working/preliminary-youtube-description-optimizer-research.md`; product-path mode uses `research/{slug}/_working/preliminary-youtube-description-optimizer-research.md`. Existing raw evidence or search-log outputs may remain as supporting evidence when the skill contract already requires them, but synthesized deliverables stay in the working packet. Update the same `review` alignment page so it renders the complete working-packet substance as structured HTML review UI: purpose-built sections, tables, matrices, gates, cards, and tier-appropriate charts or diagrams that preserve every packet section, finding, caveat, and decision detail without summary loss. Raw Markdown packet text may appear only as a supplemental source view after the rendered review UI; do not make a `Full Preliminary Packet` or `Full Working Packet` raw Markdown dump, giant `<pre><code>` block, link-only view, or source-only view the primary review surface. Include the evidence matrix, assumptions/confidence register, source coverage gaps, proposed canonical file changes, and artifact approval gates. Partial compiled responses revise the working packet and review page, then remain in Stage 2. Stage 3 consumes final compiled response YAML for artifact approval only when it has `approval_status: ready-for-agent-review` and no unresolved `needs-clarification`, unresolved `down` feedback, or other unresolved negative feedback. Apply approved edits first, archive the working packet to `docs/history/archive/YYYY-MM-DD/HHMMSS/<original-working-path>`, remove the active working packet, write the approved canonical artifacts to the unchanged output paths, and convert the page to `confirmed` with the approval record preserved.

**Stage 2 review-page template.** Stage 1 scope-review pages must include a `Stage 2 Preview / Expected Review Format` section that previews the exact section sequence, table shapes, evidence treatment, visual density, and approval gates the user will see after research; make it specific enough for the user to flag preferred content formats, grouping, labels, visuals, and evidence density before the agent does heavy research. After scope approval and research, the Stage 2 review page must include these sections as structured HTML, not as raw Markdown dumps: `Research Scope Approved` status block with approved scope, source plan, output paths, and unresolved caveats; `Executive Findings` or a skill-specific top-findings section with confidence labels; `Evidence Matrix` mapping claim, evidence/source/path, inference, confidence, assumptions, and decision impact; `Working Packet Review` with the complete working-packet substance rendered as purpose-built HTML sections, lists, tables, matrices, cards, and tier-appropriate charts or diagrams; `Alternatives / Rejected or Lower-Confidence Findings`; `Source Coverage & Gaps`; `Assumptions / Confidence Register`; `Proposed Canonical Artifacts & File Changes`; a required `User Format Preferences` gate asking whether the layout, tables, grouping, visuals, labels, and evidence density match expectations; and a required `Final Artifact Approval` gate for Stage 3 readiness. Raw Markdown packet text, search logs, or source notes may appear only as supplemental source views after the rendered review UI and never replace the Stage 2 review sections.

**Glossary Additions gate.** When this research introduces domain-specific terms, acronyms, or concept definitions that a reader outside the project would not know, include a `## Glossary Additions` section in the alignment page. Render a table of proposed terms with columns: Term, Definition, Source (`youtube-description-optimizer`), Category (business/tooling/workflow/technical/domain), and per-term Approve/Edit/Reject/Flag radio controls. Only user-approved terms are appended to the target glossary (`research/glossary.md` or `research/{slug}/glossary.md` for scoped paths) during the confirmed-page write step. When the skill operates in a product-path scope, ask whether each term belongs in the parent or scoped glossary; default to the scoped glossary.

**Required inline questions.** In `review` pages, each gate must contain at least one required inline question placed directly under the content it governs, inside a visually distinct question block. Each question must use radio-button inputs and include two standing options after the skill-generated choices: "Other / None of the above" backed by a multi-line text box for free-form input, and "Need clarification" backed by an optional notes box where the user can explain what is unclear. When any radio option other than "Other" or "Need clarification" is selected, show an optional "Additional notes" text box beneath it so the user can qualify their choice. Generate questions based on what genuinely needs user input -- do not add filler questions. Do not create a separate bottom "Decisions & Clarifications" section. Confirmed pages must not keep these as required input controls; render the answered decisions as read-only records.

**Section feedback controls.** Every major section of the page (each deliverable section, evidence matrix, confidence register, gate, and any anchor-linked top-level heading) carries a lightweight section-feedback control near its heading: three mutually exclusive choices -- "emphasize" (add more weight to this section or to the point named in the notes), thumbs down (reject or flag a concern), and "clarification needed". The section feedback textarea, local compile/copy controls, and local read-only YAML output are hidden by default. Selecting any one feedback choice reveals a multi-line section-feedback textarea plus local "Compile Feedback YAML", "Copy YAML", and read-only YAML controls placed directly under or beside that section's emphasize/down/clarify controls; deselecting the active choice hides the textarea, local compile/copy controls, and local read-only YAML output again and omits that section from compiled responses. This textarea is separate from required gate-question text inputs: even when the same section has gate questions with their own text boxes, selecting emphasize/down/clarify must still reveal the section-feedback textarea near the feedback controls. Use `--green` for active "emphasize", `--red` for the active thumbs-down, and `--orange` for active "clarification needed", with muted/inactive states otherwise. These controls are optional for final approval and do not replace required gate questions. They also contribute `section_feedback` entries to the unified response payload so the user can send emphasis requests, concerns, or clarification requests before answering every required gate question. When a section contains nested subsections (h3 or deeper), duplicate the section-feedback control at the bottom of the section, just before the closing `</section>` tag. The bottom copy mirrors the top copy — same `data-section`, same id with a `-bottom` suffix, same button set. Sections without nested subsections keep only the top control. Pair top and bottom controls by matching `data-section` attribute. When a feedback button is clicked on one copy, mirror the active state, `has-feedback` class, and `dataset.feedback` value to the paired copy. Textarea content should sync on compile — whichever textarea has content takes precedence (prefer the one the user last typed in). Both copies' local compile/copy buttons produce the same YAML. Use the top copy's `id` (without `-bottom`) as the canonical feedback id for YAML output.

**Section feedback YAML contract.** Provide local section-feedback YAML only under each selected section-feedback textarea. When a section-feedback control is selected, show local "Compile Feedback YAML" and "Copy YAML" controls plus a read-only YAML textarea directly under that section's feedback textarea; when the control is deselected, hide those local controls and output again. The local feedback compile generates YAML with `alignment_page: alignment/youtube-description-optimizer-{topic}.html`, `feedback_status: revision-request`, `approval_status: not-approved`, `unanswered_required_questions`, and a `section_feedback` list containing the single selected section-feedback entry for that local control. Enable local feedback compile controls as soon as that section-feedback control is set, even if required inline gate questions are unanswered. Populate `alignment_page` from the known repo-relative output path used to write the HTML page, not from the page title, browser URL, window location, or any display label. Each feedback entry uses the shape `section`, `feedback` (`emphasize`, `down`, or `needs-clarification`), optional `notes` from that section's feedback textarea, and `requested_agent_action` (`add-weight-to-section`, `investigate-and-revise`, or `clarify-before-approval`). For `emphasize` feedback, the YAML must make clear that the agent should add more weight, prominence, evidence, detail, or recommendation emphasis to that section or to the specific point named in the notes; this is a revision request, not approval of the section as-is. For `down` and `needs-clarification` feedback, the YAML must make clear that the agent should evaluate the feedback, investigate further when needed, and contextually amend the HTML alignment page before asking again for final approval responses. Automatically attempt to copy local feedback YAML to the clipboard, display local copy status, display it in the matching read-only textarea, and provide a "Copy YAML" button with the same retry and fallback behavior as response YAML.

**Response YAML contract.** In `review` pages, at the bottom of the page, include an ordinary in-flow compile section with a single "Compile Responses" button. The bottom compile section must not be sticky, fixed, floating, or styled as a persistent banner. "Compile Responses" aggregates all answered inline gate questions throughout the page, including free-text notes, plus every selected section-feedback entry. Enable it as soon as at least one gate question has an answer or at least one section-feedback control is selected; do not require every required gate question to be answered before compiling partial responses. If clicked with no answered gates and no selected section feedback, show a response status that asks the user to answer a gate question or select section feedback. The compiled YAML is a mixed response payload with `alignment_page: alignment/youtube-description-optimizer-{topic}.html`, `response_status` (`partial` or `complete`), `approval_status` (`not-approved` or `ready-for-agent-review`), `required_gate_status` (`incomplete` or `complete`), and `unanswered_required_questions`. It may include a `gate_answers` list where each answered gate item preserves the stable gate-answer shape: `section`, `gate_type`, `status` (`answered`, `other`, or `needs-clarification`), `answer`, optional `notes`, and optional `target_artifact` or `target_path` when the gate controls file output. It may also include a `section_feedback` list using the section-feedback shape from the section feedback YAML contract. Set `approval_status: ready-for-agent-review` only when every required gate is answered and there are no unresolved `down`, unresolved `needs-clarification`, or other unresolved negative feedback items; otherwise set `approval_status: not-approved` and keep the response in review. Populate `alignment_page` from the known repo-relative output path used to write the HTML page, not from the page title, browser URL, window location, or any display label. After successful compilation, automatically attempt to copy the YAML to the clipboard with the Clipboard API, display copy status, and display the YAML in a read-only textarea with an explicit "Copy YAML" button. The copy button must retry clipboard copy when supported and fall back to selecting the textarea contents when clipboard access is unavailable or blocked.

**Confirmed page contract.** After final approval has been applied, convert the active alignment page from `review` to `confirmed`. Include a visible status block with `alignment_status: confirmed`, confirmation date, confirmed artifact paths, approval source summary, and explicit finished but amendable language: the page is current for the completed alignment cycle, and later research can amend it only by archiving the prior confirmed page and highlighting the amendment. Remove required gate-question controls, section feedback input controls, local compile/copy controls, local read-only YAML outputs, the final "Compile Responses" button, response counters, disabled approval buttons, and approval-blocking language. Preserve the full research and approval record: answered decisions, user requests, evidence matrix, assumptions/confidence register, source gaps, proposed file changes, final compiled response YAML or faithful approval summary, and what changed during confirmation. Keep research caveats visible; `confirmed` means approved/current, not immutable or permanently true. **Reconcile before confirming.** Before marking a page `confirmed`, reconcile every displayed gate decision against the final compiled response YAML and the written canonical artifact. The read-only approval record must show the *selected* answer. When a gate answer used `other`/freeform, render the user's freeform decision as the read-only gate decision and **remove the superseded generated options** — do not leave the original multi-option control or its non-selected options visible. **Post-confirmation self-check (agent-run, before handoff).** Before reporting completion, verify on the confirmed page that: it has `data-alignment-status="confirmed"`; no active gate inputs/textareas, `Compile Responses` button, response counters, `requiredGateNames`, section feedback controls, local compile/copy/YAML controls, disabled approval buttons, or approval-blocking language remain; every compiled gate answer appears as a read-only approval record matching the final YAML; and any `other`/freeform selection is reflected in both the canonical artifact and the confirmed page.

**Pre-approval stop.** While an alignment page is in `review`, the next action is review of the HTML alignment page, not downstream routing. Ask the user to review the page and provide either local section-feedback YAML for one section or bottom compiled response YAML for gate answers and/or selected section feedback. Do not require the user to answer every gate before sending emphasis requests, negative feedback, clarification needs, or other partial responses. When compiled response YAML is partial or has `approval_status: not-approved`, treat it as a revision request: evaluate the feedback, investigate further when needed, archive and amend the HTML page contextually, highlight the changes, and ask again for review. Do not include `Recommended next skill`, `Recommended next command`, or downstream routing language until after final compiled response YAML with `approval_status: ready-for-agent-review` has been provided and the approved artifacts have been written or updated.

**After approval handling.** When final compiled response YAML with `approval_status: ready-for-agent-review` is provided, inspect it before confirming the page. If it contains approvals plus user-requested edits, first update the page, research, and proposed canonical artifacts to satisfy the request; then write or update the approved canonical artifacts and confirm the page. As part of confirming, reconcile each gate decision against the final YAML and run the post-confirmation self-check from the Confirmed page contract. If it contains `needs-clarification`, unresolved `down` feedback, or any unresolved negative feedback, revise the page and return it to `review` instead of marking it `confirmed`. Before replacing any existing alignment page, archive it to `docs/history/archive/YYYY-MM-DD/HHMMSS/alignment/youtube-description-optimizer-{topic}.html`. Future amendments to confirmed pages follow the same archive-first rule and must show what changed from the prior confirmed record.

**Diff highlighting on updates.** When the agent updates an existing alignment page after receiving feedback, compiled answers, confirmation edits, or later amendment evidence, the rendered HTML must visibly indicate what changed since the previous version. Highlight changed sections or blocks in-place with a `Changed`/`Updated` badge, distinct border or background, `<ins>`/`<del>` markup, or a side-by-side before/after comparison when that is clearer. A top-level change summary is useful but not sufficient by itself unless the changed content is also visibly marked where the reader reviews it. Remove or refresh stale change markers on later updates so the highlights describe the current revision only.

**Archiving.** Before replacing an existing alignment page, archive it to `docs/history/archive/YYYY-MM-DD/HHMMSS/alignment/youtube-description-optimizer-{topic}.html`.

**Brief Me (text-to-speech).** Every alignment page must include a `<script src="../scripts/alignment-tts-kokoro.js"></script>` tag before `</body>`. The script adds a "Brief Me" button that reads the page aloud section-by-section using Kokoro TTS (an 82M-parameter model running client-side via WebGPU/WASM from `kokoro-js`). The transport bar includes play/pause/stop/skip controls, a voice selector (persisted in localStorage), and speed selection. On first click the voice model downloads (~92MB quantized on WASM; ~326MB fp32 on WebGPU). Weights persist between visits via Cache API origin storage, and this works on `file://` origins in Chrome — including `file://wsl.localhost` UNC paths (verified 2026-06-09 with an instrumented probe in Windows Chrome: `caches` is available, entries survive reloads and browser restarts, and Chrome shares a single `file://` origin across all local pages, so one download serves every alignment page). Repeat visits pay model initialization only, not re-download. If `caches` is undefined (non-Chromium or locked-down browsers), the model re-downloads each visit; serving pages from a local HTTP origin (e.g. `node scripts/serve-alignment.mjs` in the repo root, then `http://localhost:8907/alignment/<page>.html`) guarantees caching there — note `http://localhost` is a separate origin from `file://`, so the first localhost visit downloads once even when the `file://` cache is already warm. After the first successful load on a machine, the script preloads the model during browser idle time on later page loads (gated by a `tts-kokoro-used` localStorage flag, so users who never click pay nothing). Text is prepared for speech before synthesis: block boundaries (headings, paragraphs, list items, table cells) get sentence punctuation so the model does not read them as run-ons, and speech-hostile symbols are normalized (`~92MB` reads as "approximately 92MB", `v0.3` as "version 0.3", em-dashes as comma pauses, `e.g.`/`i.e.`/`vs.` expanded). Synthesis is pipelined with small chunks: the first audio chunk is kept short (~250 chars) for fast time-to-first-audio, later chunks stay small (~300 chars, cut at sentence or clause boundaries) with up to two chunks synthesizing ahead during playback, and the next section's opening chunk is prefetched while the current section's last chunk plays, so chunk and section boundaries are gapless. If Kokoro fails to load (old browser, network error), it falls back to the Web Speech API automatically. It skips gate controls, compile UI, feedback textareas, and stat grids. Charts and tables use narrative summaries instead of raw data: containers with a `data-tts-narrative` attribute have the narrative read aloud; containers without the attribute are silently skipped. To inject TTS into existing pages, run `node scripts/inject-tts.mjs` (idempotent). Use `--force` to replace the existing TTS block with an updated version. Do not inline the TTS script; always use the `src` tag. Do not use `type="module"` — module scripts are blocked by CORS on `file://` URLs. Narration follows along visually: the blocks currently being read (paragraphs, list items, table rows, headings, chart narratives) receive a `.tts-active-chunk` highlight at ~1–2-sentence chunk granularity, and the page auto-scrolls to keep them centered (instantly rather than smoothly under `prefers-reduced-motion: reduce`), while the active section keeps a lightened outline frame. The Web Speech fallback stays section-level — outline plus section-start scroll, no per-chunk highlight.

**TTS narrative contract.** Every `.chart-container` and `.table-wrap` element should carry a `data-tts-narrative` attribute with a 1-3 sentence human-readable summary of what the chart or table shows. Chart functions in `scripts/alignment-chart-snippets.js` auto-generate a baseline narrative from their data; author-provided `data-tts-narrative` attributes take precedence. When authoring alignment pages manually, add `data-tts-narrative` to chart containers and table wrappers so that Brief Me reads a meaningful summary instead of skipping the element.

**Browser open.** After writing the resulting HTML page, attempt to open it from the repository root with this ordered fallback, replacing `alignment/youtube-description-optimizer-{topic}.html` with the actual page path when needed. First, if `scripts/open-html-page.mjs` exists, run `node scripts/open-html-page.mjs alignment/youtube-description-optimizer-{topic}.html --browser auto`. If the helper is missing or cannot open the page and the environment is WSL (`grep -qi microsoft /proc/version`) with `/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.exe` available, open a browser-friendly file URI through PowerShell: build `file://wsl.localhost/${WSL_DISTRO_NAME:-Ubuntu}/<absolute-linux-path>` from the HTML page's absolute path and run PowerShell `Start-Process '<file-uri>'`. Try `xdg-open <absolute-linux-path>` only after the helper path and WSL PowerShell bridge are unavailable or blocked. Report the final status (`focused`, `opened`, `fallback-opened`, `blocked`, or `failed`) in the handoff, and include the absolute path when the status is `blocked` or `failed`. Continue when opening is `blocked` if the files were written and verified correctly; a blocked browser-open attempt does not make the skill fail.
