60-stack-frontend

A set of frontend rules for TypeScript and React, tools commonly used to build browser interfaces. It covers type safety, components, UI states, performance, accessibility, and optional Next.js 15 App Router guidance.

In plain words
What is it for?
Use it when building or changing React components, TypeScript code, forms, loading and error states, keyboard navigation, or Next.js 15 App Router code.
Why use it?
It helps avoid unsafe types, incomplete interfaces, inaccessible controls, unnecessary browser work, and inconsistent component structure.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/luxvil/ai-coding-rules/60-stack-frontend
Clone the repo
git clone --depth 1 https://github.com/Luxvil/ai-coding-rules

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 803 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00803
Opus 5 $0.00000 $0.00402
Sonnet 5 $0.00000 $0.00161
Haiku 4.5 $0.00000 $0.00080

Measured yesterday against content hash 6fbbd8e43d59, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

60-stack-frontend scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

fetch(url, { next: { revalidate: 60 } });
Origin

This is a copy

100% identical to 60-stack-frontend — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cursor/rules/60-stack-frontend.mdc · 117 lines

How it starts

The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Frontend (TypeScript/React)

Type Safety

  • Ban any — use unknown with type guards if needed.
  • Prefer interface for object shapes, type for unions/intersections.
  • Use strict TypeScript configuration.

React Style

  • Functional components + hooks only — no class components.
  • Avoid unnecessary state; prefer reducer/context for complex state.
  • Handle all UI states: loading, empty, error, success.

Exports

  • Prefer named exports over default exports.
  • One component per file for main components.

Performance

  • Avoid unnecessary re-renders; memoize only when justified.
  • Use dynamic imports for heavy components.
  • Prevent N+1 fetches in UI loops.

Accessibility (A11y)

  • Buttons must be <button> elements.
  • Inputs must have associated labels.
  • Use aria-label for icon-only buttons.
  • Ensure keyboard navigation for menus/dialogs.

Next.js 15 App Router (Optional)

Apply when working with Next.js 15+ App Router architecture.

Component Strategy

Type When to Use Directive
Server Component Default for all components None needed
Client Component Event handlers, hooks, browser APIs 'use client' at top

Rule: Start with Server Components. Add 'use client' only when you need:

  • useState, useEffect, or other hooks
  • Event handlers (onClick, onChange, etc.)
  • Browser-only APIs (window, localStorage, etc.)

Data Fetching Patterns

Parallel Fetching (Avoid Waterfalls)
// ❌ BAD: Sequential (waterfall) — slow
const user = await getUser();
const posts = await getPosts();
const comments = await getComments();

// ✅ GOOD: Parallel — fast
const [user, posts, comments] = await Promise.all([
  getUser(),
  getPosts(),
  getComments()
]);
Server Actions for Mutations
// ✅ Preferred: Server Action
async function createPost(formData: FormData) {
  'use server';
  
  const title = formData.get('title');
  // Validation, DB insert, etc.
  revalidatePath('/posts');
}

// Usage in component
<form action={createPost}>
  <input name="title" />
  <button type="submit">Create</button>
</form>

Read the full file on GitHub · 117 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 117 lines · 0 tokens per session scan A 6fbbd8e43d59

Subscribe to this mod's changes

60-stack-frontend is a cursor rule published in the GitHub repository Luxvil/ai-coding-rules (3 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 803 tokens. A static security scan graded it A with 1 finding (makes network calls). It is 100% identical to 60-stack-frontend, differing in 0 lines, and is treated as a copy.