Windsurf rules examples work best when they encode repo-specific contracts for Cascade: how to build, which paths are off-limits, and when a rule should load. This page shows layouts and snippets you can copy into.windsurf/rules (and related Cascade rule surfaces), then tighten against your own verify commands. Treat every product label and front-matter key here as illustrative—paths and activation modes change across Windsurf / Cascade releases, so re-check your installed docs before treating any example as permanent.
01
Independence note
02
What Cascade rules are for (vs memories & prompts)
Cascade can accumulate auto-generated memories that stay local. Project rules are the durable, shareable layer you commit so every teammate’s Cascade session sees the same contracts. Put long-lived constraints in rules; keep ticket goals in the chat brief; keep ephemeral observations in memories if your workflow uses them. Decision FAQ: Windsurf memories vs rules.
- Rules: package manager, route registry, forbidden deploy paths, test commands, language defaults.
- Session prompts: this ticket’s objective, acceptance checks, and temporary non-goals.
- Neither: secrets, production credentials, or one-off customer data.
If you already maintain Cursor-oriented rules, the engineering intent is similar—different packaging. Compare side-by-side in cursor rules examples · continue rules examples and the multi-file choice notes in AGENTS.md vs CLAUDE.md vs Cursor rules. For reusable root agent docs many hosts also load, see how to write AGENTS.md.
03
File layout patterns & activation modes
Modern workspace rules usually live as focused Markdown files under.windsurf/rules/. Older setups may still use a single root.windsurfrules file. Prefer small, concern-scoped files so you can enable, disable, or activate by glob without rewriting a novel. Exact discovery paths can evolve—confirm in current product docs.
.windsurf/
rules/
project-conventions.md # always_on house style
frontend-pages.md # trigger: glob → src/pages/**
no-deploy.md # forbid wrangler/DNS unless asked
security-review.md # trigger: manual → @-mention when neededDirectory rules commonly set behavior with YAML front matter. Four activation patterns show up often (names may vary by release):
- always_on — loads for every Cascade conversation in the workspace.
- glob — loads when edited files match a pattern (pair with a short
globslist). - model_decision — Cascade judges relevance from a
description; keep that description concrete. - manual — only when you
@-mention the rule; good for heavy review checklists.
Workspace rule files are often character-capped (commonly on the order of tens of thousands of characters per file; global rules may be tighter). Stay short on purpose: dense bullets beat essays, and headroom leaves room for the next constraint you will inevitably add.
04
Copy-ready windsurf rules examples
Adapt these templates. Replace commands, paths, and non-goals with your repo’s truth. Keep them short enough that a human will maintain them.
Always-on project conventions
---
trigger: always_on
---
# Project conventions
- Indent with 4 spaces; do not reformat unrelated files.
- Register every indexable page in the site’s route registry (e.g. pages[]).
- Prefer extending an existing page/component pattern over inventing a new layout.
- Run the project’s build command before claiming done.
- Do not deploy, edit hosting config, or change DNS unless the user explicitly asks.Glob-scoped frontend / docs pages
---
trigger: glob
globs: ["src/pages/**/*.tsx", "public/assets/styles.css"]
description: Frontend and docs page conventions for Cascade
---
# Frontend page rules
- Mirror ArticleNavigation + article-hero structure from sibling EN how-to pages.
- Unique Title, Description, and a single H1 that contains the target phrase.
- Include Related reading links to sibling guides; keep bidirectional links updated.
- Do not invent new indexed URLs; only add paths listed in the task.Model-decision database / migrations
---
trigger: model_decision
description: Schema, migrations, and repository query changes
---
# Database work
- Put queries in the existing repository layer; do not invent a second data access style.
- Add a new migration; never rewrite an already-applied migration.
- Include a rollback note for destructive schema changes.
- Do not run production migrations from the agent session.Manual security review
---
trigger: manual
---
# Security review
Review the selected changes for:
1. authz gaps;
2. unvalidated external input;
3. secrets or PII in logs;
4. unsafe redirects or file paths.
Return findings with file references and severity. Do not edit files unless asked.
Invoke with @security-review when you want this checklist.When tools live outside the editor, pair rules with a clear tool policy in the prompt. For MCP host pitfalls, see the MCP server tutorial and MCP server best practices.
05
Writing patterns that stick
- Imperative and testable. “Run
pnpm run build” beats “ensure quality.” - Name artifacts. Paths, registry names, and sibling files beat vibes.
- State non-goals. Cascade over-helps; forbid deploy, rebrand, or drive-by refactors.
- Match activation to weight. Always-on for house style; glob for area conventions; manual for heavy checklists.
- Write a useful description for model-decision rules—the agent decides from that text first.
- Point at exemplars. “Match
GoodAgentPromptPage.tsx” beats reinventing layout.
Rules degrade when they become a wishlist. If Cascade still violates a rule after two sessions, either the rule is vague, the wrong activation mode is selected, or a stronger nearby example is missing—fix the example and the trigger first.
06
Anti-patterns
- Novel-length always-on rules: hit character caps and get sampled inconsistently.
- Vague model_decision descriptions: the agent cannot decide relevance from “be careful.”
- Contradictions: “always refactor” next to “never touch unrelated files.”
- Secrets in rules: rules are often committed; use env stores instead.
- Copying Cursor rules wholesale without remapping paths: wrong directory, wrong front matter, wrong done checks.
- Product tutorials inside rules: teach workflows in docs; keep rules as contracts.
Related reading: Cursor rules examples · Continue rules examples · Cline rules examples · Antigravity rules examples · Kilo code rules examples · Amazon Q rules examples · AGENTS.md vs CLAUDE.md vs Cursor rules · How to write AGENTS.md · How to write CLAUDE.md · Cursor skills examples · Good agent prompts · Cursor agent tips · Agent engineering notes
07
Windsurf workflows vs rules
Searching for windsurf workflows vs rules is the durable-standards vs slash-triggered multi-step cut (same spirit as memories vs rules). Official Workflows docs remain authoritative for product UI—this is an unofficial packaging note.
- Rules under
.windsurf/rules: persistent standards Cascade should respect across sessions (stack pins, verify commands, deploy non-goals). Commit them. - Workflows (often
/-triggered): multi-step actions you invoke on demand—checklists, release rituals, review scripts—not always-on house law.
08
FAQ
Where should I put windsurf rules examples in a repo?
Most teams use a .windsurf/rules/ directory with small, focused Markdown files. Some workspaces still carry a legacy root.windsurfrules file. Exact discovery rules depend on your Windsurf / Cascade version—confirm in current product docs. This site’s examples are unofficial templates, not a product catalog.
Which activation mode should I start with?
Start with one always_on conventions file plus oneglob file for the area you edit most. Add amanual checklist when reviews are heavy and occasional. Reach for model_decision when a domain is intermittent but you can write a crisp description Cascade can judge.
How do these relate to Cursor rules or AGENTS.md?
Same job—durable repo contracts—different loaders and file shapes. Cursor teams often use .cursor/rules; see cursor rules examples and continue rules examples. Multi-tool teams often keep a root AGENTS.md and thinner IDE-specific rules. Choice notes: AGENTS.md vs CLAUDE.md vs Cursor rules. Do not paste the same wall of text into every layer.
Windsurf workflows vs rules—how do I choose?
Searching for windsurf workflows vs rules: put durable standards in committed rules; put multi-step, on-demand playbooks in Workflows. See workflows vs rules. Official Workflows docs cover product UI; this page stays on packaging judgment.
Windsurf memories vs rules—how do I choose?
Searching for windsurf memories vs rules (Cascade Memories vs project rules) is a local-vs-shareable cut.Memories are typically auto-accumulated, local observations for one machine/user.Rules under .windsurf/rules are durable, reviewable contracts you commit so every teammate’s Cascade session shares the same constraints. Put stack pins, verify commands, and deploy non-goals in rules; leave ephemeral session observations in memories if your workflow uses them. Do not treat memories as a substitute for committed rules—or paste the same wall into both. Official Memories docs remain authoritative for product UI; this is an unofficial packaging note.
Will these templates work unchanged on every Windsurf release?
No. Treat them as starting points. Re-verify directory names, front matter keys (trigger, globs,description), character limits, and UI labels after upgrades. Prefer repo-specific commands and paths over marketing phrases that age poorly.