# .clinerules — Project Behavior File for Cline AI Agent > .clinerules is Cline's per-project rules file, read every task. Steers code style, libraries, conventions without retyping context. Roo-compatible. ## Install Paste the prompt below into your AI tool: ## Quick Use 1. Copy the `.clinerules` template below 2. Save it (no extension) at your repo root 3. Open VS Code, start a new Cline task — rules load automatically --- ## Intro `.clinerules` is the persistent rules file Cline reads on every task. It steers Cline's coding style, library choices, and project conventions without re-typing context. Best for: teams standardizing how an AI agent writes code in their codebase. Works with: Cline (VS Code), Roo Code (compatible). Setup time: under 1 minute. --- ### Format Create `.clinerules` (no extension) in your repo root. Cline reads it as plain text and injects it into every task's system prompt. ```markdown # Project: Acme Web ## Code Style - TypeScript strict mode, no `any` - Functional components only, no class components - Prefer `async/await` over `.then()` chains ## Libraries - UI: shadcn/ui + Tailwind (no Material UI, no Bootstrap) - HTTP: native `fetch` (no axios) - Forms: React Hook Form + Zod - State: Zustand (no Redux) ## File Structure - Components in `src/components//` - Hooks in `src/hooks/` - API routes in `src/app/api/` ## Testing - Vitest, not Jest - Co-locate `*.test.ts` next to source - Mock at the network layer, not the function layer ## Don't - Don't add comments unless asked - Don't refactor unrelated code in the same PR - Don't add new dependencies without confirming ``` ### Per-folder rules You can also drop `.clinerules` in subdirectories. Cline reads the closest one to the file being edited: ``` src/ ├── .clinerules # frontend rules ├── components/ └── api/ └── .clinerules # backend-specific overrides ``` ### Plan / Act mode Cline supports a Plan / Act split — Plan reviews the rules file, asks clarifying questions, and proposes the change before any file is touched. Act executes. The rules file is read in both phases. --- ### FAQ **Q: Is .clinerules free?** A: Yes. The Cline VS Code extension itself is free and open-source (Apache-2.0). You bring your own LLM API key (Claude / OpenAI / OpenRouter / etc) and pay for inference. **Q: Will Roo Code read .clinerules?** A: Yes — Roo Code is a Cline fork and stays compatible with the .clinerules format. Same file, same behavior. **Q: How long can the rules file be?** A: Practically, keep it under ~500 lines. The file goes into every system prompt, so very long rules waste tokens on every task. Split per-folder or move long context into a referenced doc. --- ## Source & Thanks > Built by [Cline](https://github.com/cline). Licensed under Apache-2.0. > > [cline/cline](https://github.com/cline/cline) — ⭐ 50,000+ --- ## 快速使用 1. 复制下面的 `.clinerules` 模板 2. 保存到仓库根目录(无扩展名) 3. 在 VS Code 里启动新的 Cline 任务,规则自动加载 --- ## 简介 `.clinerules` 是 Cline 每次任务都会读的持久规则文件。不用重复打上下文就能引导 Cline 的代码风格、库选型、项目约定。适合团队统一 AI agent 在自己代码库里的写法。兼容 Cline(VS Code)和 Roo Code。装机时间 1 分钟。 --- ### 格式 在仓库根目录创建 `.clinerules`(无扩展名)。Cline 把它当纯文本读取,每次任务都会注入到系统 prompt。 ```markdown # Project: Acme Web ## Code Style - TypeScript strict 模式,禁用 `any` - 只用 functional 组件,禁用 class 组件 - 优先 `async/await`,避免 `.then()` 链 ## Libraries - UI:shadcn/ui + Tailwind(禁用 Material UI / Bootstrap) - HTTP:原生 `fetch`(不用 axios) - 表单:React Hook Form + Zod - 状态:Zustand(不用 Redux) ## 文件结构 - 组件放 `src/components//` - Hook 放 `src/hooks/` - API 路由放 `src/app/api/` ## 测试 - Vitest,不用 Jest - `*.test.ts` 跟源码同目录 - 在网络层 mock,不在函数层 mock ## 不要做的 - 没要求别加注释 - 同一个 PR 不要顺手重构无关代码 - 没确认前不要加新依赖 ``` ### 子目录规则 可以在子目录再放 `.clinerules`。Cline 会读距离被编辑文件最近的那一个: ``` src/ ├── .clinerules # 前端规则 ├── components/ └── api/ └── .clinerules # 后端专属覆盖 ``` ### Plan / Act 双模式 Cline 支持 Plan/Act 分离 —— Plan 阶段读规则文件、问澄清问题、提出方案,不动文件。Act 阶段才执行。两个阶段都会读规则文件。 --- ### FAQ **Q: .clinerules 免费吗?** A: 免费。Cline 这个 VS Code 扩展本身 Apache-2.0 开源。你用自己的 LLM API key(Claude / OpenAI / OpenRouter 等),按推理量付费。 **Q: Roo Code 能读 .clinerules 吗?** A: 能。Roo Code 是 Cline 的 fork,保持 .clinerules 格式兼容。同一份文件,行为一致。 **Q: 规则文件能多长?** A: 实操上控制在 500 行以内。这文件每次任务都进系统 prompt,太长会持续浪费 token。可以按目录拆分,或者把长上下文移到引用文档里。 --- ## 来源与感谢 > Built by [Cline](https://github.com/cline). Licensed under Apache-2.0. > > [cline/cline](https://github.com/cline/cline) — ⭐ 50,000+ --- Source: https://tokrepo.com/en/workflows/clinerules-project-behavior-file-for-cline-ai-agent Author: Cline