- Manual Repository Rules - configured through the web interface
- Automatic Rule File Detection - automatically discovered from your repository files

Update repo rules at codegen.com/repos
How Repository Rules Work
When an agent is assigned a task on a repository with defined rules, those rules are automatically prepended or made available to the LLM as part of its context. This means the agent “sees” these rules alongside the actual task or prompt it receives. For example, if you have a rule like “Always use tabs for indentation,” the agent will be reminded of this preference before it starts writing or modifying code in that repository.Accessing and Configuring Repository Rules
You can typically find and configure Repository Rules within the settings page for each specific repository in the Codegen web UI.- Navigate to codegen.com/repos.
- Select the repository for which you want to set rules.
- Look for a section titled “Repository rules” or similar in the repository’s settings.

Update repo rules at codegen.com/repos
Automatic Rule File Detection
In addition to manual repository rules, Codegen automatically discovers and includes agent rule files from your repository when the agent starts working on it. This happens automatically whenever theset_active_codebase
tool is used.
Supported Rule File Patterns
Codegen automatically searches for the following types of rule files in your repository:.cursorrules
- Cursor AI editor rules.clinerules
- Cline AI assistant rules.windsurfrules
- Windsurf AI editor rules**/*.mdc
- Markdown files with.mdc
extension anywhere in the repository.cursor/rules/**/*.mdc
- Markdown files in the.cursor/rules/
directory structureCLAUDE.md
,AGENTS.md
,AGENT.md
- top-level docs commonly used to instruct AI agents
How Automatic Detection Works
- File Discovery: When you switch to a repository, Codegen uses
ripgrep
to search for files matching the supported patterns - Content Extraction: The content of discovered files is read and processed
- New: The content is encoded to preserve formatting during transport, then decoded before being presented to the agent
- Size Limitation (25k global budget): All rule files combined are truncated to fit within a 25,000 character global budget to ensure optimal performance
- Context Integration: The rule content is automatically included in the agent’s context alongside any manual repository rules
Example Rule Files
Here are examples of how you might structure automatic rule files in your repository:.cursorrules
example:
.cursor/rules/backend.mdc
example:
Visibility in UI
When rules are discovered, they are displayed in the AgentTrace under theSetActiveCodebase
tool card as “Repository Rules (Filesystem)”. You can expand each entry to preview the content and open the source file on GitHub.
Benefits of Automatic Rule Files
- Version Control: Rule files are committed with your code, ensuring consistency across team members
- Repository-Specific: Different repositories can have different rule files without manual configuration
- Developer-Friendly: Developers can manage rules using familiar file-based workflows
- Editor Integration: Many AI-powered editors already support these file formats
Automatic rule files work alongside manual repository rules. Both types of rules are combined and provided to the agent for maximum context.
If your rule files exceed the global 25,000 character budget, they will be truncated per-file and/or at the aggregate level. Keep rule files concise or split them into focused files.
Common Use Cases and Examples
Repository rules are flexible and can be used for various purposes:- Enforcing Linting/Formatting:
- “Remember to run the linter with
npm run lint
before committing.” - “Ensure all Python code follows PEP 8 guidelines. Use
black
for formatting.”
- “Remember to run the linter with
- Specifying Commit Message Conventions:
- “All commit messages must follow the Conventional Commits specification.”
- “Prefix commit messages with the related Linear issue ID (e.g.,
ENG-123: ...
).”
- Highlighting Project-Specific Information:
- “This repository uses TypeScript. All new backend code should be in the
/server/src
directory.” - “Avoid using deprecated function
old_function()
. Usenew_function()
instead.”
- “This repository uses TypeScript. All new backend code should be in the
- Code Style Preferences:
- “Don’t write super long strings, as this will break pre-commit. Do triple-quoted strings with newlines, non-indented, instead!” (As seen in your example image)
- “Prefer functional components over class components in React.”
- Reminders for Testing:
- “Ensure all new features have corresponding unit tests.”
- “Run integration tests with
npm run test:integration
after significant changes.”
Keep your repository rules concise and clear. Overly complex or numerous rules
might confuse the agent or lead to suboptimal performance. Focus on the most
critical guidelines for each repository.
Both manual repository rules and automatic rule files are applied in addition to any global prompting strategies or agent capabilities. They provide a repository-specific layer of instruction that helps ensure consistent behavior across your codebase.