Cline Rules Examples: 7 .clinerules Files to Copy (with paths Conditionals)
Cline reads Markdown rule files so you don't have to repeat "use pnpm, write a test, don't touch /legacy" at the start of every task. Rules without frontmatter are always on; rules with a paths list load only when you're working with matching files.
This page gives you seven rules to copy, free and without a signup. Everything here was checked on 2026-10-28 against the official Cline Rules docs. Cline changes often, so re-check anything you rely on.
Where the rules live
| Scope | Location | Notes |
|---|---|---|
| Workspace | .clinerules/*.md or .cline/rules/*.md at the project root |
Both are searched; the VS Code Rules panel creates new rules in .clinerules/ |
| Global (macOS, Linux, WSL) | ~/Documents/Cline/Rules |
Cline also checks ~/.cline/rules and ~/Cline/Rules |
| Global (Windows) | Documents\Cline\Rules |
Including OneDrive-redirected Documents folders |
| Cross-tool | AGENTS.md in the project, ~/.agents/AGENTS.md globally |
Shared with Codex, Cursor, Copilot and others |
| Other tools' files | .cursorrules, .windsurfrules |
Detected automatically |
Every detected rule shows up in the Rules panel (the scale icon at the bottom of the Cline panel) with its own on/off toggle. When workspace and global rules conflict, the workspace rule wins. Numeric prefixes like 01-coding.md only sort the files; they're optional.
1. Project basics (always on)
Save as .clinerules/01-project.md. No frontmatter means it loads on every request, so keep it short.
# Project basics
- Stack: Next.js 15, TypeScript strict, pnpm. Never use npm or yarn.
- Run `pnpm lint && pnpm test` before saying a task is done.
- Don't edit anything in `/legacy` (scheduled for removal; changes will be lost).
- Don't add a dependency without asking first.
- Follow the error pattern in `src/lib/errors.ts`.
2. Frontend only (conditional)
Save as .clinerules/frontend.md. It loads when a file under these folders is in context.
---
paths:
- "src/components/**"
- "src/app/**"
- "src/hooks/**"
---
# Frontend
- Functional components and hooks only.
- Style with Tailwind classes; no new CSS files.
- Keep client components small; fetch data in server components.
- Every interactive element needs an accessible name.
3. Backend and database (conditional)
Save as .clinerules/backend.md.
---
paths:
- "src/api/**"
- "src/server/**"
- "src/db/**"
---
# Backend
- All queries go through `src/db/repositories/`; no raw SQL in route handlers.
- Validate every request body with the zod schemas in `src/api/schemas/`.
- Return typed errors from services; only route handlers turn them into HTTP codes.
- New tables need a migration in `src/db/migrations/`; never edit an old one.
4. Tests (conditional)
Save as .clinerules/testing.md.
---
paths:
- "**/*.test.ts"
- "**/*.spec.ts"
- "**/__tests__/**"
---
# Tests
- Name tests "should <behavior> when <condition>".
- Mock network and third-party SDKs, not our own modules.
- Build test data with the factories in `test/factories/`.
- Run only the changed test file first: `pnpm vitest run <path>`.
5. Docs (conditional)
Save as .clinerules/docs.md.
---
paths:
- "docs/**"
- "**/*.mdx"
---
# Docs
- Sentence-case headings.
- Every feature page has a runnable code example.
- Paragraphs of four sentences or fewer.
- Update `docs/changelog.md` when behavior changes.
6. Monorepo packages (conditional, brace pattern)
Save as .clinerules/packages-web-api.md. {a,b} matches either name.
---
paths:
- "packages/{web,api}/**"
---
# web and api packages
- Shared types live in `packages/types`; import from there, never copy them.
- Run commands from the package folder: `pnpm --filter web test`.
7. Personal global rule
Save in your global folder, for example ~/Documents/Cline/Rules/me.md. It applies to every project, and any workspace rule overrides it.
# My preferences
- Explain the plan in three bullets before editing more than two files.
- Prefer small commits with conventional commit messages.
- Ask before running anything that deletes files or touches git history.
How conditional rules decide to load
Cline compares each rule's paths globs with the files in the current context: paths you mention in your message, open tabs, visible editor panes, files Cline has edited in the task, and files it's about to edit. A rule loads if any pattern matches any of those files, and it can switch on mid-task. When it does, Cline shows "Conditional rules applied" with the file name.
| Pattern | Matches |
|---|---|
src/**/*.ts |
All TypeScript files under src/ |
*.md |
Markdown files in the root only |
**/*.test.ts |
Test files anywhere |
packages/{web,api}/** |
Files in the web or api package |
src/components/*.tsx |
TSX files directly in components, not nested |
Two handy tricks from the docs: paths: [] turns a rule off without deleting it, and a throwaway rule whose body is just TEST: this rule should activate tells you whether a pattern matches.
Why Cline ignores a rule
- The toggle is off. Check the Rules panel; a disabled rule never loads, even if its paths match.
- No matching file in context. "Update the user service" may not trigger a path rule; "update
src/services/user.ts" will. Name the file. - Broken frontmatter. The opening
---must be the first line. If the YAML can't be parsed, Cline fails open: the rule loads with the raw frontmatter visible, which is your hint to fix it. - The glob is too narrow or too wide.
*stops at/;**crosses folders and can match more than you meant. - Vague wording. "Use good names" changes nothing; "camelCase variables, PascalCase classes" does.
- Too much text. Rules cost context tokens on every request they load for. Link to long style guides instead of pasting them.
Cline and AGENTS.md
Cline reads AGENTS.md and ~/.agents/AGENTS.md, and picks up .cursorrules and .windsurfrules. If your team already keeps an AGENTS.md for Codex, Cursor or Copilot, Cline uses it too, so put only Cline-specific or path-scoped rules in .clinerules/ and avoid sending the same instruction twice. See our AGENTS.md examples, Cursor rules examples and GEMINI.md examples.
FAQ
.clinerules/ or .cline/rules/? Either. Both are searched, so don't copy rules into both. The Rules panel creates new files in .clinerules/.
Can Cline write a rule for me? Yes, type /newrule and it creates one interactively.
Do rules without frontmatter still work? Yes, they're always active.
Get matching files for every tool
The free AGENTS.md generator builds AGENTS.md, CLAUDE.md, GEMINI.md, Cursor, Copilot and Kiro files in your browser from your package.json or pyproject.toml, and Cline reads AGENTS.md too. The AI Coding Agent Config Kit adds stack templates and prompts that audit and test them.
AI Coding Agent Config Kit
Instruction-file templates for 12 stacks and 12 prompts that write and audit them. 34-page PDF, $14.
Not ready to buy? Start with the free PDF.
Get 10 of our most-used prompts as a free PDF from Gumroad. You will be asked for your email so Gumroad can deliver it.