Repository Rules
Repository rules allow you to define specific instructions that Codegen will follow when working with your codebase. These rules can help ensure that Codegen adheres to your team’s coding standards, follows project-specific conventions, or handles certain files in specific ways.Overview
Repository rules are custom instructions written in markdown format that guide Codegen’s behavior when interacting with your repository. These rules can be defined in two ways:- Through the Codegen web interface - Configure rules in your repository settings
- Using rule files in your repository - Create special files that Codegen automatically detects
Configuring Rules via Web Interface
The simplest way to configure repository rules is through the Codegen web interface:- Log in to your Codegen account at codegen.sh
- Navigate to Repositories in the sidebar
- Select the repository you want to configure
- In the repository settings page, find the Repository rules section
- Enter your rules in markdown format in the text area
- Click Save to apply your changes
Configuring Rules via Files
Alternatively, you can define rules directly in your repository using special files. Codegen automatically detects and follows rules defined in these files:.cursorrules- A file at the root of your repository.clinerules- A file at the root of your repository.windsurfrules- A file at the root of your repository.cursor/rules/**/*.mdc- Any.mdcfiles in the.cursor/rulesdirectory**/*.mdc- Any.mdcfiles anywhere in your repository
Example: Creating Rules in .cursor/rules
- Create a
.cursor/rulesdirectory in your repository:
- Create a new file with your rules, for example
.cursor/rules/coding-standards.mdc:
- Commit and push these changes to your repository
Rule Format and Examples
Repository rules are written in markdown format, which allows for rich formatting and structure. Here are some examples of effective repository rules:Example 1: General Development Guidelines
Example 2: Project-Specific Instructions
Example 3: Task Approach Template
Best Practices
To get the most out of repository rules, follow these best practices:- Be specific and clear - Write rules that are specific, clear, and actionable
- Organize rules logically - Group related rules together and use headings to create a clear structure
- Focus on what matters - Include rules that are important for your project and team
- Keep rules up to date - Regularly review and update your rules as your project evolves
- Use examples - Include examples to illustrate how rules should be applied
- Explain the why - Explain why rules exist to help Codegen understand their importance
Rule Precedence
If you define rules in multiple places, Codegen follows this precedence order:- Rules defined in the web interface
- Rules defined in repository files (
.cursorrules,.clinerules,.windsurfrules) - Rules defined in
.cursor/rules/**/*.mdcfiles - Rules defined in other
.mdcfiles
Troubleshooting
If Codegen is not following your repository rules as expected, check the following:- Rule format - Ensure your rules are written in valid markdown format
- Rule location - Verify that your rule files are in the correct location
- Rule content - Make sure your rules are clear, specific, and actionable
- Rule conflicts - Check for conflicting rules in different locations
- Rule updates - Ensure you’ve saved your changes in the web interface or committed and pushed your file changes