Cursor Rules Examples: React Native, Go, Flutter, Svelte
Most published Cursor rules examples are written for Next.js or Python/FastAPI, so teams on React Native, Go, Flutter, or Svelte end up copying a rule file built for a different framework and stripping out what doesn't apply. Below is one annotated starter .mdc per stack — globs, the always-on vs. scoped call, and the two or three bans each ecosystem actually needs. Last updated 2026-10-29 by Rakshit Yadav.
What a rule file needs that's different per stack
Every .cursor/rules/*.mdc file needs the same three frontmatter decisions — a description, a globs pattern, and whether alwaysApply is true — but the right glob and the right bans change completely once you leave the Next.js/TypeScript world most examples assume. A React Native rule has to separate platform-specific files from shared logic; a Go rule has to talk about error handling instead of a client/server boundary; a Flutter rule lives in a widget tree instead of a component tree; a Svelte rule has to account for runes replacing most of what used to be component state. Treat each glob as the first design decision, not an afterthought — a rule scoped too wide loads on every turn and gets skimmed, and one scoped too narrow silently never fires. For the general framework behind this split, see Cursor Rules vs Skills vs Commands.
React Native: .cursor/rules/react-native.mdc
---
description: React Native platform and native-module conventions
globs: src/**/*.tsx,src/**/*.ts,app/**/*.tsx
alwaysApply: false
---
- Platform-specific logic goes in a .ios.tsx / .android.tsx file pair, not an
inline Platform.OS branch inside a shared component, once that branch
exceeds a couple of lines.
- Never call a native module API (camera, biometrics, push tokens) directly
from a screen component. Wrap it in a hook under src/native/ so a mocked
version can back it in tests and on web/Expo Go.
- Lists over roughly 20 items use FlatList/FlashList, not .map() inside a
ScrollView. A mapped ScrollView renders every row up front and will jank on
a mid-range Android device even if it's fine in the simulator.
- Any new dependency that touches native code (not pure JS) must be checked
against the current Expo SDK's compatibility list before it's added.The FlatList rule exists because a mapped ScrollView looks correct in a simulator and in code review — the jank only shows up on real low-end Android hardware, which is exactly the gap an agent without that context won't catch on its own.
Go: .cursor/rules/go-services.mdc
---
description: Go error handling and service conventions
globs: **/*.go
alwaysApply: false
---
- Every returned error gets wrapped with fmt.Errorf("doing X: %w", err) at
each call boundary, not returned bare. Bare propagation loses the context
needed to debug a failure three layers down without re-running it.
- Don't ignore an error with _ unless the line directly above explains why
it's safe to ignore (e.g. a Close() in a defer after a successful write).
- Context (context.Context) is the first parameter of any function that can
block on I/O, and it's never stored on a struct — pass it down the call
chain instead.
- New goroutines that aren't fire-and-forget logging must be joined with a
sync.WaitGroup or bounded by an errgroup.Group. A goroutine with no owner
is a goroutine nobody can report a panic or error from.This is one of the few rule files where alwaysApply: false with a repo-wide glob (**/*.go) still makes sense: in a Go-only repo every file matches anyway, so the glob is really there to exclude generated code (*.pb.go, *_mock.go) once you add an ignore pattern for it.
Flutter: .cursor/rules/flutter-widgets.mdc
---
description: Flutter widget and state-management conventions
globs: lib/**/*.dart
alwaysApply: false
---
- Default to a StatelessWidget plus the project's state-management package
(Riverpod/Bloc — name whichever this repo actually uses) for anything that
holds state. Reach for StatefulWidget only for state that is purely local
to the widget's own lifecycle, like an AnimationController.
- Never call setState() inside a build() method or a loop. If a rebuild loop
shows up in the Flutter DevTools profiler, that's the first place to look.
- Split a widget into a smaller one once its build() method needs to scroll
to read in full. A giant build() is the Flutter equivalent of a God
component, and it rebuilds entirely on every state change that touches it.
- Dispose any controller (TextEditingController, AnimationController,
ScrollController) you create in initState() inside the matching dispose().The dispose rule is the one most often dropped when a rule file gets ported in from a React-flavored starter, because React has no direct equivalent — there's no dispose() concept to carry over, so it has to be added explicitly rather than inherited from another stack's rule file.
Svelte: .cursor/rules/svelte5-runes.mdc
---
description: Svelte 5 runes and reactivity conventions
globs: src/**/*.svelte,src/**/*.svelte.ts
alwaysApply: false
---
- This project uses Svelte 5 runes ($state, $derived, $effect), not the
Svelte 4 export-let / $: syntax. Do not introduce Svelte 4 patterns
into new files even if an older file in the repo still uses them.
- $effect is for syncing with something outside Svelte's reactivity (the
DOM, a third-party library, localStorage), not for deriving a value from
other state — that's what $derived is for. An $effect that only
recomputes and reassigns a $state value should be a $derived instead.
- Shared reactive logic that needs to run outside a component goes in a
.svelte.ts file using runes directly, not back into a plain store unless
the project has an explicit reason to keep using stores.
- Server-only code (DB clients, secrets) stays in +page.server.ts /
+server.ts files and must never be imported into a +page.svelte or any
.svelte.ts file reachable from the client bundle.The $effect-vs-$derived line matters because Svelte 5's runes are new enough that a model trained mostly on Svelte 4 examples (or on React's useEffect habits) will reach for $effect by default — it's the one that most resembles what it already knows, not the one that's correct here.
Common mistakes when porting a rule from another framework
| Mistake | Where it comes from | Fix |
|---|---|---|
| Copying a Next.js "use client" rule into a Flutter or Go rule file verbatim, leaving a dead reference to a concept that doesn't exist in the target stack | Starting from a popular public .mdc gist instead of writing from the stack's own idioms | Delete anything that references a concept the target framework doesn't have, even if it seems harmless to leave in |
Scoping a glob to the whole repo (**/*) when only one directory tree needs the rule | Not realizing alwaysApply: false + a broad glob still fires on every matching file, every turn | Scope to the actual directory (lib/**/*.dart, src/**/*.svelte) so unrelated edits don't load it |
| Writing the rule as prose explanation instead of a checkable ban | Rule files get drafted like documentation, not like a lint rule | Each line should be something you could grep a diff against — "never do X" or "always do Y," not "consider doing X when appropriate" |
| Putting a full how-to (e.g. Riverpod provider setup, a Go error-package walkthrough) into the rule instead of a skill | No separate skill exists yet, so everything lands in the one file that does | Keep the rule to bans; move the procedure into a skill — see Rules vs Skills: Which One Do You Need |
Where this fits with skills and CLAUDE.md
These four rule files are deliberately short lists of bans, the same shape as the Next.js App Router rule and the Stripe billing rules on this site. If you need the full procedure behind any of them — setting up a Riverpod provider tree, structuring a Go service's error package, wiring a React Native native module — that belongs in a skill the agent loads on demand, not in a rule that fires on every turn. The decision logic for that split, and how it maps to Claude Code's CLAUDE.md and SKILL.md equivalents if you run both tools, is covered in Cursor Rules vs Skills vs Commands.
Related pages
Frequently asked questions
Can I use one .mdc rule file across React Native, Go, Flutter and Svelte?
No — scope a separate file per stack with its own glob (lib/**/*.dart for Flutter, **/*.go for Go, src/**/*.svelte for Svelte, src/**/*.tsx for React Native). A shared rule file either loads for the wrong files or has to be written so vaguely it stops being checkable.Why does the Svelte rule call out $effect vs $derived specifically?
Svelte 5's runes are recent enough that a model's training data skews toward Svelte 4 or React patterns, so it defaults to $effect (which mirrors useEffect) even when $derived is correct. Naming the exact failure mode in the rule is what makes it catchable in a diff.Should the Go rule apply to generated files like *.pb.go?
No. Scope the glob to exclude generated and mock files, or the rule will flag code you never hand-write and can't meaningfully fix without regenerating it.What's the most common mistake when porting a Cursor rule between frameworks?
Copying a rule written for one stack's idioms (most often a Next.js 'use client' example) and leaving references to concepts the target framework doesn't have, instead of writing the rule from that stack's own failure modes.Where do I put the full setup procedure instead of just the bans?
In a skill, not the rule file. The rule should stay a short, checkable list; a longer walkthrough (provider setup, native module wiring, a Go error-handling package) belongs in .cursor/skills/<name>/SKILL.md so it only loads when the task actually needs it.
Skip hand-writing the rule file
AgenticKit ships stack-specific skills and a react-specialist agent for Claude Code. If you run Cursor alongside it, generate matching .mdc rules from the same source instead of maintaining two copies by hand.