tribunal-kit 4.3.0 → 4.4.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/.agent/history/architecture-explorer.html +352 -0
- package/.agent/history/architecture-graph.yaml +109 -0
- package/.agent/history/graph-cache.json +215 -0
- package/.agent/history/snapshots/migrate_refs.js.json +11 -0
- package/.agent/history/snapshots/scripts__changelog.js.json +12 -0
- package/.agent/history/snapshots/scripts__sync-version.js.json +11 -0
- package/.agent/history/snapshots/scripts__validate-payload.js.json +11 -0
- package/.agent/history/snapshots/test__integration__bridges.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__init.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__routing.test.js.json +11 -0
- package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__wave2.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__args.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__copyDir.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__semver.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +11 -0
- package/.agent/scripts/case_law_manager.js +684 -684
- package/.agent/scripts/dependency_analyzer.js +1 -1
- package/.agent/scripts/graph_builder.js +311 -0
- package/.agent/scripts/graph_visualizer.js +384 -0
- package/.agent/scripts/graph_zoom.js +154 -0
- package/.agent/scripts/mutation_runner.js +280 -0
- package/.agent/skills/agent-organizer/SKILL.md +9 -1
- package/.agent/skills/agentic-patterns/SKILL.md +9 -1
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +9 -1
- package/.agent/skills/api-patterns/SKILL.md +206 -198
- package/.agent/skills/api-security-auditor/SKILL.md +9 -1
- package/.agent/skills/app-builder/SKILL.md +9 -1
- package/.agent/skills/app-builder/templates/SKILL.md +77 -69
- package/.agent/skills/appflow-wireframe/SKILL.md +9 -1
- package/.agent/skills/architecture/SKILL.md +9 -1
- package/.agent/skills/authentication-best-practices/SKILL.md +9 -1
- package/.agent/skills/bash-linux/SKILL.md +9 -1
- package/.agent/skills/behavioral-modes/SKILL.md +9 -1
- package/.agent/skills/brainstorming/SKILL.md +9 -1
- package/.agent/skills/building-native-ui/SKILL.md +9 -1
- package/.agent/skills/clean-code/SKILL.md +9 -1
- package/.agent/skills/code-review-checklist/SKILL.md +9 -1
- package/.agent/skills/config-validator/SKILL.md +9 -1
- package/.agent/skills/csharp-developer/SKILL.md +9 -1
- package/.agent/skills/data-validation-schemas/SKILL.md +287 -279
- package/.agent/skills/database-design/SKILL.md +199 -191
- package/.agent/skills/deployment-procedures/SKILL.md +9 -1
- package/.agent/skills/devops-engineer/SKILL.md +9 -1
- package/.agent/skills/devops-incident-responder/SKILL.md +9 -1
- package/.agent/skills/documentation-templates/SKILL.md +9 -1
- package/.agent/skills/edge-computing/SKILL.md +9 -1
- package/.agent/skills/error-resilience/SKILL.md +387 -379
- package/.agent/skills/extract-design-system/SKILL.md +9 -1
- package/.agent/skills/framer-motion-expert/SKILL.md +203 -195
- package/.agent/skills/frontend-design/SKILL.md +160 -152
- package/.agent/skills/game-design-expert/SKILL.md +9 -1
- package/.agent/skills/game-engineering-expert/SKILL.md +9 -1
- package/.agent/skills/geo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/github-operations/SKILL.md +9 -1
- package/.agent/skills/gsap-core/SKILL.md +54 -46
- package/.agent/skills/gsap-frameworks/SKILL.md +54 -46
- package/.agent/skills/gsap-performance/SKILL.md +54 -46
- package/.agent/skills/gsap-plugins/SKILL.md +54 -46
- package/.agent/skills/gsap-react/SKILL.md +54 -46
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -46
- package/.agent/skills/gsap-timeline/SKILL.md +54 -46
- package/.agent/skills/gsap-utils/SKILL.md +54 -46
- package/.agent/skills/i18n-localization/SKILL.md +9 -1
- package/.agent/skills/intelligent-routing/SKILL.md +38 -30
- package/.agent/skills/knowledge-graph/SKILL.md +52 -0
- package/.agent/skills/lint-and-validate/SKILL.md +9 -1
- package/.agent/skills/llm-engineering/SKILL.md +9 -1
- package/.agent/skills/local-first/SKILL.md +9 -1
- package/.agent/skills/mcp-builder/SKILL.md +9 -1
- package/.agent/skills/mobile-design/SKILL.md +222 -214
- package/.agent/skills/monorepo-management/SKILL.md +293 -285
- package/.agent/skills/motion-engineering/SKILL.md +193 -185
- package/.agent/skills/nextjs-react-expert/SKILL.md +193 -185
- package/.agent/skills/nodejs-best-practices/SKILL.md +9 -1
- package/.agent/skills/observability/SKILL.md +9 -1
- package/.agent/skills/parallel-agents/SKILL.md +9 -1
- package/.agent/skills/performance-profiling/SKILL.md +9 -1
- package/.agent/skills/plan-writing/SKILL.md +9 -1
- package/.agent/skills/platform-engineer/SKILL.md +9 -1
- package/.agent/skills/playwright-best-practices/SKILL.md +9 -1
- package/.agent/skills/powershell-windows/SKILL.md +9 -1
- package/.agent/skills/project-idioms/SKILL.md +9 -1
- package/.agent/skills/python-patterns/SKILL.md +9 -1
- package/.agent/skills/python-pro/SKILL.md +282 -274
- package/.agent/skills/react-specialist/SKILL.md +236 -228
- package/.agent/skills/readme-builder/SKILL.md +9 -1
- package/.agent/skills/realtime-patterns/SKILL.md +9 -1
- package/.agent/skills/red-team-tactics/SKILL.md +9 -1
- package/.agent/skills/rust-pro/SKILL.md +9 -1
- package/.agent/skills/seo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/server-management/SKILL.md +9 -1
- package/.agent/skills/shadcn-ui-expert/SKILL.md +9 -1
- package/.agent/skills/skill-creator/SKILL.md +9 -1
- package/.agent/skills/sql-pro/SKILL.md +9 -1
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +9 -1
- package/.agent/skills/swiftui-expert/SKILL.md +9 -1
- package/.agent/skills/systematic-debugging/SKILL.md +9 -1
- package/.agent/skills/tailwind-patterns/SKILL.md +9 -1
- package/.agent/skills/tdd-workflow/SKILL.md +9 -1
- package/.agent/skills/test-result-analyzer/SKILL.md +9 -1
- package/.agent/skills/testing-patterns/SKILL.md +28 -3
- package/.agent/skills/trend-researcher/SKILL.md +9 -1
- package/.agent/skills/typescript-advanced/SKILL.md +294 -286
- package/.agent/skills/ui-ux-pro-max/SKILL.md +561 -116
- package/.agent/skills/ui-ux-researcher/SKILL.md +9 -1
- package/.agent/skills/vue-expert/SKILL.md +234 -226
- package/.agent/skills/vulnerability-scanner/SKILL.md +9 -1
- package/.agent/skills/web-accessibility-auditor/SKILL.md +9 -1
- package/.agent/skills/web-design-guidelines/SKILL.md +9 -1
- package/.agent/skills/webapp-testing/SKILL.md +9 -1
- package/.agent/skills/whimsy-injector/SKILL.md +9 -1
- package/.agent/skills/workflow-optimizer/SKILL.md +9 -1
- package/README.md +242 -242
- package/bin/tribunal-kit.js +157 -21
- package/package.json +81 -80
- package/scripts/validate-payload.js +73 -0
|
@@ -1,187 +1,187 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: nextjs-react-expert
|
|
3
|
-
description: Next.js 15+ App Router mastery. Server Components, Server Actions, PPR, caching, metadata, middleware, parallel/intercepting routes. Use when building Next.js apps or optimizing Next.js performance.
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
-
version: 3.1.0
|
|
6
|
-
last-updated: 2026-04-06
|
|
7
|
-
applies-to-model: gemini-3-1-pro, claude-3-7-sonnet
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Next.js 15+ App Router — Dense Reference
|
|
11
|
-
|
|
12
|
-
## Hallucination Traps (Read First)
|
|
13
|
-
- ❌ `pages/api/` or `_app.tsx` → ✅ App Router only: `app/api/route.ts`, `app/layout.tsx`
|
|
14
|
-
- ❌ `getServerSideProps` → ✅ `async function Page()` fetches directly
|
|
15
|
-
- ❌ `next/router` → ✅ `next/navigation` (`useRouter`, `usePathname`, `useSearchParams`)
|
|
16
|
-
- ❌ Server Action without `"use server"` → ✅ Required at top of file or top of function
|
|
17
|
-
- ❌ Fetch is cached by default → ✅ **Next.js 15 changed this**: `fetch()` is UNCACHED by default
|
|
18
|
-
- ❌ `cookies()` at top of page → ✅ Opts entire route into dynamic rendering, breaking PPR. Wrap inside `<Suspense>`
|
|
19
|
-
- ❌ Passing functions as props Server → Client → ✅ Illegal. Use Server Actions instead.
|
|
20
|
-
- ❌ Plain `Response` in route handler → ✅ Use `NextResponse.json()`
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## App Router Conventions
|
|
25
|
-
|
|
26
|
-
```text
|
|
27
|
-
app/
|
|
28
|
-
├── layout.tsx ← Root shell (HTML/BODY)
|
|
29
|
-
├── page.tsx ← Route UI
|
|
30
|
-
├── loading.tsx ← Auto-suspense fallback
|
|
31
|
-
├── error.tsx ← Error boundary (Must be "use client")
|
|
32
|
-
├── not-found.tsx ← 404 UI
|
|
33
|
-
├── global-error.tsx ← Root error boundary
|
|
34
|
-
├── api/users/route.ts ← API Handler (GET, POST)
|
|
35
|
-
├── @modal/login/page.tsx ← Parallel Route (renders in same layout)
|
|
36
|
-
└── (auth)/login/page.tsx ← Route Group (doesn't affect URL)
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Server vs Client Components
|
|
42
|
-
|
|
43
|
-
- **Server Components (Default)**: Zero JS. Direct DB access. Secure env vars.
|
|
44
|
-
- **Client Components (`"use client"`)**: Lifecycle (`useEffect`), State (`useState`), Browser APIs (`window`), Event listeners (`onClick`).
|
|
45
|
-
|
|
46
|
-
```tsx
|
|
47
|
-
// ✅ INTERLEAVING PATTERN: Pass Server Component as children to Client Component
|
|
48
|
-
export default function Page() {
|
|
49
|
-
return (
|
|
50
|
-
<ClientSidebar> {/* "use client" */}
|
|
51
|
-
<ServerStats /> {/* Server: zero JS bundle, fetches DB */}
|
|
52
|
-
</ClientSidebar>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## Server Actions (Mutations)
|
|
60
|
-
|
|
61
|
-
```tsx
|
|
62
|
-
"use server"
|
|
63
|
-
import { revalidatePath } from "next/cache";
|
|
64
|
-
import { z } from "zod";
|
|
65
|
-
|
|
66
|
-
const Schema = z.object({ name: z.string().min(2) });
|
|
67
|
-
|
|
68
|
-
export async function createUser(prevState: any, formData: FormData) {
|
|
69
|
-
// ❌ TRAP: ALWAYS validate formData. Never trust client input.
|
|
70
|
-
const parsed = Schema.safeParse({ name: formData.get("name") });
|
|
71
|
-
if (!parsed.success) return { errors: parsed.error.flatten().fieldErrors };
|
|
72
|
-
|
|
73
|
-
await db.user.create({ data: parsed.data });
|
|
74
|
-
revalidatePath("/users"); // Clears cache so next render shows new user
|
|
75
|
-
return { success: true };
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Client usage (React 19):
|
|
80
|
-
```tsx
|
|
81
|
-
"use client"
|
|
82
|
-
import { useActionState } from "react";
|
|
83
|
-
import { createUser } from "./actions";
|
|
84
|
-
|
|
85
|
-
export function UserForm() {
|
|
86
|
-
const [state, formAction, isPending] = useActionState(createUser, null);
|
|
87
|
-
return (
|
|
88
|
-
<form action={formAction}>
|
|
89
|
-
<input name="name" />
|
|
90
|
-
<button disabled={isPending}>Submit</button>
|
|
91
|
-
{state?.errors?.name && <p>{state.errors.name}</p>}
|
|
92
|
-
</form>
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## Data Fetching & Caching (Next.js 15)
|
|
100
|
-
|
|
101
|
-
```tsx
|
|
102
|
-
// Next.js 15 caching defaults
|
|
103
|
-
const dynamic = await fetch(url); // 15 default: NO CACHE
|
|
104
|
-
const static = await fetch(url, { cache: "force-cache" }); // Static
|
|
105
|
-
const isr = await fetch(url, { next: { revalidate: 3600 } }); // Revalidate every hour
|
|
106
|
-
const tagged = await fetch(url, { next: { tags: ["user-1"] } }); // On-demand via revalidateTag()
|
|
107
|
-
|
|
108
|
-
// DB calls without fetch
|
|
109
|
-
import { unstable_cache } from "next/cache";
|
|
110
|
-
const getCachedUser = unstable_cache(
|
|
111
|
-
async (id) => db.user.findUnique({ where: { id } }),
|
|
112
|
-
["user-cache-key"],
|
|
113
|
-
{ revalidate: 60, tags: ["users"] }
|
|
114
|
-
);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Waterfall Elimination
|
|
118
|
-
```tsx
|
|
119
|
-
// ✅ Parallel Fetching:
|
|
120
|
-
const [user, posts] = await Promise.all([getUser(), getPosts()]);
|
|
121
|
-
|
|
122
|
-
// ✅ Streaming (PPR-compatible):
|
|
123
|
-
export default function Page() {
|
|
124
|
-
return (
|
|
125
|
-
<main>
|
|
126
|
-
<FastNav />
|
|
127
|
-
{/* Page shell loads instantly, SlowChart streams in when ready */}
|
|
128
|
-
<Suspense fallback={<Skeleton />}>
|
|
129
|
-
<SlowChart />
|
|
130
|
-
</Suspense>
|
|
131
|
-
</main>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## Partial Prerendering (PPR)
|
|
139
|
-
|
|
140
|
-
PPR static-generates the route shell and streams dynamic parts.
|
|
141
|
-
```tsx
|
|
142
|
-
// next.config.ts
|
|
143
|
-
export default { experimental: { ppr: true } };
|
|
144
|
-
|
|
145
|
-
// Any component reading cookies/headers inside a Suspense boundary becomes a dynamic hole
|
|
146
|
-
import { cookies } from "next/headers";
|
|
147
|
-
|
|
148
|
-
async function Cart() {
|
|
149
|
-
const c = await cookies(); // Next.js 15 cookies are async!
|
|
150
|
-
const cartId = c.get("cartId");
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export default function Page() {
|
|
154
|
-
return (
|
|
155
|
-
<div>
|
|
156
|
-
<StaticHeader /> {/* Cached at build time on CDN */}
|
|
157
|
-
<Suspense fallback={<CartSkeleton />}>
|
|
158
|
-
<Cart /> {/* Dynamic, streamed at request time */}
|
|
159
|
-
</Suspense>
|
|
160
|
-
</div>
|
|
161
|
-
)
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## Middleware
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
// middleware.ts (Root of project)
|
|
171
|
-
import { NextResponse } from "next/server";
|
|
172
|
-
import type { NextRequest } from "next/server";
|
|
173
|
-
|
|
174
|
-
export function middleware(req: NextRequest) {
|
|
175
|
-
const token = req.cookies.get("auth-token");
|
|
176
|
-
if (!token && req.nextUrl.pathname.startsWith("/dashboard")) {
|
|
177
|
-
return NextResponse.redirect(new URL("/login", req.url));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export const config = {
|
|
182
|
-
matcher: ["/dashboard/:path*"], // Strict matcher is critical for performance
|
|
183
|
-
};
|
|
184
|
-
```
|
|
1
|
+
---
|
|
2
|
+
name: nextjs-react-expert
|
|
3
|
+
description: Next.js 15+ App Router mastery. Server Components, Server Actions, PPR, caching, metadata, middleware, parallel/intercepting routes. Use when building Next.js apps or optimizing Next.js performance.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
version: 3.1.0
|
|
6
|
+
last-updated: 2026-04-06
|
|
7
|
+
applies-to-model: gemini-3-1-pro, claude-3-7-sonnet
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Next.js 15+ App Router — Dense Reference
|
|
11
|
+
|
|
12
|
+
## Hallucination Traps (Read First)
|
|
13
|
+
- ❌ `pages/api/` or `_app.tsx` → ✅ App Router only: `app/api/route.ts`, `app/layout.tsx`
|
|
14
|
+
- ❌ `getServerSideProps` → ✅ `async function Page()` fetches directly
|
|
15
|
+
- ❌ `next/router` → ✅ `next/navigation` (`useRouter`, `usePathname`, `useSearchParams`)
|
|
16
|
+
- ❌ Server Action without `"use server"` → ✅ Required at top of file or top of function
|
|
17
|
+
- ❌ Fetch is cached by default → ✅ **Next.js 15 changed this**: `fetch()` is UNCACHED by default
|
|
18
|
+
- ❌ `cookies()` at top of page → ✅ Opts entire route into dynamic rendering, breaking PPR. Wrap inside `<Suspense>`
|
|
19
|
+
- ❌ Passing functions as props Server → Client → ✅ Illegal. Use Server Actions instead.
|
|
20
|
+
- ❌ Plain `Response` in route handler → ✅ Use `NextResponse.json()`
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## App Router Conventions
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
app/
|
|
28
|
+
├── layout.tsx ← Root shell (HTML/BODY)
|
|
29
|
+
├── page.tsx ← Route UI
|
|
30
|
+
├── loading.tsx ← Auto-suspense fallback
|
|
31
|
+
├── error.tsx ← Error boundary (Must be "use client")
|
|
32
|
+
├── not-found.tsx ← 404 UI
|
|
33
|
+
├── global-error.tsx ← Root error boundary
|
|
34
|
+
├── api/users/route.ts ← API Handler (GET, POST)
|
|
35
|
+
├── @modal/login/page.tsx ← Parallel Route (renders in same layout)
|
|
36
|
+
└── (auth)/login/page.tsx ← Route Group (doesn't affect URL)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Server vs Client Components
|
|
42
|
+
|
|
43
|
+
- **Server Components (Default)**: Zero JS. Direct DB access. Secure env vars.
|
|
44
|
+
- **Client Components (`"use client"`)**: Lifecycle (`useEffect`), State (`useState`), Browser APIs (`window`), Event listeners (`onClick`).
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
// ✅ INTERLEAVING PATTERN: Pass Server Component as children to Client Component
|
|
48
|
+
export default function Page() {
|
|
49
|
+
return (
|
|
50
|
+
<ClientSidebar> {/* "use client" */}
|
|
51
|
+
<ServerStats /> {/* Server: zero JS bundle, fetches DB */}
|
|
52
|
+
</ClientSidebar>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Server Actions (Mutations)
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
"use server"
|
|
63
|
+
import { revalidatePath } from "next/cache";
|
|
64
|
+
import { z } from "zod";
|
|
65
|
+
|
|
66
|
+
const Schema = z.object({ name: z.string().min(2) });
|
|
67
|
+
|
|
68
|
+
export async function createUser(prevState: any, formData: FormData) {
|
|
69
|
+
// ❌ TRAP: ALWAYS validate formData. Never trust client input.
|
|
70
|
+
const parsed = Schema.safeParse({ name: formData.get("name") });
|
|
71
|
+
if (!parsed.success) return { errors: parsed.error.flatten().fieldErrors };
|
|
72
|
+
|
|
73
|
+
await db.user.create({ data: parsed.data });
|
|
74
|
+
revalidatePath("/users"); // Clears cache so next render shows new user
|
|
75
|
+
return { success: true };
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Client usage (React 19):
|
|
80
|
+
```tsx
|
|
81
|
+
"use client"
|
|
82
|
+
import { useActionState } from "react";
|
|
83
|
+
import { createUser } from "./actions";
|
|
84
|
+
|
|
85
|
+
export function UserForm() {
|
|
86
|
+
const [state, formAction, isPending] = useActionState(createUser, null);
|
|
87
|
+
return (
|
|
88
|
+
<form action={formAction}>
|
|
89
|
+
<input name="name" />
|
|
90
|
+
<button disabled={isPending}>Submit</button>
|
|
91
|
+
{state?.errors?.name && <p>{state.errors.name}</p>}
|
|
92
|
+
</form>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Data Fetching & Caching (Next.js 15)
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
// Next.js 15 caching defaults
|
|
103
|
+
const dynamic = await fetch(url); // 15 default: NO CACHE
|
|
104
|
+
const static = await fetch(url, { cache: "force-cache" }); // Static
|
|
105
|
+
const isr = await fetch(url, { next: { revalidate: 3600 } }); // Revalidate every hour
|
|
106
|
+
const tagged = await fetch(url, { next: { tags: ["user-1"] } }); // On-demand via revalidateTag()
|
|
107
|
+
|
|
108
|
+
// DB calls without fetch
|
|
109
|
+
import { unstable_cache } from "next/cache";
|
|
110
|
+
const getCachedUser = unstable_cache(
|
|
111
|
+
async (id) => db.user.findUnique({ where: { id } }),
|
|
112
|
+
["user-cache-key"],
|
|
113
|
+
{ revalidate: 60, tags: ["users"] }
|
|
114
|
+
);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Waterfall Elimination
|
|
118
|
+
```tsx
|
|
119
|
+
// ✅ Parallel Fetching:
|
|
120
|
+
const [user, posts] = await Promise.all([getUser(), getPosts()]);
|
|
121
|
+
|
|
122
|
+
// ✅ Streaming (PPR-compatible):
|
|
123
|
+
export default function Page() {
|
|
124
|
+
return (
|
|
125
|
+
<main>
|
|
126
|
+
<FastNav />
|
|
127
|
+
{/* Page shell loads instantly, SlowChart streams in when ready */}
|
|
128
|
+
<Suspense fallback={<Skeleton />}>
|
|
129
|
+
<SlowChart />
|
|
130
|
+
</Suspense>
|
|
131
|
+
</main>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Partial Prerendering (PPR)
|
|
139
|
+
|
|
140
|
+
PPR static-generates the route shell and streams dynamic parts.
|
|
141
|
+
```tsx
|
|
142
|
+
// next.config.ts
|
|
143
|
+
export default { experimental: { ppr: true } };
|
|
144
|
+
|
|
145
|
+
// Any component reading cookies/headers inside a Suspense boundary becomes a dynamic hole
|
|
146
|
+
import { cookies } from "next/headers";
|
|
147
|
+
|
|
148
|
+
async function Cart() {
|
|
149
|
+
const c = await cookies(); // Next.js 15 cookies are async!
|
|
150
|
+
const cartId = c.get("cartId");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default function Page() {
|
|
154
|
+
return (
|
|
155
|
+
<div>
|
|
156
|
+
<StaticHeader /> {/* Cached at build time on CDN */}
|
|
157
|
+
<Suspense fallback={<CartSkeleton />}>
|
|
158
|
+
<Cart /> {/* Dynamic, streamed at request time */}
|
|
159
|
+
</Suspense>
|
|
160
|
+
</div>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Middleware
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// middleware.ts (Root of project)
|
|
171
|
+
import { NextResponse } from "next/server";
|
|
172
|
+
import type { NextRequest } from "next/server";
|
|
173
|
+
|
|
174
|
+
export function middleware(req: NextRequest) {
|
|
175
|
+
const token = req.cookies.get("auth-token");
|
|
176
|
+
if (!token && req.nextUrl.pathname.startsWith("/dashboard")) {
|
|
177
|
+
return NextResponse.redirect(new URL("/login", req.url));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const config = {
|
|
182
|
+
matcher: ["/dashboard/:path*"], // Strict matcher is critical for performance
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
---
|
|
@@ -223,4 +223,12 @@ Review these questions before confirming output:
|
|
|
223
223
|
|
|
224
224
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
225
225
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
226
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
226
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
## Pre-Flight Checklist
|
|
230
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
231
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
232
|
+
|
|
233
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
234
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -537,4 +537,12 @@ Review these questions before confirming output:
|
|
|
537
537
|
|
|
538
538
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
539
539
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
540
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
540
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
## Pre-Flight Checklist
|
|
544
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
545
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
546
|
+
|
|
547
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
548
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -332,4 +332,12 @@ Review these questions before confirming output:
|
|
|
332
332
|
|
|
333
333
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
334
334
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
335
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
335
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
## Pre-Flight Checklist
|
|
339
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
340
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
341
|
+
|
|
342
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
343
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -135,4 +135,12 @@ Review these questions before confirming output:
|
|
|
135
135
|
|
|
136
136
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
137
137
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
138
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
138
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
## Pre-Flight Checklist
|
|
142
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
143
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
144
|
+
|
|
145
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
146
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -256,4 +256,12 @@ Review these questions before confirming output:
|
|
|
256
256
|
|
|
257
257
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
258
258
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
259
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
259
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
## Pre-Flight Checklist
|
|
263
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
264
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
265
|
+
|
|
266
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
267
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -131,4 +131,12 @@ Review these questions before confirming output:
|
|
|
131
131
|
|
|
132
132
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
133
133
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
134
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
134
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## Pre-Flight Checklist
|
|
138
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
139
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
140
|
+
|
|
141
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
142
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -136,4 +136,12 @@ Review these questions before confirming output:
|
|
|
136
136
|
|
|
137
137
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
138
138
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
139
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
139
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
## Pre-Flight Checklist
|
|
143
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
144
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
145
|
+
|
|
146
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
147
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -176,4 +176,12 @@ Review these questions before confirming output:
|
|
|
176
176
|
|
|
177
177
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
178
178
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
179
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
179
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
## Pre-Flight Checklist
|
|
183
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
184
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
185
|
+
|
|
186
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
187
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -151,4 +151,12 @@ Review these questions before confirming output:
|
|
|
151
151
|
|
|
152
152
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
153
153
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
154
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
154
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## Pre-Flight Checklist
|
|
158
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
159
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
160
|
+
|
|
161
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
162
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -126,4 +126,12 @@ Review these questions before confirming output:
|
|
|
126
126
|
|
|
127
127
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
128
128
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
129
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
129
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## Pre-Flight Checklist
|
|
133
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
134
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
135
|
+
|
|
136
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
137
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -248,4 +248,12 @@ Review these questions before confirming output:
|
|
|
248
248
|
|
|
249
249
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
250
250
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
251
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
251
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
## Pre-Flight Checklist
|
|
255
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
256
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
257
|
+
|
|
258
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
259
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|