--- name: report-writer description: Generates a standalone HTML report summarizing changes, findings, debug investigations, or architectural decisions, and opens it in the browser. Use after completing work on a ticket, investigation, or debug session. user-invocable: true argument-hint: "[optional: ticket-id or report-name]" --- # Report generator Generate a standalone HTML report summarizing the work you just completed: bug fixes, features, refactoring, investigations, or debug sessions. The report opens in the default browser. ## When to use - After completing work on a ticket - After a debug/investigation session - To document architectural decisions - To summarize a refactoring effort - Whenever you want a record of what was done and why ## Quick start ``` /report-writer PROJ-1234 /report-writer auth-migration-investigation /report-writer # auto-names from branch ``` ## Report types ### Bug fix report Sections to include: 1. **Problem statement** - What was broken, who was affected, symptoms 2. **Root cause analysis** - Why it happened, the chain of events 3. **Investigation timeline** - Steps taken to diagnose 4. **Solution** - What was changed and why this approach 5. **Files changed** - List of modified files with brief descriptions 6. **Testing** - How the fix was verified 7. **Impact assessment** - Risk level, rollback plan, monitoring ### Feature report Sections to include: 1. **Overview** - What the feature does, business context 2. **Architecture** - How it fits into the system, design decisions 3. **Implementation details** - Key components, patterns used 4. **Files changed** - New and modified files 5. **Configuration** - Any new config, env vars, feature flags 6. **Testing** - Test coverage, edge cases considered 7. **Deployment notes** - Migration steps, dependencies, rollout plan ### Refactoring report Sections to include: 1. **Motivation** - Why the refactoring was needed 2. **Scope** - What was refactored, what was left untouched 3. **Approach** - Strategy used (e.g., strangler fig, parallel implementation) 4. **Before/After** - Key structural comparisons 5. **Files changed** - Renamed, moved, deleted, created 6. **Risk assessment** - What could break, how it was mitigated 7. **Follow-up** - Remaining tech debt, future improvements ### Investigation / debug report Sections to include: 1. **Objective** - What was being investigated 2. **Hypothesis** - Initial theories 3. **Investigation timeline** - Chronological steps and findings 4. **Evidence** - Logs, metrics, code snippets 5. **Conclusions** - What was found 6. **Recommendations** - Suggested actions 7. **Open questions** - Unresolved items ### Data explorer / interactive dashboard report Use this when the report is data, not a narrative: a CSV export, a compliance audit, an error-frequency dump. The output is a single standalone HTML file that lets the reader filter, slice, chart, and export the dataset. Pick it over a narrative report when the reader is going to do `awk`, `grep`, or pivot-table work. #### Default path In most cases use the generic files in this skill directly. You do not need to write new HTML or JS: - **[data-explorer-template.html](references/data-explorer-template.html)** - domain-agnostic template with `{{TOKEN}}` placeholders (filter builder, Chart.js charts, dynamic stat cards, sortable records table, CSV export, all dark-themed). - **[data-explorer-generator.py](references/data-explorer-generator.py)** - ~60-line script that fills the template: ```bash python references/data-explorer-generator.py --csv data.csv --out report.html --config report_config.json ``` The config JSON declares title, requirements HTML, default filters, charts, stat cards, search fields, multi-valued columns, and a fixed value-to-color map. If the dataset has quirks (synthetic derived fields, custom reason categorization, bespoke charts), copy `data-explorer-template.html` and edit the JS inline. #### Page layout (top to bottom) 1. **Header** - title, source filename, generation timestamp, total record count. 2. **What this report measures** - three collapsible `
` blocks: (a) every check the dataset encodes, (b) requirements we deliberately cannot measure and why, (c) checks the upstream system runs but does not persist. The reader needs to know what is and is not in the data before slicing it. This is the biggest difference from narrative reports. 3. **Filters** (see Filter builder below). Pre-load at least one sensible default (e.g. `teacher_type is one of [b2c]`); Reset returns to the default, not to empty. 4. **Records table** - placed directly under the filters so the reader sees their filter changes reflected immediately. All columns from the CSV (horizontal scroll; do not pre-pick). Include the "Export filtered CSV" button so the reader can grab the filtered subset without leaving the page. 5. **Summary stat cards** - live counts that re-render on every filter change. Color cards by polarity (`good` / `bad` / `warn`). 6. **Breakdowns / charts** - `repeat(auto-fit, minmax(380px, 1fr))` so it reflows on resize. **Order matters:** filters → records → summary → charts. The reader filters first, checks the filtered rows in the table, and only then looks at the aggregates and visuals. The table is the source of truth. #### Source format Take a CSV (or any tabular export) and a generator script that emits one HTML file. Keep the generator small. The page does the work. ``` src/scripts/_report_html.py # generator (or use the generic one) .csv # input _report.html # output (1-2 MB is fine) ``` The generator should: 1. `csv.DictReader` the input. 2. Embed the rows as JSON in a ``. No npm, no bundler. **Container CSS.** Chart.js with `responsive: true` and `maintainAspectRatio: false` expands the canvas to fill its parent. If the parent has no fixed height, you get a 2000px-tall chart. Always wrap the canvas in a `position: relative` div with an explicit height: ```css .chart .canvas-wrap { position: relative; flex: 1 1 auto; height: 300px; } .chart canvas { max-width: 100%; } .chart.tall .canvas-wrap { height: 420px; } /* horizontal bars with many rows */ ``` ```html

