Skip to content

docs: extending skills#208

Closed
vorcigernix wants to merge 0 commit intocloudflare:mainfrom
vorcigernix:main
Closed

docs: extending skills#208
vorcigernix wants to merge 0 commit intocloudflare:mainfrom
vorcigernix:main

Conversation

@vorcigernix
Copy link

Extending skills with real project problems me and my agent solved. No change in code, just the agentic knowledge.

@vorcigernix
Copy link
Author

/bonk review please

1 similar comment
@southpolesteve
Copy link
Collaborator

/bonk review please

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 1, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@208

commit: df61437

Copy link
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for documenting real migration learnings — this kind of field-tested knowledge is genuinely useful for agents and humans alike. A few observations below, mostly about keeping the guidance general enough to age well and reducing duplication across the three files.

1. Auth/session behavior can regress even when pages appear to load.
- In request-wide auth guards (`proxy.ts` / middleware equivalents), treat vinext static asset paths (`/assets/*`) as internal like `/_next/*`. Redirecting these to sign-in breaks anonymous/public rendering.
- When calling auth APIs server-side, do not rely only on `headers()`. Merge cookie-store cookies into the request headers so RSC/server-action paths consistently see session cookies.
- For Better Auth + SIWE, use shared DB storage (not in-memory) and ensure schema exists (especially `verification`). Prefer explicit schema bootstrap scripts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Better Auth + SIWE guidance here is very specific to one authentication stack. Agents reading this skill will apply these instructions broadly, even when the project doesn't use Better Auth or SIWE.

Consider generalizing to something like: "For any server-side auth library that uses DB-backed sessions, ensure the backing store is persistent (not in-memory) and that all required schema tables exist before the first request." The Better Auth + SIWE specifics could live in troubleshooting.md under the new Auth section (where they already appear at line 44-47).

This would reduce duplication and keep the SKILL.md learnings stack-agnostic.

- For Better Auth + SIWE, use shared DB storage (not in-memory) and ensure schema exists (especially `verification`). Prefer explicit schema bootstrap scripts.
2. Avoid server actions for high-frequency client mutations.
- If a UI action creates many records (for example AI parsing into many day/category entries), use one route handler (`/api/...`) batch request instead of looped server actions.
- Reason: server actions trigger RSC replay and layout re-execution; with auth-protected layouts this can surface `NEXT_REDIRECT` noise and UX churn.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good practical advice, but framing it as a vinext-specific issue is slightly misleading — looped server actions causing NEXT_REDIRECT noise is a general React/Next.js architecture pattern, not something unique to vinext. It may be worth a short note like "This applies to Next.js as well, but surfaces more visibly during migration when layouts are restructured."

- Excluding broad component libraries can cause ESM/CJS runtime mismatches (for example `react/jsx-runtime` named export errors in dev).
- Prefer default optimization unless there is a proven incompatibility.
4. Route segment `error.tsx` can expose shim/runtime gaps.
- If adding segment error boundaries triggers runtime import errors from vinext shims, remove the segment boundary and use safer fallback handling until upstream fix is available.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"remove the segment boundary and use safer fallback handling" is a bit vague for an agent to act on. What does "safer fallback handling" mean concretely? A try/catch in the component? A top-level error boundary? Removing the route entirely?

Even a one-liner like "remove the error.tsx file and rely on the nearest parent error boundary or the root error boundary" would make this actionable.

If you use request-wide auth (`proxy.ts`), treat `/assets/*` as internal/static just like `/_next/*`.

```ts
function isInternalRequest(request: NextRequest): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function accepts NextRequest but doesn't import it. Since this is example code that an agent might copy verbatim into a project, adding the import would prevent a follow-up error:

Suggested change
function isInternalRequest(request: NextRequest): boolean {
function isInternalRequest(request: Request): boolean {
const pathname = new URL(request.url).pathname;
if (pathname.startsWith("/_next/")) return true;
if (pathname.startsWith("/assets/")) return true; // vinext static assets
if (request.headers.has("rsc")) return true;
if (request.headers.has("next-action")) return true;
return false;
}

Alternatively, keep NextRequest but add import { NextRequest } from "next/server"; above the function. Using plain Request + new URL() is arguably more portable since this function doesn't use any NextRequest-specific APIs (.nextUrl is convenient but not required here).


```ts
// client
await fetchJson("/api/dashboard/work-blocks/batch", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetchJson isn't a standard browser/Node API — it's presumably a project-specific helper. An agent copying this example won't have it. Using fetch directly would be more universally applicable:

Suggested change
await fetchJson("/api/dashboard/work-blocks/batch", {
await fetch("/api/dashboard/work-blocks/batch", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ entries }),
});


Do not broadly add libraries to `optimizeDeps.exclude` unless you have a verified reason.
This can trigger ESM/CJS runtime mismatches in dev.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: there's an extra blank line here before ## VinextOptions. Minor, but the rest of the file uses single blank lines between sections.

| `vinext: command not found` | vinext not installed or not in PATH | Install vinext: `npm install vinext`, then run via `npx vinext` or package.json scripts |
| RSC environment crash on dev start | Native Node module (sharp, satori) loaded in RSC env | vinext auto-stubs these in production; in dev, ensure these are only imported in server code behind dynamic `import()` |
| `ASSETS binding not found` | wrangler.jsonc missing assets config | Add `"assets": { "not_found_handling": "none" }` to wrangler.jsonc |
| `NEXT_REDIRECT:/auth/sign-in` after client mutation | Mutation implemented as server action triggers RSC replay + auth-protected layout re-exec | Move high-volume mutations to route handlers (`/api/...`) and batch writes in one request |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The three new table rows are solid additions. One small thing: the error string NEXT_REDIRECT:/auth/sign-in is very specific to one auth setup. Consider broadening the error column to NEXT_REDIRECT during server action or similar, so agents match on the pattern rather than the exact path.

- For Better Auth with SIWE:
- use persistent/shared DB storage
- ensure schema bootstrap includes Better Auth tables (especially `verification`)
- avoid running migration introspection on every request; run explicit bootstrap migrations instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates the Better Auth + SIWE guidance that's also in SKILL.md lines 144-145. Having it in one place (here in troubleshooting, since it's stack-specific) and referencing it from SKILL.md would be cleaner. Duplication in agent skill files is particularly costly because it inflates context without adding new information.

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Mar 1, 2026

Review posted. Here's a summary of the feedback:

Overall: Good addition — real-world migration learnings are valuable for the skill system. The main themes in my review are:

  1. Reduce duplication — The Better Auth + SIWE guidance appears in both SKILL.md and troubleshooting.md. Keeping stack-specific advice in one place (troubleshooting) and referencing it from SKILL.md would be cleaner and save agent context.

  2. Generalize where possible — Some advice is very specific to one auth stack (Better Auth + SIWE) or one error string (NEXT_REDIRECT:/auth/sign-in). Broadening the patterns makes the guidance more reusable.

  3. Fix code examples for copy-paste safety — The isInternalRequest example uses NextRequest without an import, and the batch mutation example uses a non-standard fetchJson helper. Switching to Request/fetch makes these universally applicable.

  4. Clarify vague guidance — "safer fallback handling" for error.tsx shim gaps needs a concrete recommendation (e.g., "rely on the nearest parent error boundary").

  5. Minor: extra blank line before ## VinextOptions in config-examples.md.

github run

@vorcigernix
Copy link
Author

I'll open new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants