Skip to content

Conversation

@liwilliam2021
Copy link
Contributor

@liwilliam2021 liwilliam2021 commented Jul 18, 2025

Add magic rules generation feature for automated codebase analysis

  • Implement automated codebase analysis that generates mode-specific rules (general, code, architect, debug, docs-extractor)
  • Add rule type selection UI with descriptions for each mode's focus areas
  • Include .gitignore auto-integration option to prevent committing generated rules
  • Add auto-approval toggle for protected .roo directory file operations
  • Implement custom rules input field for project-specific instructions
  • Add small repository warning for projects with limited code examples
  • Support file overwrite detection and warnings for existing rule files

Feature Loom: https://www.loom.com/share/6dc1eae6a5774008be760b590091792e

Screenshot 2025-07-18 at 1 46 54 AM

Important

Introduces automatic generation of mode-specific rules with UI integration, configuration management, and comprehensive testing.

  • Behavior:
    • Implements automatic generation of mode-specific rules (general, code, architect, debug, docs-extractor) in generate-rules.ts.
    • Adds UI for rule type selection and descriptions in RulesSettings.tsx.
    • Supports .gitignore auto-integration and file overwrite warnings.
  • Settings and Configuration:
    • Updates global-settings.ts to include rulesSettings for storing rule generation preferences.
    • Adds RulesSettings component to ExperimentalSettings.tsx for managing rule generation settings.
  • Testing:
    • Adds tests for rule generation logic in generate-rules.test.ts and rulesGenerator.test.ts.
  • Misc:
    • Adds make-rules command to context menu in context-mentions.ts.
    • Updates i18n files for new rule generation strings.

This description was created by Ellipsis for bb59cf9. You can customize this summary. It will automatically update as commits are pushed.

@liwilliam2021 liwilliam2021 requested review from cte, jr and mrubens as code owners July 18, 2025 09:37
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request UI/UX UI/UX related or focused labels Jul 18, 2025
@delve-auditor
Copy link

delve-auditor bot commented Jul 18, 2025

No security or compliance issues detected. Reviewed everything up to a7e4e5b.

Security Overview
  • 🔎 Scanned files: 28 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@liwilliam2021 liwilliam2021 changed the title Automatic generation for rules file feat: Automatic generation for rules file Jul 18, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 18, 2025
@MuriloFP
Copy link
Contributor

Hey! I like this a lot, but I have a few questions:

  • Are we going to be able to edit the prompt for creating the rules? If so, how?
  • Does it detect our own custom modes if we want to create rules for them, or is it just for the default modes?

@daniel-lxs daniel-lxs moved this from Triage to PR [Changes Requested] in Roo Code Roadmap Jul 18, 2025
@hannesrudolph hannesrudolph added PR - Changes Requested and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 18, 2025
@liwilliam2021
Copy link
Contributor Author

Hey! I like this a lot, but I have a few questions:

  • Are we going to be able to edit the prompt for creating the rules? If so, how?
  • Does it detect our own custom modes if we want to create rules for them, or is it just for the default modes?

Those are some great thoughts! The PR was getting a little big, so I was thinking off adding more of default modes stuff in a separate PR if you think that makes sense?

For editing the rule creation prompt-- that's a great idea! Maybe I could add a "preview task prompt" button that compiles an editable preview of the rule creation prompt. I wasn't that pressed about it for this PR bc we have the user input box + I think the idea for the rule generator is that you would only run it once per repo.

Another PR to build of this if we see rules taking off is making the magic rule generator additive instead of overriding!

alright if I just start with this for now?

@MuriloFP
Copy link
Contributor

Hey! I like this a lot, but I have a few questions:

  • Are we going to be able to edit the prompt for creating the rules? If so, how?
  • Does it detect our own custom modes if we want to create rules for them, or is it just for the default modes?

Those are some great thoughts! The PR was getting a little big, so I was thinking off adding more of default modes stuff in a separate PR if you think that makes sense?

