- Follow your team’s coding standards (naming conventions, file organization, error handling patterns)
- Understand project-specific context (tech stack, architecture decisions, dependencies)
- Apply consistent documentation or testing requirements
- Remember constraints like “don’t modify files in /legacy” or “always use TypeScript”
Supported Rule Types
Cline recognizes rules from multiple sources, so you can use existing rule files from other tools:| Rule Type | Location | Description |
|---|---|---|
| Cline Rules | .clinerules/ | Primary rule format |
| Cursor Rules | .cursorrules | Automatically detected |
| Windsurf Rules | .windsurfrules | Automatically detected |
| AGENTS.md | AGENTS.md | Standard format for cross-tool compatibility |
Where Rules Live
Rules can be stored in two locations: your project workspace or globally on your system. Workspace rules go in.clinerules/ at your project root. Use these for team standards, project-specific constraints, and anything you want to share with collaborators via version control.
Global rules go in your system’s Cline Rules directory. Use these for personal preferences that apply across all projects.
.md and .txt files inside .clinerules/, combining them into a unified set of rules. Numeric prefixes (like 01-coding.md) help organize files but are optional.
When both workspace and global rules exist, Cline combines them. Workspace rules take precedence when they conflict with global rules. See Storage Locations for more guidance.
Global Rules Directory
| Operating System | Default Location |
|---|---|
| Windows | Documents\Cline\Rules |
| macOS | ~/Documents/Cline/Rules |
| Linux/WSL | ~/Documents/Cline/Rules |
Linux/WSL users: If you don’t find global rules in
~/Documents/Cline/Rules, check ~/Cline/Rules.Creating Rules
Open the Rules menu
Click the scale icon at the bottom of the Cline panel, to the left of the model selector.
Create a new rule file
Click “New rule file…” and enter a filename (e.g.,
coding-standards). The file will be created with a .md extension./newrule slash command to have Cline create a rule interactively.
Toggling Rules
Every rule has a toggle to enable or disable it. This gives you fine-grained control over which rules apply to your current task without deleting the rule file. For example, you might have a strict testing rule that you want to disable when prototyping, or a client-specific rule you only need when working on that client’s features.Writing Effective Rules
Structure
Rules work best when they’re scannable and specific. Use markdown structure to organize instructions:Best Practices
Be specific, not vague. “Use descriptive variable names” is too broad. “Use camelCase for variables, PascalCase for classes, UPPER_SNAKE for constants” gives Cline something concrete to follow. Include the why. When a rule might seem arbitrary, explain the reason. “Don’t modify files in /legacy (this code is scheduled for removal in Q2)” helps Cline make better decisions in edge cases. Point to examples. If your codebase already demonstrates the pattern you want, reference it. “Follow the error handling pattern in /src/utils/errors.ts” is more effective than describing the pattern from scratch. Keep rules current. Outdated rules confuse Cline and waste context. If a constraint no longer applies, remove it. If your tech stack changes, update the rules. One concern per file. Split rules by topic:coding.md for style, testing.md for test requirements, architecture.md for structural decisions. This makes it easy to toggle specific rules on or off.
Example
Conditional Rules
Conditional rules let you scope rules to specific parts of your codebase. Rules activate only when you’re working with matching files, keeping your context focused and relevant.- Without conditionals: every rule loads for every request.
- With conditionals, rules activate only when your current files match their defined scope.
How It Works
Conditional rules use YAML frontmatter at the top of your rule files. When Cline processes a request, it gathers context from your current work (open files, visible tabs, mentioned paths, edited files), evaluates each rule’s conditions, and activates matching rules.When a conditional rule activates, you’ll see a notification: “Conditional rules applied: workspace:frontend-rules.md”
Writing Conditional Rules
Add YAML frontmatter to the top of any rule file in your.clinerules/ directory:
--- markers delimit the frontmatter. Everything after the closing --- is your rule content.
The paths Conditional
Currently, paths is the supported conditional. It takes an array of glob patterns:
*matches any characters except/**matches any characters including/(recursive)?matches a single character[abc]matches any character in the brackets{a,b}matches either pattern
| Pattern | Matches |
|---|---|
src/**/*.ts | All TypeScript files under src/ |
*.md | Markdown files in root only |
**/*.test.ts | Test files anywhere in the project |
packages/{web,api}/** | Files in web or api packages |
src/components/*.tsx | TSX files directly in components (not nested) |
Behavior Details
Multiple patterns: A rule activates if any pattern matches any file in your context.paths: [] means the rule never activates. Use this to temporarily disable a rule.
Invalid YAML: If frontmatter can’t be parsed, Cline fails open. The rule activates with raw content visible to help debugging.
What Counts as “Current Context”
Cline evaluates rules based on:- Your message: File paths mentioned in your prompt (e.g., “update
src/App.tsx”) - Open tabs: Files currently open in your editor
- Visible files: Files visible in your active editor panes
- Edited files: Files Cline has created, modified, or deleted during the task
- Pending operations: Files Cline is about to edit
Practical Examples
Copy these patterns and adapt them to your project structure.Frontend vs Backend Rules
Keep frontend and backend rules separate to avoid noise. Frontend rules only load when working with UI code, backend rules only load when working with API or service code.Test File Rules
Enforce testing standards automatically. This rule activates only when you’re writing or modifying tests, so testing guidance appears exactly when you need it.Documentation Rules
Apply documentation standards only when editing docs. Prevents style rules from cluttering your context when you’re writing code.Combining with Rule Toggles
Conditional rules work alongside the rule toggle UI. Toggle off a conditional rule to disable it entirely (it won’t activate even if paths match). Toggle on to let it activate when conditions are met. This provides two levels of control: manual toggles and automatic condition-based activation.Tips for Effective Conditional Rules
Start Broad, Then Narrow. Begin with broader patterns and refine as you learn what works:Troubleshooting Conditional Rules
Rule not activating:- Check that file paths in your context match the glob pattern
- Verify the rule is toggled on in the rules panel
- Ensure YAML frontmatter has proper
---delimiters
- Review glob patterns.
**is recursive and may match more than intended - Check for open files that match the pattern
- File paths mentioned in your message also count as context
- YAML couldn’t be parsed
- Check for syntax errors (unquoted special characters, improper indentation)

