All skills
sergiodxa avatar

/frontend-react-router-best-practices

@9da9532

React Router performance and architecture patterns. Use when writing loaders, actions, forms, routes, or working with React Router data fetching. Triggers on tasks involving React Router routes, data loading, form handling, or route organization.

Use this Skill: https://skilld.dev/gh/sergiodxa/agent-skills/frontend-react-router-best-practices

This session only. Nothing lands on disk.

rulesmiddleware-batcher.md

≈258 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Batcher Middleware

Use createBatcherMiddleware for request-scoped deduping of expensive calls.

Why

  • Avoids duplicate DB/API calls within one request
  • Keeps code composable across loaders/actions
  • Simplifies request-level caching

Pattern

// app/middleware/batcher.server.ts
import { createBatcherMiddleware } from "remix-utils/middleware/batcher";
import { getContext } from "~/middleware/context-storage.server";

export const [batcherMiddleware, getBatcherFromContext] =
  createBatcherMiddleware();

export function getBatcher() {
  return getBatcherFromContext(getContext());
}
export const middleware: Route.MiddlewareFunction[] = [batcherMiddleware];

export async function loader() {
  let batcher = getBatcher();
  let result = await batcher.batch("key", async () => getData());
  return data({ result });
}

Rules

  1. Use a stable batch key per request
  2. Prefer batching to ad-hoc in-memory caches

Source: SKILL.md on GitHub

2 warnings16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides a comprehensive set of developer guidelines and best practices for building React Router applications. It emphasizes performance, type safety, and security measures like input validation (Zod), safe redirects, and CSRF protection (Sec-Fetch). No malicious code, obfuscation, or data exfiltration patterns were detected.

  • Socket16d

    1 alert: gptSecurity

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    56/56 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 9da9532. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago

README badge

README badge for sergiodxa/agent-skills/frontend-react-router-best-practices