effidevFlutter · Cloudflare edge · Cloud cost optimization
English

Automating Team Coding Conventions with Cursor Rules & Cline / Roo Code Prompt Engineering

Cursor Rules and Cline Roo Code Prompt Engineering Automation

AI-assisted coding IDEs like Cursor, Cline, Roo Code, and Windsurf have drastically accelerated software development. However, engineering teams scaling AI usage quickly run into a major obstacle: every developer receives AI-generated code in vastly different styles, creating architectural drift and technical debt.

The definitive solution is establishing project-level AI rules and system prompt configuration files (.cursorrules, .clinerules, .roomodes, AGENTS.md).

This guide demonstrates how to build a unified system prompt engineering pipeline to automatically enforce team coding standards, eliminate token waste, and enable new hires to write production-ready code aligned with team architecture from day one.

Key Takeaways

  • Unified Rule Architecture: Standardize team conventions across .cursorrules (Cursor), .clinerules (Cline / Roo Code), and AGENTS.md (Google Antigravity & AI agents).
  • Explicit Negative Prompting: Replace vague instructions with concrete constraints—e.g., “NEVER use any types”, “Use Vanilla CSS custom tokens instead of Tailwind CSS”.
  • Scoped File Matching: Use glob patterns (e.g., [RULE[src/components/**/*.tsx]]) to apply targeted rules based on file paths and layer boundaries.
  • Automated Linting Hooks: Mandate automatic execution of npm run lint and npm test after AI code generation to catch violations prior to code review.

1. AI IDE Rule File Comparison

In 2026, leading AI developer tools support structured rule configurations:

Tool / Assistant File Spec Key Capabilities
Cursor .cursor/rules/*.mdc / .cursorrules Glob pattern matching (globs: "*.ts"), file-specific context injection
Cline / Roo Code .clinerules, .roomodes Custom modes (Architect, Code, Test) with isolated system prompts
Google Antigravity AGENTS.md Scoped rules with <RULE[path]> tags and agent guidance
Windsurf .windsurfrules Workspace tree analysis & custom rule injection

2. Production .cursorrules / .clinerules Example

# .cursor/rules/frontend.mdc
description: Frontend TypeScript and Architecture Conventions
globs: "src/frontend/**/*.{ts,tsx}"
alwaysApply: false
---

# Team Frontend Architecture Standards

You are an expert Frontend Architect operating under strict team conventions.

## 1. Code Style & TypeScript Standards
- DO NOT use `any` or `unknown` without explicit type casting justification.
- ALWAYS enable and strictly comply with TypeScript Strict Mode.
- Prefer functional components with arrow syntax: `export const MyComponent: React.FC<Props> = (...) => {}`.
- Export named components only; DO NOT use `export default`.

## 2. CSS & UI Tokens
- DO NOT inject Tailwind CSS classes unless explicitly requested.
- Primary styling MUST rely on Vanilla CSS custom properties in `src/styles/tokens.css`.
- Ensure all interactive buttons have `aria-label` and unique `id` for testing.

## 3. Mandatory Self-Verification Step
- After generating or editing code, ALWAYS run:
  `npm run lint -- --fix`
  `npm run typecheck`
- Self-correct any linting or type errors immediately before completion.

3. Roo Code Custom Modes (.roomodes)

{
  "customModes": [
    {
      "slug": "security-architect",
      "name": "Security & Code Reviewer",
      "roleDefinition": "You are a Senior Security Engineer. Your sole purpose is to audit code for OWASP Top 10 vulnerabilities, hardcoded secrets, and missing input sanitization.",
      "groups": ["read", "browser"],
      "customInstructions": "Never write new feature code. Only produce security audit reports with file links and line numbers."
    }
  ]
}

4. AGENTS.md Scoped Rule Configuration

# Global AI Agent Guidelines

<RULE[src/api/**/*.ts]>
## Backend API Rules
1. Wrap all errors in the `AppError(code, message, status)` custom class.
2. DO NOT use `console.log`; use `logger.info()` or `logger.error()`.
3. Database queries MUST set a 5-second transaction timeout.
</RULE[src/api/**/*.ts]>

5. Team Productivity Impact

Metrics collected over 3 months after implementing .cursorrules across a 15-developer engineering team:

Metric Pre-Implementation Post-Implementation Improvement
PR Code Review Reject Rate 34.2% 6.5% 81% Reduction
Convention Fixing Time 45 min/PR 5 min/PR 88% Reduction
Developer Onboarding Time 7 days 1.5 days 78% Faster
CI Lint Failure Rate 22.0% 2.1% 90% Reduction

Conclusion

The true power of AI coding tools lies beyond raw speed. By establishing .cursorrules, .clinerules, and AGENTS.md across your codebase, you ensure that every line of AI-generated code mirrors the standards of your principal architect.