...

``` **Re-render, don't recreate.** Cache chart instances by id and call `chart.update()` when filters change. Recreating a chart destroys the canvas context each time and leaks memory. **Chart mix that usually works:** | Visual | Use for | |---|---| | Doughnut | Pass/fail status, vendor distribution, single categorical breakdown | | Stacked bar (vertical) | Compliance broken down by another category (e.g. by teacher type) | | Stacked bar (`indexAxis: "y"`) | Top-N reasons, long category labels | | Plain bar | Quality levels with semantic colors (GOOD = green, BAD = red) | **Categorizing free-text reasons.** If your dataset has a `reason` column with delimited atoms (`"completion_type=partial; unsupported:Virtual Background; build_bitness=32-bit"`), bucket them in JS before charting so the top-N bar is readable: ```js function categorizeReason(atom) { const s = atom.trim(); if (s.startsWith("unsupported:")) return "Unsupported feature: " + s.slice(12); if (s.startsWith("build_bitness=")) return "Not 64-bit OS"; if (s.startsWith("hardware_acceleration=")) return "Hardware acceleration off"; return s; } ``` #### Records table conventions - Render all CSV columns (`TABLE_COLUMNS = COLUMNS`). Horizontal scroll handles width. - Click-to-sort by any column (toggle ascending / descending). - Cap visible rows at 500 for performance; show `"500 of 12345 (sorted by X)"` in a pager line. - Position `` as `position: sticky; top: 0` so headers stay visible while scrolling. #### Search vs filter builder Keep a free-text search input in addition to the builder. It is quicker than building `contains` filters across five identity fields: ```js const hay = SEARCH_FIELDS.map(c => r[c] || "").join(" ").toLowerCase(); if (!hay.includes(search)) return false; ``` #### CSV export ```js function exportCsv() { const rows = applyFilters(); const out = [COLUMNS.join(",")]; for (const r of rows) { out.push(COLUMNS.map(c => { const v = (r[c] || "").toString(); return /[",\n]/.test(v) ? '"' + v.replace(/"/g, '""') + '"' : v; }).join(",")); } const blob = new Blob([out.join("\n")], { type: "text/csv" }); const a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = "filtered.csv"; a.click(); } ``` #### Theming A dark theme suits dense data screens and is easier on the eyes over a 30-minute filtering session. Use CSS custom properties so palettes can be swapped: ```css :root { --bg: #0f172a; --panel: #1e293b; --panel2: #273449; --text: #e2e8f0; --muted: #94a3b8; --border: #334155; --good: #34d399; --bad: #f87171; --warn: #fbbf24; } ``` Set chart grid lines and tick text on dark backgrounds to `--muted` (`#94a3b8`) so the axes don't dominate. #### Pitfalls - **Don't embed data as a JS literal.** Escaping breaks on quotes and newlines. Use `