Repository Rules in Codegen act as a persistent set of instructions or a “system prompt” for the AI agent whenever it operates on a specific repository. These rules guide the agent’s behavior by enforcing coding standards and repository-specific conventions through automated reminders to the language model (LLM) during each task.
Codegen supports two types of repository rules:
Update repo rules at codegen.com/repos
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.
You can typically find and configure Repository Rules within the settings page for each specific repository in the Codegen web UI.
Update repo rules at codegen.com/repos
In the text area provided (as shown in the image), you can specify any rules you want the agent to follow for this repository. Click “Save” to apply them.
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 the set_active_codebase
tool is used.
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 structureripgrep
to search for files matching the supported patternsHere are examples of how you might structure automatic rule files in your repository:
.cursorrules
example:
.cursor/rules/backend.mdc
example:
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 3,000 characters combined, they will be automatically truncated. Consider keeping rule files concise or splitting them into multiple focused files.
Repository rules are flexible and can be used for various purposes:
npm run lint
before committing.”black
for formatting.”ENG-123: ...
).”/server/src
directory.”old_function()
. Use new_function()
instead.”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.