The Windsurf .windsurf/rules directory replaces monolithic .windsurfrules files with modular Markdown documents capped at 12,000 characters each and governed by four YAML activation modes: always_on, glob, model_decision, and manual. Scoping rules by file path or agent intent eliminates constant prompt bloat across Windsurf Cascade and modern Devin Local sessions.
How Does the .windsurf/rules Directory Replace Monolithic .windsurfrules Files?
Windsurf replaces single-file .windsurfrules configurations by discovering multiple Markdown files inside .windsurf/rules/*.md across your workspace, subdirectories, and parent folders up to the Git root. Instead of loading every guideline on every turn, Cascade and Devin Local inspect each file's YAML trigger frontmatter to decide when it enters context.
According to the official Windsurf Memories & Rules documentation, discovery scans .windsurf/rules across nested subdirectories and parent folders up to the Git root, deduplicating multi-root matches by shortest relative path. Per the Devin Local Customizations docs and Devin CLI Configuration Import reference, legacy .windsurf/rules/*.md, .windsurf/global_rules.md, and .windsurfrules load automatically alongside .devin/rules/*.md, with subdirectory files discovered lazily as the agent touches those folders.
Activation Modes Compared: always_on, glob, model_decision, and manual
Windsurf supports four activation modes—always_on, glob, model_decision, and manual—to control when a .windsurf/rules/*.md file enters prompt context. Picking the right trigger prevents a 30-rule workspace from burning thousands of idle tokens per turn.
| Activation Mode | Frontmatter Syntax | When Loaded | Context Cost | Best Use Case |
|---|---|---|---|---|
| always_on | trigger: always_on | Injected into every Cascade or Devin Local session at startup | Full file character count on every turn | Short repo invariants (package manager, test runner, language strictness) |
| glob | trigger: glob + globs: "src/api/**/*.ts" | Loaded only when the agent opens or edits files matching the glob pattern | Zero overhead outside matching paths | Framework rules (React UI, SQL migrations, Vitest suites, Terraform) |
| model_decision | trigger: model_decision + description: "..." | Agent sees the description at startup and reads the full file when relevant | Minimal index metadata until triggered | Domain workflows (security audits, incident playbooks, release checklists) |
| manual | trigger: manual | Excluded from automatic context; loaded only when invoked via @rule-name | Zero baseline context tokens | Heavy refactoring guides, migration runbooks, and edge-case templates |
Choose glob when a rule maps cleanly to file paths (such as **/*.test.ts), because path matching is deterministic. Choose model_decision when relevance depends on user intent rather than file extension, keeping only the rule's description in the startup index until matched.
Where Does Windsurf Discover Global, Workspace, and Enterprise System Rules?
Windsurf discovers rules across four filesystem tiers: enterprise system folders, workspace .windsurf/rules/*.md directories, legacy root .windsurfrules, and user-level global rules. Knowing how each tier scopes prevents silent shadowing between personal and team repositories.
| Rule Tier | Filesystem Path | Scope | Resolution Notes |
|---|---|---|---|
| 1. Enterprise System Rules | /Library/Application Support/Windsurf/rules/*.md (macOS), /etc/windsurf/rules/*.md (Linux), C:\ProgramData\Windsurf\rules\*.md (Windows) | All workspaces on managed endpoints; read-only for end users | Merged alongside workspace and global rules without overriding user rules. |
| 2. Workspace Rules Directory | .windsurf/rules/*.md (imported alongside .devin/rules/*.md) | Current workspace, subdirectories, and parent folders up to Git root | Each rule file is capped at 12,000 characters; supports all 4 activation modes. |
| 3. Legacy Workspace Root File | .windsurfrules (workspace root) | Entire repository as a single always-on markdown file | Imported for backward compatibility; lacks per-rule activation triggers. |
| 4. Global User Rules | ~/.codeium/windsurf/memories/global_rules.md (or ~/.devin/global_rules.md) | Every project on the local machine; not committed to Git | When both .devin/global_rules.md and .windsurf/global_rules.md exist, only .devin/global_rules.md loads. |
Enterprise system rules merge with workspace and global rules as read-only "System" entries in Cascade. For personal defaults, Windsurf reads ~/.codeium/windsurf/memories/global_rules.md; if migrating to Devin Desktop and both .devin/global_rules.md and .windsurf/global_rules.md exist, only .devin/global_rules.md loads.
Why Do the 12,000-Character Rule Limit and Context Caps Matter?
Windsurf caps each rule file in .windsurf/rules/*.md at 12,000 characters, and every always_on rule consumes prompt tokens on every turn. Oversized rules risk hitting that cap and diluting attention even before truncation occurs.
The Windsurf Memories & Rules docs state verbatim: “Rules files are limited to 12000 characters each.” and “Keep rules simple, concise, and specific. Rules that are too long or vague may confuse Cascade.” Similarly, the Devin CLI Rules guide advises: “Rules and AGENTS should be kept as small as possible.”
Across a 30-turn trajectory (within Cascade's default limit of 40 tool invocations per prompt), four always_on files totaling 10,000 characters (~2,500 tokens) burn 75,000 cumulative tokens. Keeping one 1,200-character always_on core file (~300 tokens) and moving framework rules to glob or model_decision cuts baseline rule overhead by more than 80%. Compare these mechanics in our guides on Windsurf Cascade rules vs. Claude Code skills and Windsurf, Cursor, and Claude Code formats.
Step-by-Step Setup: Authoring Modular .windsurf/rules/*.md Files With Frontmatter
Migrating from .windsurfrules to .windsurf/rules/ takes five steps: create the directory, keep one lean always_on file, assign glob and model_decision to domain rules, mark runbooks manual, and remove duplicate root rules.
- Initialize the folder: Create
.windsurf/rules/at the Git root (or inside package subdirectories). - Cap core invariants: Keep
00-core-stack.md(trigger: always_on) under 1,500 characters using XML grouping tags. - Scope path rules with
glob: Target test, UI, and API rules to explicitglobspatterns. - Scope workflows with
model_decisionandmanual: Write specificdescriptiontriggers for dynamic loading, and reservemanualfor@rule-namerunbooks. - Prune legacy
.windsurfrules: Delete migrated sections from root.windsurfrulesto eliminate duplicate context injection.
# .windsurf/rules/00-core-stack.md
---
trigger: always_on
---
<project_invariants>
- Package manager: Use pnpm exclusively; never run npm or yarn.
- TypeScript: Strict mode enabled; prohibit "any" and non-null assertions.
- Verification: Run "pnpm lint && pnpm test --run" before finishing edits.
</project_invariants>
# .windsurf/rules/vitest-testing.md
---
trigger: glob
globs: "**/*.test.ts,**/*.test.tsx"
---
All unit test files must use explicit `describe` / `it` blocks, avoid shared mutable state between specs, and mock outbound HTTP calls.
# .windsurf/rules/db-migrations.md
---
trigger: model_decision
description: Apply when designing database schema changes, Prisma migrations, SQL indexes, or backfill scripts.
---
- Always create reversible SQL migrations via "pnpm prisma migrate dev --create-only" and inspect locks on tables over 1M rows.
- Never run "prisma migrate reset" against staging or production databases.
# .windsurf/rules/release-checklist.md
---
trigger: manual
---
Run full pre-release audit: verify changelog entries, check environment variable parity, run production build, and tag release commit.Notice the XML tags (<project_invariants>) inside the core rule—the Windsurf Cascade documentation explicitly recommends XML tags alongside bulleted lists to group related constraints cleanly for the model.
The Sprawl Moment: When Carefully Tuned Windsurf Rules Stay Behind on One Machine
You spend two weeks refining eight .windsurf/rules/*.md files across your primary laptop—dialing in exact glob filters for Next.js App Router handlers, a model_decision SQL migration guardrail, and a manual release checklist you summon with @release-checklist. Half of those rules live inside a private client repo you cannot fork, and your personal preferences sit in ~/.codeium/windsurf/memories/global_rules.md on your desk MacBook. On Friday night, a staging outage hits while you are traveling with a spare laptop and debugging over SSH in Claude Code and Codex CLI. You ask the terminal agent to patch a failing migration, and it immediately suggests an unsafe table-locking command—because your tuned rules never left your other machine, and Windsurf's directory format means nothing to your terminal agents.
Prompttly is a skill manager for AI agents — one library for your skills and prompts that syncs into Claude Code, Codex, ChatGPT, and Claude and is one hotkey away on your Mac, so your setup follows you across every machine, repo, and tool.
Instead of rebuilding your rule directory whenever you switch laptops or drop into a different IDE or browser chat, Prompttly keeps one versioned library of your prompts and skills, synchronizes native skill folders to Claude Code and Codex on macOS, exposes write-capable MCP access to connected agents, and gives you a sub-200ms Mac hotkey palette to insert any rule or checklist into Windsurf, Cursor, or any desktop app without copy-paste.
Can You Sync .windsurf/rules With Claude Code, Cursor, and Codex Without Drift?
Yes—you can keep Windsurf .windsurf/rules/*.md files aligned with Cursor, Claude Code, and OpenAI Codex CLI by treating universal AGENTS.md or a centralized skill library as the single source of truth and mapping each tool's trigger metadata cleanly. Attempting to edit four native formats independently guarantees instruction divergence within days.
| AI Coding Tool | Native Rules / Skills Path | Trigger / Scoping Mechanism | Documented Cap |
|---|---|---|---|
| Windsurf / Devin Desktop | .windsurf/rules/*.md & ~/.codeium/windsurf/memories/global_rules.md | YAML trigger (always_on, glob, model_decision, manual) | 12,000 characters per rule file |
| Cursor IDE | .cursor/rules/*.mdc & AGENTS.md | YAML alwaysApply, globs, and description | Modular .mdc files scoped by file path |
| Anthropic Claude Code | ~/.claude/skills/<name>/SKILL.md & .claude/skills/ | YAML name, description, and paths frontmatter | Keep SKILL.md under 500 lines; 1% context window listing budget |
| OpenAI Codex CLI | AGENTS.md, AGENTS.override.md & ~/.codex/skills/ | Root-to-cwd AGENTS.md merge + skill frontmatter | 32 KiB (32,768 bytes) project_doc_max_bytes default cap |
Every major coding agent converges on the same architectural split: thin always-on project guardrails plus lazy-loaded task playbooks. In Cursor Rules, project rules live in .cursor/rules/*.mdc with alwaysApply and globs. In Anthropic Claude Code Skills, reusable workflows live in SKILL.md under 500 lines with a 1% context window listing budget. Across Windsurf, Cursor, Codex, and Antigravity, universal AGENTS.md files cover shared repository invariants while a skill manager like Prompttly synchronizes portable playbooks across machines.
You can also check how Cursor's MDC rules compare directly to Windsurf's format in our Cursor Rules vs. Windsurf Cascade Rules migration guide. If you want to author clean, spec-compliant frontmatter for portable workflows, try our free Claude Skill Creator.
Common Activation Mode Mistakes and How to Debug Ignored Rules
Most “ignored” rules inside .windsurf/rules/ stem from four predictable errors: exceeding the 12,000-character limit, leaving description vague on model_decision files, mis-formatting globs patterns, or shadowing global rules after a Devin Desktop migration. Checking these four items resolves nearly every rule-loading failure in under two minutes.
- When NOT to use
always_on: Never assigntrigger: always_onto language-specific style guides, migration playbooks, or prompt templates exceeding 1,500 characters. When five or six verbose files runalways_on, Cascade's system prefix crowds out active code context and weakens adherence to every rule in the stack. - Vague
model_decisiondescriptions: Writingdescription: "Helpful coding tips"gives Cascade no signal for dynamic retrieval. Write explicit trigger conditions such as"Apply when modifying Prisma schemas, PostgreSQL indexes, or database seed scripts." - Character overflow over 12,000 characters: Because Windsurf caps each rule file at 12,000 characters, oversized files copied from monolithic
.windsurfrulesdocuments fail to load cleanly. Split large guides into focused files by subsystem or move multi-step scripts into skills. - Shadowed
global_rules.mdduring Devin migration: If a workspace or home folder contains both.devin/global_rules.mdand.windsurf/global_rules.md, Devin Desktop loads only.devin/global_rules.md. Consolidate global rules into one canonical file so updates never vanish silently.
Frequently Asked Questions: Windsurf Rules Directory and Activation Modes
Where does Windsurf store workspace and global rules?
Windsurf stores modular workspace rules in .windsurf/rules/*.md across your project, subdirectories, and parent folders up to the Git root. Global rules live in ~/.codeium/windsurf/memories/global_rules.md, while Devin Desktop also reads .devin/rules/*.md and ~/.devin/global_rules.md.
What are the four activation modes in .windsurf/rules/*.md?
Windsurf supports four YAML trigger modes: always_on (every session), glob (matching file paths), model_decision (loaded when the agent matches your description), and manual (loaded only when referenced with @rule-name).
What is the maximum character limit for a Windsurf rule file?
Official Windsurf documentation caps each rule file at 12,000 characters. Splitting large rule sets by domain and using glob or model_decision triggers prevents silent truncation and context bloat.
Do .windsurf/rules/*.md files still work in Devin Desktop and Devin CLI?
Yes. Devin imports .windsurf/rules/*.md, .windsurf/global_rules.md, and .windsurfrules by default alongside .devin/rules/*.md, though .devin/global_rules.md takes precedence when both global_rules.md files exist.
How do you sync Windsurf rules with Claude Code, Cursor, and Codex?
Prompttly keeps one cloud library of your skills and rules, syncing native SKILL.md folders into Claude Code and Codex while providing sub-200ms Mac hotkey insertion across Windsurf, Cursor, and browser tools.
Explore the full catalog of multi-agent guides on the Prompttly resources hub.
Related Prompt Resources
Sync your Windsurf rules across every agent and laptop
Stop rewriting .windsurf/rules/*.md files into Cursor .mdc rules and Claude Code SKILL.md folders by hand. Keep one versioned skill library in Prompttly and reach any prompt in under 200ms with the Mac hotkey palette.