- Enforce team coding standards (naming conventions, file organization, error handling patterns)
- Capture project-specific context (tech stack, architecture decisions, constraints)
- Apply consistent documentation or testing requirements
- Set hard boundaries like “never modify files in
/legacy” or “always use TypeScript”
Supported rule formats
Cline recognizes rules from multiple sources, so you can reuse 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 with organization but are optional.
When both workspace and global rules exist, Cline combines them. Workspace rules take precedence when they conflict with global rules.
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 is created with a .md extension./newrule slash command to have Cline create a rule interactively based on your description.
Toggling rules
Every rule has a toggle to enable or disable it. This gives you fine-grained control without deleting the rule file — useful when you want to disable a strict testing rule during prototyping, or a client-specific rule you only need for 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. 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 rule files
Conditional rules
Conditional rules let you scope instructions to specific parts of your codebase. Rules activate only when you’re working with matching files, keeping 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:
| 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) |
paths: [] means the rule never activates — use this to temporarily disable a rule.
Practical examples
Frontend vs backend rules
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
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
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. This provides two levels of control: manual toggles and automatic condition-based activation.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)