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.
npx agentmods add rules/rm2thaddeus/pixel_detective/nextjs-hydration-preventiongit clone --depth 1 https://github.com/rm2thaddeus/Pixel_DetectiveWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/rm2thaddeus/pixel_detective/nextjs-hydration-prevention)<a href="https://agentmods.dev/rules/rm2thaddeus/pixel_detective/nextjs-hydration-prevention"><img src="https://agentmods.dev/badge/rules/rm2thaddeus/pixel_detective/nextjs-hydration-prevention.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00697 |
| Opus 5 | $0.00000 | $0.00349 |
| Sonnet 5 | $0.00000 | $0.00139 |
| Haiku 4.5 | $0.00000 | $0.00070 |
Grade C, and why
nextjs-hydration-prevention 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 4d 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.
1. **Clear caches**: `rm -rf .next && npm run dev` How it starts
The opening of the file, as written. The whole thing — 107 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Next.js Hydration Error Prevention Rules
🚨 CRITICAL: Server/Client Rendering Consistency
MANDATORY PATTERNS - ALWAYS USE:
1. Theme Provider Setup (Chakra UI)
// ✅ CORRECT: Two-stage rendering to prevent mismatches
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);
// During SSR - minimal theme
if (!mounted) {
return <ChakraProvider theme={ssrTheme}>{children}</ChakraProvider>;
}
// After hydration - full theme
return <ChakraProvider theme={clientTheme}>{children}</ChakraProvider>;
2. ColorModeScript Placement
// ✅ ALWAYS in layout.tsx <head>
export default function RootLayout({ children }) {
return (
<html lang="en" suppressHydrationWarning>
<head>
<ColorModeScript initialColorMode="light" />
</head>
<body><Provider>{children}</Provider></body>
</html>
);
}
3. Client-Only Components
// ✅ Use mounted state for browser-specific logic
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return <PlaceholderComponent />; // Server-safe fallback
}
return <BrowserSpecificComponent />; // Full functionality
FORBIDDEN PATTERNS - NEVER USE:
❌ Direct Browser API Access in Render
// ❌ NEVER: Causes hydration mismatch
function BadComponent() {
return <div>Width: {window.innerWidth}</div>;
}
// ❌ NEVER: Different values on server/client
function BadComponent() {
return <div>{Math.random()}</div>;
}
// ❌ NEVER: Time-dependent rendering
function BadComponent() {
return <div>{new Date().toLocaleTimeString()}</div>;
}
DEBUGGING CHECKLIST:
Before any commit involving themes, client-only features, or dynamic content:
- Test in production build:
npm run build && npm start - Console clean: No hydration error messages
- Theme consistency: Both light/dark modes work without flash
- suppressHydrationWarning: Only on
<html>tag, nowhere else - ColorModeScript: Always in
<head>, matches theme config
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.
- 4d ago First seen · 107 lines · 0 tokens per session scan C 5018b8d3a755
nextjs-hydration-prevention is a cursor rule published in the GitHub repository rm2thaddeus/Pixel_Detective (21 stars, last pushed 7mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 697 tokens. 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.
Other cursor rules, from other repositories
development-conventions
Development conventions, code style, and best practices for the Kaneo project.
general
Wonder Blocks design system conventions, component patterns, and coding standards.
backend
Backend development rules for TT Studio - AI model management backend.
new-component
Workflow for creating new React components.
common-fixes
Utility for VAN QA common validation fixes.
middleware-auth
Next.js middleware auth — prevents auth logic being placed in middleware instead of route handlers.