web-rules

A set of rules for building the web application with React Router, a framework for routing and rendering React pages, plus Vite and Tailwind CSS.

In plain words
What is it for?
Use it when developing the React web app, including server-rendered pages, data loading, form handling, route files, and shared UI imports.
Why use it?
It keeps web code consistent by documenting the rendering mode, module format, project structure, and file-based routes.

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/proyecto26/projectx/web-rules
Clone the repo
git clone --depth 1 https://github.com/proyecto26/projectx

Made for: Cursor.

Per session 2,527 This file is loaded in full into every session.
When invoked 2,527 The same file — it is already loaded in full.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found 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.02527 $0.02527
Opus 5 $0.01264 $0.01264
Sonnet 5 $0.00505 $0.00505
Haiku 4.5 $0.00253 $0.00253

Measured 2d ago against content hash 46695e54c31f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

web-rules scanned grade C 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 2d ago.

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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf /app/.turbo && \
.cursor/rules/frontend/web-rules.mdc · 352 lines

How it starts

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

Web Application Rules (React Router SSR)

Project Overview

  • Framework: React Router v7 (Framework mode) - The next version of RemixJS
  • Rendering: Server-Side Rendering (SSR)
  • Module System: ESM (not CommonJS)
  • Styling: TailwindCSS v4 (imported from @projectx/ui package)
  • Build Tool: Vite
  • Port: 3000

Critical: Module System

✅ This app uses ESM

// ✅ CORRECT - ESM imports
import { something } from './module';
export { something };
export default Component;
// ❌ WRONG - CommonJS (don't use in web app)
const something = require('./module');
module.exports = something;

Importing from packages

// ✅ Can import ESM and CommonJS packages
import { User } from '@projectx/models';  // ESM
import { AuthService } from '@projectx/core';  // CommonJS (transpiled)
import { Button } from '@projectx/ui';  // ESM

React Router Framework Mode

This is NOT traditional React Router

  • Uses file-based routing (like Remix/Next.js)
  • Server-side rendering by default
  • Built-in data loading with loaders
  • Form handling with actions
  • Automatic code splitting

File structure:

apps/web/
├── app/
│   ├── routes/           # File-based routes
│   │   ├── _index.tsx    # Home page (/)
│   │   ├── about.tsx     # /about
│   │   └── users.$id.tsx # /users/:id (dynamic)
│   ├── root.tsx          # Root layout
│   └── entry.client.tsx  # Client entry point
│   └── entry.server.tsx  # Server entry point

Route conventions:

  • _index.tsx - Index route
  • about.tsx - Static route /about
  • users.$id.tsx - Dynamic route /users/:id
  • _layout.tsx - Layout route (no URL segment)
  • _auth.login.tsx - Pathless layout

Data Loading

Use loaders for server-side data fetching

import { json, type LoaderFunctionArgs } from 'react-router';
export async function loader({ params, request }: LoaderFunctionArgs) {
  const user = await fetchUser(params.id);
  return json({ user });
}
export default function UserPage() {
  const { user } = useLoaderData<typeof loader>();
  return <div>{user.name}</div>;
}

Read the full file on GitHub · 352 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. 2d ago First seen · 352 lines · 2,527 tokens per session scan C 46695e54c31f

Subscribe to this mod's changes

web-rules is a cursor rule published in the GitHub repository proyecto26/projectx (83 stars, last pushed 4mo ago), licensed MIT. It adds 2,527 tokens to every session, about $0.0126 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.