Firebase rules like Cursor rules
Okay, here is the detailed description of Cursor AI Rules in English:
"Cursor AI Rules" are configuration files that allow you to customize the behavior of the artificial intelligence within Cursor AI to your specific needs and projects. They enable you to set guidelines, constraints, and behavioral patterns for AI interactions.
There are different types of Cursor AI Rules:
- Global AI Rules (Settings):
These rules are configured in the Cursor settings under "General".
They establish fundamental principles for all AI interactions and are language-agnostic.
For example, you can specify that the AI should always explore the code first before reaching a conclusion, or that it should follow specific programming paradigms when generating code.
You can also set the language in which the AI should communicate with you.
2. Project-Wide Rules (.cursorrules or .cursor/rules/*.mdc):
These rules are defined either in a file named .cursorrules in the root directory of your project or in individual .mdc files within the .cursor/rules/ folder inside your project.
They apply only to the respective project and allow you to define project-specific conventions and requirements.
Here, you can specify, for example:
Which technologies and frameworks the project uses (e.g., "// This project uses React, TypeScript, and Tailwind CSS").
Which naming conventions should be used for files and variables (e.g., "// All component files should be named in PascalCase").
Which libraries should be preferred (e.g., "// Use the lodash library for utility functions").
Which patterns should be avoided (e.g., "// Avoid inline styles in React components").
Specific architectural patterns, code quality standards (e.g., RuboCop for Ruby), or testing requirements.
Using .mdc files in the .cursor/rules/ folder allows for better organization of rules by file type or directory.
3. Pattern-Specific Rules (.cursor/rules/*.mdc with Globs):
You can define rules that only apply to specific file patterns.
In the header of the .mdc file, you can use the keyword Globs: to specify which files or folders this rule should apply to (e.g., Globs: app/controllers/*/.rb for Ruby on Rails controller files).
How to Define Cursor Rules:
Global Rules: Go to Cursor Settings -> General and enter your rules in the "Rules for AI" text field.
Project-Wide Rules (.cursorrules): Create a file named .cursorrules in the root directory of your project and write your rules in this file. You can use plain text, JSON, or other formats that Cursor AI understands.
Project-Wide Rules (.cursor/rules/*.mdc):
Open Cursor.
Press Ctrl+Shift+P (or Cmd+Shift+P) to open the command palette.
Search for "File: New Cursor Rule" and select it.
Enter a name for your rule file (e.g., rails_controllers.mdc) and press Enter. The .cursor/rules/ folder will be created automatically if it doesn't already exist.
In the header of the file, you can add a Description: and use Globs: to specify which files the rule should apply to.
Below the header, you can define your specific rules.
Important Concepts:
Context-Aware Assistance: Cursor Rules help the AI better understand the context of your project and provide more relevant suggestions.
Consistency: By defining rules, you ensure that the generated code adheres to the standards and conventions of your project.
Flexibility: You can combine global, project-wide, and pattern-specific rules to precisely control the AI.
Agent Mode: In newer versions of Cursor AI, rules can be used in "Agent Mode" to give the AI specific instructions on how to act (e.g., "You are instructa, a senior Rails developer with superpowers!").
-
Yang Cheng commented
Important Concepts:
Context-Aware Assistance: Cursor Rules help the AI better understand the context of your project and provide more relevant suggestions.
Consistency: By defining rules, you ensure that the generated code adheres to the standards and conventions of your project.
Flexibility: You can combine global, project-wide, and pattern-specific rules to precisely control the AI.
Agent Mode: In newer versions of Cursor AI, rules can be used in "Agent Mode" to give the AI specific instructions on how to act (e.g., "You are instructa, a senior Rails developer with superpowers!").