heymegabyte/agent-skills / 06-build-and-slice-loop
build-and-slice-loop
VerifiedUse when implementing features or streaming OnePrompt site builds. Complete vertical slices with real content, strict TypeScript and Zod. Parallel section/data work, deterministic assembly, granular patches and immediate valid previews.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.2 KB |
| admin-dashboard.md | markdown | 5.5 KB |
| ai-chat-widget.md | markdown | 6.0 KB |
| blog-and-content-engine.md | markdown | 6.2 KB |
| build-breaking-rules.md | markdown | 7.4 KB |
| chat-native-dashboard.md | markdown | 3.6 KB |
| contact-forms-and-endpoints.md | markdown | 6.7 KB |
| copilot-and-ai-features.md | markdown | 7.4 KB |
| custom-error-pages.md | markdown | 4.5 KB |
| data-tables.md | markdown | 7.7 KB |
| domain-provisioning.md | markdown | 4.6 KB |
| easter-eggs.md | markdown | 4.7 KB |
| empty-states-and-loading.md | markdown | 5.7 KB |
| file-uploads-and-storage.md | markdown | 6.7 KB |
| internationalization.md | markdown | 4.3 KB |
| keyboard-shortcuts-and-command-palette.md | markdown | 6.7 KB |
| microcopy-library.md | markdown | 8.0 KB |
| notification-center.md | markdown | 8.4 KB |
| onboarding-and-first-run.md | markdown | 5.0 KB |
| pre-digested-builds.md | markdown | 3.6 KB |
| pwa-kit.md | markdown | 6.8 KB |
| realtime-and-websockets.md | markdown | 7.2 KB |
| rich-text-editor.md | markdown | 7.4 KB |
| site-search.md | markdown | 4.0 KB |
| stripe-first-donations.md | markdown | 10.7 KB |
| web-manifest-system.md | markdown | 11.9 KB |
| webhook-system.md | markdown | 9.5 KB |
data-tables.md
View on GitHub---
name: "Data Tables"
version: "2.0.0"
updated: "2026-04-23"
description: "AG Grid (ag-grid-angular) for complex data tables with server-side row model, Hono API pagination, column definitions, filtering, sorting, cell renderers, infinite scroll for 100K+ rows, and CSV/Excel export. Angular 22 standalone + signals integration."
---
# Data Tables
## Angular AG Grid Setup
```typescript
// data-table.component.ts
import { Component, input, signal, viewChild } from '@angular/core';
import { AgGridAngular } from 'ag-grid-angular';
import type { ColDef, GridReadyEvent, IServerSideDatasource, IServerSideGetRowsParams, GridApi } from 'ag-grid-community';
import { ModuleRegistry } from 'ag-grid-community';
import { ServerSideRowModelModule } from 'ag-grid-enterprise';
import { CsvExportModule, ExcelExportModule } from 'ag-grid-enterprise';
ModuleRegistry.registerModules([ServerSideRowModelModule, CsvExportModule, ExcelExportModule]);
@Component({
selector: 'app-data-table',
standalone: true,
imports: [AgGridAngular],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="toolbar">
<input type="text" placeholder="Search..." (input)="onSearch($event)" />
<button (click)="exportCsv()">Export CSV</button>
<button (click)="exportExcel()">Export Excel</button>
</div>
<ag-grid-angular
style="width: 100%; height: 600px;"
class="ag-theme-alpine-dark"
[columnDefs]="columnDefs()"
[defaultColDef]="defaultColDef"
[rowModelType]="'serverSide'"
[pagination]="true"
[paginationPageSize]="50"
[cacheBlockSize]="50"
[animateRows]="true"
(gridReady)="onGridReady($event)"
/>
`,
})
export class DataTableComponent {
readonly endpoint = input('/api/data');
readonly columnDefs = input<ColDef[]>([]);
defaultColDef: ColDef = {
sortable: true,
filter: true,
resizable: true,
floatingFilter: true,
minWidth: 100,
};
private gridApi = signal<GridApi | undefined>(undefined);
onGridReady(params: GridReadyEvent): void {
this.gridApi.set(params.api);
params.api.setGridOption('serverSideDatasource', this.createDatasource());
}
onSearch(event: Event): void {
const value = (event.target as HTMLInputElement).value;
this.gridApi()?.setGridOption('quickFilterText', value);
}
exportCsv(): void { this.gridApi()?.exportDataAsCsv(); }
exportExcel(): void { this.gridApi()?.exportDataAsExcel(); }
private createDatasource(): IServerSideDatasource {
const endpoint = this.endpoint;
return {
getRows: async (params: IServerSideGetRowsParams) => {
const { startRow, endRow, sortModel, filterModel } = params.request;
const query = new URLSearchParams({
offset: String(startRow ?? 0),
limit: String((endRow ?? 50) - (startRow ?? 0)),
sort: JSON.stringify(sortModel),
filter: JSON.stringify(filterModel),
});
try {
const res = await fetch(`${endpoint}?${query}`);
const { rows, totalCount } = await res.json();
params.success({ rowData: rows, rowCount: totalCount });
} catch {
params.fail();
}
},
};
}
}
```
## Hono Server-Side Pagination API
```typescript
// src/routes/data.ts
import { Hono } from 'hono';
import { zValidator } from '@hono/zod-validator';
import { z } from 'zod';
const data = new Hono<{ Bindings: Env }>();
const querySchema = z.object({
offset: z.coerce.number().int().min(0).default(0),
limit: z.coerce.number().int().min(1).max(200).default(50),
sort: z.string().optional(),
filter: z.string().optional(),
search: z.string().optional(),
});
data.get('/', zValidator('query', querySchema), async (c) => {
const { offset, limit, sort, filter, search } = c.req.valid('query');
let query = 'SELECT * FROM items';
let countQuery = 'SELECT COUNT(*) as total FROM items';
const conditions: string[] = [];
const bindings: unknown[] = [];
// Search
if (search) {
conditions.push('(name LIKE ? OR description LIKE ?)');
bindings.push(`%${search}%`, `%${search}%`);
}
// AG Grid filter model
if (filter) {
const filters = JSON.parse(filter) as Record<string, { filterType: string; type: string; filter: unknown }>;
for (const [col, f] of Object.entries(filters)) {
if (f.filterType === 'text') {
switch (f.type) {
case 'contains': conditions.push(`${col} LIKE ?`); bindings.push(`%${f.filter}%`); break;
case 'equals': conditions.push(`${col} = ?`); bindings.push(f.filter); break;
case 'startsWith': conditions.push(`${col} LIKE ?`); bindings.push(`${f.filter}%`); break;
}
} else if (f.filterType === 'number') {
switch (f.type) {
case 'equals': conditions.push(`${col} = ?`); bindings.push(f.filter); break;
case 'greaterThan': conditions.push(`${col} > ?`); bindings.push(f.filter); break;
case 'lessThan': conditions.push(`${col} < ?`); bindings.push(f.filter); break;
}
}
}
}
if (conditions.length) {
const where = ` WHERE ${conditions.join(' AND ')}`;
query += where;
countQuery += where;
}
// AG Grid sort model
if (sort) {
const sorts = JSON.parse(sort) as Array<{ colId: string; sort: 'asc' | 'desc' }>;
if (sorts.length) {
query += ` ORDER BY ${sorts.map((s) => `${s.colId} ${s.sort}`).join(', ')}`;
}
}
query += ' LIMIT ? OFFSET ?';
bindings.push(limit, offset);
const [rows, countResult] = await Promise.all([
c.env.DB.prepare(query).bind(...bindings).all(),
c.env.DB.prepare(countQuery).bind(...bindings.slice(0, -2)).first(),
]);
return c.json({ rows: rows.results, totalCount: (countResult as { total: number }).total });
});
export { data };
```
## Column Definition Patterns
```typescript
const columnDefs: ColDef[] = [
{ field: 'id', headerName: 'ID', width: 80, hide: true },
{ field: 'name', headerName: 'Name', flex: 2, filter: 'agTextColumnFilter' },
{ field: 'email', headerName: 'Email', flex: 2 },
{ field: 'status', headerName: 'Status', width: 120,
cellRenderer: (params: { value: string }) => {
const colors: Record<string, string> = { active: '#00E5FF', inactive: '#666', pending: '#7C3AED' };
return `<span style="color:${colors[params.value] || '#fff'}">${params.value}</span>`;
},
filter: 'agSetColumnFilter',
},
{ field: 'amount', headerName: 'Amount', width: 120, type: 'numericColumn',
valueFormatter: (p) => p.value ? `$${p.value.toLocaleString()}` : '—',
},
{ field: 'createdAt', headerName: 'Created', width: 160,
valueFormatter: (p) => p.value ? new Date(p.value).toLocaleDateString() : '',
filter: 'agDateColumnFilter',
},
{ headerName: 'Actions', width: 100, sortable: false, filter: false,
cellRenderer: (params: { data: { id: string } }) =>
`<button data-action="edit" data-id="${params.data.id}">Edit</button>`,
},
];
```
## Infinite Scroll (no pagination)
```typescript
// Replace pagination with infinite scroll
<ag-grid-angular
[rowModelType]="'serverSide'"
[pagination]="false"
[cacheBlockSize]="100"
[maxBlocksInCache]="10"
[rowBuffer]="20"
/>
// Server returns rows in blocks, grid fetches next block on scroll
```
## Print Layout
```typescript
printTable(): void {
this.gridApi.setDomLayout('print');
setTimeout(() => {
window.print();
this.gridApi.setDomLayout('normal');
}, 200);
}
```
## Theming (dark-first)
```css
.ag-theme-alpine-dark {
--ag-background-color: #060610;
--ag-header-background-color: #0a0a1a;
--ag-odd-row-background-color: #0d0d1f;
--ag-row-hover-color: rgba(0, 229, 255, 0.05);
--ag-selected-row-background-color: rgba(0, 229, 255, 0.1);
--ag-font-family: 'Space Grotesk', sans-serif;
--ag-border-color: rgba(255, 255, 255, 0.08);
}
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |