@patricio0312rev/skillset 0.1.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/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/bin/cli.js +37 -0
- package/package.json +55 -0
- package/src/commands/init.js +301 -0
- package/src/index.js +168 -0
- package/src/lib/config.js +200 -0
- package/src/lib/generator.js +166 -0
- package/src/utils/display.js +95 -0
- package/src/utils/readme.js +196 -0
- package/src/utils/tool-specific.js +233 -0
- package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
- package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
- package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
- package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
- package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
- package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
- package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
- package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
- package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
- package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
- package/templates/architecture/adr-writer/ SKILL.md +250 -0
- package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
- package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
- package/templates/architecture/migration-planner/ SKILL.md +376 -0
- package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
- package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
- package/templates/architecture/rfc-generator/ SKILL.md +362 -0
- package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
- package/templates/architecture/system-design-generator/ SKILL.md +339 -0
- package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
- package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
- package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
- package/templates/backend/auth-module-builder/ SKILL.md +99 -0
- package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
- package/templates/backend/caching-strategist/ SKILL.md +190 -0
- package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
- package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
- package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
- package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
- package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
- package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
- package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
- package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
- package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
- package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
- package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
- package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
- package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
- package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
- package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
- package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
- package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
- package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
- package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
- package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
- package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
- package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
- package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
- package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
- package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
- package/templates/foundation/changelog-writer/ SKILL.md +431 -0
- package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
- package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
- package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
- package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
- package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
- package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
- package/templates/foundation/explaining-code/SKILL.md +13 -0
- package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
- package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
- package/templates/foundation/project-scaffolder/references/templates.md +126 -0
- package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
- package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
- package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
- package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
- package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
- package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
- package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
- package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
- package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
- package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
- package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
- package/templates/frontend/table-builder/ SKILL.md +350 -0
- package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
- package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
- package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
- package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
- package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
- package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
- package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
- package/templates/performance/observability-setup/ SKILL.md +232 -0
- package/templates/performance/postmortem-writer/ SKILL.md +203 -0
- package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
- package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
- package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
- package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
- package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
- package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
- package/templates/security/secrets-scanner/ SKILL.md +462 -0
- package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
- package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
- package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
- package/templates/security/threat-model-generator/ SKILL.md +394 -0
- package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
- package/templates/testing/coverage-strategist/ SKILL.md +436 -0
- package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
- package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
- package/templates/testing/integration-test-builder/ SKILL.md +525 -0
- package/templates/testing/mocking-assistant/ SKILL.md +383 -0
- package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
- package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
- package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
- package/templates/testing/unit-test-generator/ SKILL.md +548 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: table-builder
|
|
3
|
+
description: Creates data table patterns with filtering, sorting, pagination, row actions, column configuration, server/client rendering modes, and empty/loading states. Use when building "data tables", "list views", "admin tables", or "data grids".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Table Builder
|
|
7
|
+
|
|
8
|
+
Generate production-ready data tables with sorting, filtering, and pagination.
|
|
9
|
+
|
|
10
|
+
## Core Workflow
|
|
11
|
+
|
|
12
|
+
1. **Define columns**: Column configuration with types
|
|
13
|
+
2. **Choose mode**: Server-side or client-side rendering
|
|
14
|
+
3. **Add features**: Sorting, filtering, pagination, search
|
|
15
|
+
4. **Row actions**: Edit, delete, view actions
|
|
16
|
+
5. **Empty states**: No data and error views
|
|
17
|
+
6. **Loading states**: Skeletons and suspense
|
|
18
|
+
7. **Mobile responsive**: Stack columns or horizontal scroll
|
|
19
|
+
|
|
20
|
+
## Column Configuration
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
24
|
+
|
|
25
|
+
export const columns: ColumnDef<User>[] = [
|
|
26
|
+
{
|
|
27
|
+
accessorKey: "id",
|
|
28
|
+
header: "ID",
|
|
29
|
+
cell: ({ row }) => (
|
|
30
|
+
<span className="font-mono text-sm">{row.original.id}</span>
|
|
31
|
+
),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
accessorKey: "name",
|
|
35
|
+
header: ({ column }) => (
|
|
36
|
+
<Button
|
|
37
|
+
variant="ghost"
|
|
38
|
+
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
|
39
|
+
>
|
|
40
|
+
Name
|
|
41
|
+
<ArrowUpDown className="ml-2 h-4 w-4" />
|
|
42
|
+
</Button>
|
|
43
|
+
),
|
|
44
|
+
cell: ({ row }) => (
|
|
45
|
+
<div className="font-medium">{row.getValue("name")}</div>
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
accessorKey: "email",
|
|
50
|
+
header: "Email",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
accessorKey: "status",
|
|
54
|
+
header: "Status",
|
|
55
|
+
cell: ({ row }) => {
|
|
56
|
+
const status = row.getValue("status") as string;
|
|
57
|
+
return (
|
|
58
|
+
<Badge variant={status === "active" ? "success" : "secondary"}>
|
|
59
|
+
{status}
|
|
60
|
+
</Badge>
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "actions",
|
|
66
|
+
cell: ({ row }) => <RowActions row={row} />,
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## React Table Implementation
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
"use client";
|
|
75
|
+
|
|
76
|
+
import {
|
|
77
|
+
useReactTable,
|
|
78
|
+
getCoreRowModel,
|
|
79
|
+
getPaginationRowModel,
|
|
80
|
+
getSortedRowModel,
|
|
81
|
+
getFilteredRowModel,
|
|
82
|
+
flexRender,
|
|
83
|
+
} from "@tanstack/react-table";
|
|
84
|
+
|
|
85
|
+
export function DataTable<TData, TValue>({
|
|
86
|
+
columns,
|
|
87
|
+
data,
|
|
88
|
+
}: {
|
|
89
|
+
columns: ColumnDef<TData, TValue>[];
|
|
90
|
+
data: TData[];
|
|
91
|
+
}) {
|
|
92
|
+
const [sorting, setSorting] = useState<SortingState>([]);
|
|
93
|
+
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
|
|
94
|
+
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
|
|
95
|
+
|
|
96
|
+
const table = useReactTable({
|
|
97
|
+
data,
|
|
98
|
+
columns,
|
|
99
|
+
getCoreRowModel: getCoreRowModel(),
|
|
100
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
101
|
+
getSortedRowModel: getSortedRowModel(),
|
|
102
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
103
|
+
onSortingChange: setSorting,
|
|
104
|
+
onColumnFiltersChange: setColumnFilters,
|
|
105
|
+
onPaginationChange: setPagination,
|
|
106
|
+
state: { sorting, columnFilters, pagination },
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<div className="space-y-4">
|
|
111
|
+
<div className="flex items-center justify-between">
|
|
112
|
+
<Input
|
|
113
|
+
placeholder="Search..."
|
|
114
|
+
value={(table.getColumn("name")?.getFilterValue() as string) ?? ""}
|
|
115
|
+
onChange={(e) =>
|
|
116
|
+
table.getColumn("name")?.setFilterValue(e.target.value)
|
|
117
|
+
}
|
|
118
|
+
className="max-w-sm"
|
|
119
|
+
/>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<div className="rounded-md border">
|
|
123
|
+
<Table>
|
|
124
|
+
<TableHeader>
|
|
125
|
+
{table.getHeaderGroups().map((headerGroup) => (
|
|
126
|
+
<TableRow key={headerGroup.id}>
|
|
127
|
+
{headerGroup.headers.map((header) => (
|
|
128
|
+
<TableHead key={header.id}>
|
|
129
|
+
{flexRender(
|
|
130
|
+
header.column.columnDef.header,
|
|
131
|
+
header.getContext()
|
|
132
|
+
)}
|
|
133
|
+
</TableHead>
|
|
134
|
+
))}
|
|
135
|
+
</TableRow>
|
|
136
|
+
))}
|
|
137
|
+
</TableHeader>
|
|
138
|
+
<TableBody>
|
|
139
|
+
{table.getRowModel().rows?.length ? (
|
|
140
|
+
table.getRowModel().rows.map((row) => (
|
|
141
|
+
<TableRow key={row.id}>
|
|
142
|
+
{row.getVisibleCells().map((cell) => (
|
|
143
|
+
<TableCell key={cell.id}>
|
|
144
|
+
{flexRender(
|
|
145
|
+
cell.column.columnDef.cell,
|
|
146
|
+
cell.getContext()
|
|
147
|
+
)}
|
|
148
|
+
</TableCell>
|
|
149
|
+
))}
|
|
150
|
+
</TableRow>
|
|
151
|
+
))
|
|
152
|
+
) : (
|
|
153
|
+
<TableRow>
|
|
154
|
+
<TableCell
|
|
155
|
+
colSpan={columns.length}
|
|
156
|
+
className="h-24 text-center"
|
|
157
|
+
>
|
|
158
|
+
No results.
|
|
159
|
+
</TableCell>
|
|
160
|
+
</TableRow>
|
|
161
|
+
)}
|
|
162
|
+
</TableBody>
|
|
163
|
+
</Table>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<DataTablePagination table={table} />
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Server-Side Pattern
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
// app/users/page.tsx
|
|
176
|
+
import { DataTable } from "@/components/ui/data-table";
|
|
177
|
+
|
|
178
|
+
async function getUsers(params: {
|
|
179
|
+
page: number;
|
|
180
|
+
pageSize: number;
|
|
181
|
+
sortBy?: string;
|
|
182
|
+
sortOrder?: "asc" | "desc";
|
|
183
|
+
search?: string;
|
|
184
|
+
}) {
|
|
185
|
+
const response = await fetch(`/api/users?${new URLSearchParams(params)}`);
|
|
186
|
+
return response.json();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export default async function UsersPage({
|
|
190
|
+
searchParams,
|
|
191
|
+
}: {
|
|
192
|
+
searchParams: { page?: string; search?: string };
|
|
193
|
+
}) {
|
|
194
|
+
const page = Number(searchParams.page) || 1;
|
|
195
|
+
const search = searchParams.search || "";
|
|
196
|
+
|
|
197
|
+
const { data, totalPages } = await getUsers({ page, pageSize: 10, search });
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<div className="space-y-4">
|
|
201
|
+
<h1 className="text-3xl font-bold">Users</h1>
|
|
202
|
+
<DataTable columns={columns} data={data} totalPages={totalPages} />
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Pagination Component
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
export function DataTablePagination({ table }: { table: Table<any> }) {
|
|
212
|
+
return (
|
|
213
|
+
<div className="flex items-center justify-between px-2">
|
|
214
|
+
<div className="text-sm text-gray-700">
|
|
215
|
+
{table.getFilteredSelectedRowModel().rows.length} of{" "}
|
|
216
|
+
{table.getFilteredRowModel().rows.length} row(s) selected
|
|
217
|
+
</div>
|
|
218
|
+
<div className="flex items-center space-x-6">
|
|
219
|
+
<div className="flex items-center space-x-2">
|
|
220
|
+
<p className="text-sm font-medium">Rows per page</p>
|
|
221
|
+
<Select
|
|
222
|
+
value={`${table.getState().pagination.pageSize}`}
|
|
223
|
+
onValueChange={(value) => table.setPageSize(Number(value))}
|
|
224
|
+
>
|
|
225
|
+
<option value="10">10</option>
|
|
226
|
+
<option value="20">20</option>
|
|
227
|
+
<option value="50">50</option>
|
|
228
|
+
</Select>
|
|
229
|
+
</div>
|
|
230
|
+
<div className="flex items-center space-x-2">
|
|
231
|
+
<Button
|
|
232
|
+
variant="outline"
|
|
233
|
+
size="sm"
|
|
234
|
+
onClick={() => table.previousPage()}
|
|
235
|
+
disabled={!table.getCanPreviousPage()}
|
|
236
|
+
>
|
|
237
|
+
Previous
|
|
238
|
+
</Button>
|
|
239
|
+
<Button
|
|
240
|
+
variant="outline"
|
|
241
|
+
size="sm"
|
|
242
|
+
onClick={() => table.nextPage()}
|
|
243
|
+
disabled={!table.getCanNextPage()}
|
|
244
|
+
>
|
|
245
|
+
Next
|
|
246
|
+
</Button>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Row Actions
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
function RowActions({ row }: { row: Row<User> }) {
|
|
258
|
+
const user = row.original;
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<DropdownMenu>
|
|
262
|
+
<DropdownMenuTrigger asChild>
|
|
263
|
+
<Button variant="ghost" size="icon">
|
|
264
|
+
<MoreHorizontal className="h-4 w-4" />
|
|
265
|
+
</Button>
|
|
266
|
+
</DropdownMenuTrigger>
|
|
267
|
+
<DropdownMenuContent align="end">
|
|
268
|
+
<DropdownMenuItem
|
|
269
|
+
onClick={() => navigator.clipboard.writeText(user.id)}
|
|
270
|
+
>
|
|
271
|
+
Copy ID
|
|
272
|
+
</DropdownMenuItem>
|
|
273
|
+
<DropdownMenuItem onClick={() => router.push(`/users/${user.id}`)}>
|
|
274
|
+
View Details
|
|
275
|
+
</DropdownMenuItem>
|
|
276
|
+
<DropdownMenuItem onClick={() => handleEdit(user)}>
|
|
277
|
+
Edit
|
|
278
|
+
</DropdownMenuItem>
|
|
279
|
+
<DropdownMenuSeparator />
|
|
280
|
+
<DropdownMenuItem
|
|
281
|
+
className="text-red-600"
|
|
282
|
+
onClick={() => handleDelete(user)}
|
|
283
|
+
>
|
|
284
|
+
Delete
|
|
285
|
+
</DropdownMenuItem>
|
|
286
|
+
</DropdownMenuContent>
|
|
287
|
+
</DropdownMenu>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Empty State
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
export function EmptyState() {
|
|
296
|
+
return (
|
|
297
|
+
<div className="flex flex-col items-center justify-center py-12">
|
|
298
|
+
<div className="rounded-full bg-gray-100 p-6">
|
|
299
|
+
<InboxIcon className="h-12 w-12 text-gray-400" />
|
|
300
|
+
</div>
|
|
301
|
+
<h3 className="mt-4 text-lg font-semibold">No data found</h3>
|
|
302
|
+
<p className="mt-2 text-sm text-gray-600">
|
|
303
|
+
Get started by creating a new record.
|
|
304
|
+
</p>
|
|
305
|
+
<Button className="mt-4">Create New</Button>
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Loading Skeleton
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
export function TableSkeleton() {
|
|
315
|
+
return (
|
|
316
|
+
<div className="space-y-4">
|
|
317
|
+
<Skeleton className="h-10 w-64" />
|
|
318
|
+
<div className="rounded-md border">
|
|
319
|
+
{Array.from({ length: 10 }).map((_, i) => (
|
|
320
|
+
<div key={i} className="flex gap-4 border-b p-4">
|
|
321
|
+
<Skeleton className="h-6 w-full" />
|
|
322
|
+
</div>
|
|
323
|
+
))}
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Best Practices
|
|
331
|
+
|
|
332
|
+
- Use TanStack Table for complex features
|
|
333
|
+
- Server-side pagination for large datasets
|
|
334
|
+
- Debounce search inputs
|
|
335
|
+
- Persist sorting/filtering in URL params
|
|
336
|
+
- Mobile: Horizontal scroll or card view
|
|
337
|
+
- Accessibility: Keyboard navigation, ARIA
|
|
338
|
+
|
|
339
|
+
## Output Checklist
|
|
340
|
+
|
|
341
|
+
- [ ] Column definitions with types
|
|
342
|
+
- [ ] Sorting functionality
|
|
343
|
+
- [ ] Filtering/search
|
|
344
|
+
- [ ] Pagination controls
|
|
345
|
+
- [ ] Row actions menu
|
|
346
|
+
- [ ] Empty state component
|
|
347
|
+
- [ ] Loading skeleton
|
|
348
|
+
- [ ] Mobile responsive
|
|
349
|
+
- [ ] URL state persistence
|
|
350
|
+
- [ ] Accessibility attributes
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alerting-dashboard-builder
|
|
3
|
+
description: Creates SLO-based alerts and operational dashboards with key charts, alert thresholds, and runbook links. Use for "alerting", "dashboards", "SLO", or "monitoring".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Alerting & Dashboard Builder
|
|
7
|
+
|
|
8
|
+
Build effective alerts and dashboards based on SLOs.
|
|
9
|
+
|
|
10
|
+
## SLO Definition
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
slos:
|
|
14
|
+
- name: api_availability
|
|
15
|
+
objective: 99.9%
|
|
16
|
+
window: 30d
|
|
17
|
+
sli: |
|
|
18
|
+
sum(rate(http_requests_total{status_code!~"5.."}[5m])) /
|
|
19
|
+
sum(rate(http_requests_total[5m]))
|
|
20
|
+
|
|
21
|
+
- name: api_latency
|
|
22
|
+
objective: 95% # 95% of requests under 500ms
|
|
23
|
+
window: 30d
|
|
24
|
+
sli: |
|
|
25
|
+
histogram_quantile(0.95,
|
|
26
|
+
rate(http_request_duration_seconds_bucket[5m])
|
|
27
|
+
) < 0.5
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Alert Rules
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
groups:
|
|
34
|
+
- name: slo_alerts
|
|
35
|
+
rules:
|
|
36
|
+
# Fast burn (1% budget in 1h)
|
|
37
|
+
- alert: AvailabilitySLOFastBurn
|
|
38
|
+
expr: |
|
|
39
|
+
(1 - (sum(rate(http_requests_total{status_code!~"5.."}[1h])) /
|
|
40
|
+
sum(rate(http_requests_total[1h])))) > 0.01
|
|
41
|
+
for: 5m
|
|
42
|
+
labels:
|
|
43
|
+
severity: critical
|
|
44
|
+
annotations:
|
|
45
|
+
summary: "Burning 1% error budget per hour"
|
|
46
|
+
runbook: "https://runbooks.example.com/availability-fast-burn"
|
|
47
|
+
|
|
48
|
+
# Slow burn (10% budget in 24h)
|
|
49
|
+
- alert: AvailabilitySLOSlowBurn
|
|
50
|
+
expr: |
|
|
51
|
+
(1 - (sum(rate(http_requests_total{status_code!~"5.."}[24h])) /
|
|
52
|
+
sum(rate(http_requests_total[24h])))) > 0.001
|
|
53
|
+
for: 1h
|
|
54
|
+
labels:
|
|
55
|
+
severity: warning
|
|
56
|
+
annotations:
|
|
57
|
+
summary: "Burning error budget slowly"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Dashboard Template
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"title": "Service Health Dashboard",
|
|
65
|
+
"rows": [
|
|
66
|
+
{
|
|
67
|
+
"title": "Golden Signals",
|
|
68
|
+
"panels": [
|
|
69
|
+
{
|
|
70
|
+
"title": "Request Rate",
|
|
71
|
+
"query": "sum(rate(http_requests_total[5m]))",
|
|
72
|
+
"type": "graph"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"title": "Error Rate",
|
|
76
|
+
"query": "sum(rate(http_requests_total{status_code=~"5.."}[5m]))",
|
|
77
|
+
"type": "graph"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"title": "Latency (p50, p95, p99)",
|
|
81
|
+
"queries": [
|
|
82
|
+
"histogram_quantile(0.50, rate(http_request_duration_seconds_bucket[5m]))",
|
|
83
|
+
"histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))",
|
|
84
|
+
"histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m]))"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"title": "Saturation (CPU, Memory)",
|
|
89
|
+
"queries": [
|
|
90
|
+
"rate(process_cpu_seconds_total[5m])",
|
|
91
|
+
"process_resident_memory_bytes"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"title": "SLO Tracking",
|
|
98
|
+
"panels": [
|
|
99
|
+
{
|
|
100
|
+
"title": "Error Budget Remaining",
|
|
101
|
+
"query": "1 - ((1 - 0.999) - (1 - slo_availability))"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## What to Do When Alert Fires
|
|
110
|
+
|
|
111
|
+
```markdown
|
|
112
|
+
# Alert Response Guide
|
|
113
|
+
|
|
114
|
+
## HighErrorRate
|
|
115
|
+
|
|
116
|
+
**What it means:** More than 5% of requests are failing
|
|
117
|
+
|
|
118
|
+
**First steps:**
|
|
119
|
+
|
|
120
|
+
1. Check recent deployments (rollback if needed)
|
|
121
|
+
2. Review error logs for patterns
|
|
122
|
+
3. Check dependent services health
|
|
123
|
+
4. Verify database connectivity
|
|
124
|
+
|
|
125
|
+
**Escalation:** If not resolved in 15 min, page on-call lead
|
|
126
|
+
|
|
127
|
+
## HighLatency
|
|
128
|
+
|
|
129
|
+
**What it means:** p95 latency above 2 seconds
|
|
130
|
+
|
|
131
|
+
**First steps:**
|
|
132
|
+
|
|
133
|
+
1. Check database query performance
|
|
134
|
+
2. Review recent code changes
|
|
135
|
+
3. Check cache hit rates
|
|
136
|
+
4. Look for slow external API calls
|
|
137
|
+
|
|
138
|
+
**Temporary mitigation:**
|
|
139
|
+
|
|
140
|
+
- Scale up instances
|
|
141
|
+
- Enable aggressive caching
|
|
142
|
+
|
|
143
|
+
## LowAvailability
|
|
144
|
+
|
|
145
|
+
**What it means:** Availability below 99.5%
|
|
146
|
+
|
|
147
|
+
**First steps:**
|
|
148
|
+
|
|
149
|
+
1. Check infrastructure (AWS status page)
|
|
150
|
+
2. Review load balancer health checks
|
|
151
|
+
3. Check for DDoS activity
|
|
152
|
+
4. Verify auto-scaling functioning
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Output Checklist
|
|
156
|
+
|
|
157
|
+
- [ ] SLOs defined
|
|
158
|
+
- [ ] Alert rules configured
|
|
159
|
+
- [ ] Dashboards created
|
|
160
|
+
- [ ] Runbooks linked
|
|
161
|
+
- [ ] Response guides documented
|
|
162
|
+
ENDFILE
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: backend-latency-profiler-helper
|
|
3
|
+
description: Identifies API latency hotspots and bottlenecks with profiling tools, slow endpoint detection, suspected causes, and fix roadmap. Use for "latency profiling", "performance bottlenecks", "slow APIs", or "backend performance".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Backend Latency Profiler Helper
|
|
7
|
+
|
|
8
|
+
Find and fix API performance bottlenecks.
|
|
9
|
+
|
|
10
|
+
## Slow Endpoint Detection
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// Middleware to track latency
|
|
14
|
+
app.use((req, res, next) => {
|
|
15
|
+
const start = Date.now();
|
|
16
|
+
|
|
17
|
+
res.on("finish", () => {
|
|
18
|
+
const duration = Date.now() - start;
|
|
19
|
+
|
|
20
|
+
if (duration > 1000) {
|
|
21
|
+
logger.warn(
|
|
22
|
+
{
|
|
23
|
+
endpoint: req.path,
|
|
24
|
+
method: req.method,
|
|
25
|
+
duration_ms: duration,
|
|
26
|
+
userId: req.user?.id,
|
|
27
|
+
},
|
|
28
|
+
"Slow request detected"
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
next();
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Top Slow Endpoints
|
|
38
|
+
|
|
39
|
+
```sql
|
|
40
|
+
-- Query from logs
|
|
41
|
+
SELECT
|
|
42
|
+
endpoint,
|
|
43
|
+
AVG(duration_ms) as avg_ms,
|
|
44
|
+
MAX(duration_ms) as max_ms,
|
|
45
|
+
COUNT(*) as requests
|
|
46
|
+
FROM request_logs
|
|
47
|
+
WHERE created_at > NOW() - INTERVAL '1 day'
|
|
48
|
+
GROUP BY endpoint
|
|
49
|
+
HAVING AVG(duration_ms) > 500
|
|
50
|
+
ORDER BY avg_ms DESC
|
|
51
|
+
LIMIT 10;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Suspected Causes
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
interface PerformanceBottleneck {
|
|
58
|
+
endpoint: string;
|
|
59
|
+
avgLatency: number;
|
|
60
|
+
suspectedCauses: string[];
|
|
61
|
+
fixPriority: "high" | "medium" | "low";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const bottlenecks: PerformanceBottleneck[] = [
|
|
65
|
+
{
|
|
66
|
+
endpoint: "GET /api/users/:id",
|
|
67
|
+
avgLatency: 2500,
|
|
68
|
+
suspectedCauses: [
|
|
69
|
+
"N+1 query fetching user orders",
|
|
70
|
+
"No database index on user_id",
|
|
71
|
+
"Expensive JSON serialization",
|
|
72
|
+
],
|
|
73
|
+
fixPriority: "high",
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Fix Roadmap
|
|
79
|
+
|
|
80
|
+
```markdown
|
|
81
|
+
# Performance Fix Roadmap
|
|
82
|
+
|
|
83
|
+
## Week 1: Quick Wins
|
|
84
|
+
|
|
85
|
+
- [ ] Add database indexes
|
|
86
|
+
- [ ] Enable response caching
|
|
87
|
+
- [ ] Fix N+1 queries
|
|
88
|
+
|
|
89
|
+
## Week 2: Medium Effort
|
|
90
|
+
|
|
91
|
+
- [ ] Optimize slow database queries
|
|
92
|
+
- [ ] Implement Redis caching
|
|
93
|
+
- [ ] Add connection pooling
|
|
94
|
+
|
|
95
|
+
## Week 3: Long-term
|
|
96
|
+
|
|
97
|
+
- [ ] Database query optimization
|
|
98
|
+
- [ ] Service decomposition
|
|
99
|
+
- [ ] CDN integration
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Output Checklist
|
|
103
|
+
|
|
104
|
+
- [ ] Slow endpoints identified
|
|
105
|
+
- [ ] Causes analyzed
|
|
106
|
+
- [ ] Fix roadmap created
|
|
107
|
+
- [ ] Monitoring configured
|
|
108
|
+
ENDFILE
|