Skip to content

Commit c21c726

Browse files
docs: update Repo Rules docs for automatic rule files + 25k budget + AgentTrace visibility (#1185)
Co-authored-by: Jay Hack <[email protected]> Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
1 parent a72fb96 commit c21c726

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

docs/settings/repo-rules.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ Codegen automatically searches for the following types of rule files in your rep
4747
- **`.windsurfrules`** - Windsurf AI editor rules
4848
- **`**/*.mdc`** - Markdown files with `.mdc` extension anywhere in the repository
4949
- **`.cursor/rules/**/*.mdc`** - Markdown files in the `.cursor/rules/` directory structure
50+
- **`CLAUDE.md`**, **`AGENTS.md`**, **`AGENT.md`** - top-level docs commonly used to instruct AI agents
5051

5152
### How Automatic Detection Works
5253

5354
1. **File Discovery**: When you switch to a repository, Codegen uses `ripgrep` to search for files matching the supported patterns
5455
2. **Content Extraction**: The content of discovered files is read and processed
55-
3. **Size Limitation**: All rule files combined are truncated to fit within 3,000 characters total to ensure optimal performance
56+
- **New**: The content is encoded to preserve formatting during transport, then decoded before being presented to the agent
57+
3. **Size Limitation (25k global budget)**: All rule files combined are truncated to fit within a 25,000 character global budget to ensure optimal performance
5658
4. **Context Integration**: The rule content is automatically included in the agent's context alongside any manual repository rules
5759

5860
### Example Rule Files
@@ -82,6 +84,10 @@ Prefer functional components over class components in React
8284
- Include request/response validation
8385
```
8486

87+
### Visibility in UI
88+
89+
When rules are discovered, they are displayed in the AgentTrace under the `SetActiveCodebase` tool card as "Repository Rules (Filesystem)". You can expand each entry to preview the content and open the source file on GitHub.
90+
8591
### Benefits of Automatic Rule Files
8692

8793
- **Version Control**: Rule files are committed with your code, ensuring consistency across team members
@@ -94,7 +100,7 @@ Prefer functional components over class components in React
94100
</Tip>
95101

96102
<Warning>
97-
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.
103+
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.
98104
</Warning>
99105

100106
## Common Use Cases and Examples

docs/settings/repo-rules.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,40 @@ When an agent is assigned a task on a repository with defined rules, those rules
1414

1515
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.
1616

17+
## Automatic Rule File Detection
18+
19+
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 discovery happens whenever the `set_active_codebase` tool initializes work on a repo.
20+
21+
### Supported Rule File Patterns
22+
23+
Codegen searches for the following patterns:
24+
25+
- **`.cursorrules`** (Cursor)
26+
- **`.clinerules`** (Cline)
27+
- **`.windsurfrules`** (Windsurf)
28+
- **`**/*.mdc`** (any `.mdc` file in the repo)
29+
- **`.cursor/rules/**/*.mdc`** (files under `.cursor/rules/`)
30+
- **`CLAUDE.md`**, **`AGENTS.md`**, **`AGENT.md`** (top-level agent instruction docs)
31+
32+
### How it works
33+
34+
1. Discovery via `ripgrep`
35+
2. Content is read and encoded to preserve formatting during transport, then decoded
36+
3. A global size budget of **25,000 characters** is enforced across all discovered files
37+
4. The resulting content is combined with your manual Repository Rules and provided to the agent
38+
39+
### Visibility in the UI
40+
41+
Discovered rule files are rendered in AgentTrace under the `SetActiveCodebase` tool card as "Repository Rules (Filesystem)". Expand entries to preview content and open the source on GitHub.
42+
43+
<Tip>
44+
Automatic rule files are merged with manual Repository Rules to give the agent repository-specific context.
45+
</Tip>
46+
47+
<Warning>
48+
If discovered rule files exceed the global 25,000 character budget, content will be truncated. Keep files concise or split by area of concern.
49+
</Warning>
50+
1751
## Accessing and Configuring Repository Rules
1852

1953
You can typically find and configure Repository Rules within the settings page for each specific repository in the Codegen web UI.

0 commit comments

Comments
 (0)