For editing the rule creation prompt-- that's a great idea! Maybe I could add a "preview task prompt" button that compiles an editable preview of the rule creation prompt. I wasn't that pressed about it for this PR bc we have the user input box + I think the idea for the rule generator is that you would only run it once per repo.

Another PR to build of this if we see rules taking off is making the magic rule generator additive instead of overriding!

alright if I just start with this for now?

Sounds good!

@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Jul 18, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

I only saw one small detail with the UI:

Image

The space here looks a bit too large.

Also left another small suggestion, let me know what you think

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jul 21, 2025
Comment on lines +37 to +39
- Focus: ${rule.focus}${alwaysAllowWriteProtected ? "\n - The directory has already been created for you" : "\n - Create the necessary directories if they don't exist"}
- Always overwrite the existing file if it exists
- Use the \`write_to_file\` tool to save the content${alwaysAllowWriteProtected ? "\n - Note: Auto-approval for protected file writes is enabled, so you can write to .roo directories without manual approval" : "\n - Note: You will need to approve the creation of protected directories and files"}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the prompt need to know whether alwaysAllowWriteProtected is enabled? I wouldn't think so.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just read a little more. Zooming out I don't think this feature should be interacting with the alwaysAllowWriteProtected setting the way it is (or encouraging people to set it to true as part of this feature).

Comment on lines +70 to +79
general: {
path: ".roo/rules/coding-standards.md",
focus: "General coding standards that apply to all modes, including naming conventions, file organization, and general best practices",
analysisSteps: [
"Examine the project structure and file organization patterns",
"Identify naming conventions for files, functions, variables, and classes",
"Look for general coding patterns and conventions used throughout the codebase",
"Check for any existing documentation or README files that describe project standards",
],
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least in my testing this didn't seem to generate very useful rules. I think it might be worth tweaking the prompt, especially since this is the content that will end up in the system prompt for every one of the modes (including the custom modes). What do you think the most important information for the model to know is? What does Claude Code do?

"Examine test files to understand testing patterns and frameworks used",
"Look for error handling patterns and logging strategies",
"Identify code style preferences and import/export patterns",
"Check for TypeScript usage and type definition patterns if applicable",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typescript mention might be a little too specific?

Comment on lines +114 to +124
"docs-extractor": {
path: ".roo/rules-docs-extractor/documentation-rules.md",
focus: "Documentation extraction and formatting rules, including documentation style guides, API documentation patterns, and content organization",
analysisSteps: [
"Check for existing documentation files and their formats",
"Analyze code comments and documentation patterns",
"Look for API documentation tools or generators",
"Identify documentation structure and organization patterns",
"Check for examples or tutorials in the codebase",
],
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have this option - it's only applicable in the Roo Code repo

}
}

// Count all files in the workspace
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can use one of the existing ways of listing files in the workspace so the logic is consistent

exists?: boolean
}

export const RulesSettings = ({ className, hasUnsavedChanges, ...props }: RulesSettingsProps) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Product-wise, I kind of feel like it's more magical (and simpler) if we just have a single button to automatically generate rules and it's smart enough to generate relevant ones for the project. The user will always have the ability to decide which of the files to keep or not, and they'll likely have the option to approve each one as well with the default of auto-approving writes to protected files turned off (in this case seems reasonable to review the output).

I also think they can add to .gitignore later if they want, but in general I would think that the default should be that these rules files are not gitignored and that teams would collaborate on them to build up a collection of project-specific rules. So probably wouldn't have that setting in the UI/prompt either.

@mrubens
Copy link
Collaborator

mrubens commented Jul 22, 2025

Just finished reviewing. The more I think about it, I'm really interested in the angle where there's a single button that intelligently proposes a set of rules files that makes the modes all work better together in the project, and what the ideal prompt would be for that.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Jul 29, 2025
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jul 29, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 23, 2025
@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Changes Requested size:XXL This PR changes 1000+ lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants