-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
What specific problem does this solve?
Problem
RooCode currently injects all applicable rules into every chat session via the system prompt, regardless of relevance. This creates significant issues:
- Token waste: Irrelevant rules consume valuable context tokens
- Context pollution: Unrelated rules can mislead LLM responses
- Poor scalability: Rule overhead grows linearly with project complexity
- Limited rule depth: Users avoid detailed rules due to constant overhead
While custom modes exist for task specialization, creating modes for every variant (Next.js App Router vs Pages Router vs Flask backend, etc.) leads to mode proliferation. Similarly, different parts of a codebase need different rules without warranting separate modes.
Current Behavior
From the documentation:
"The system prompt is generated dynamically each time you interact with Roo, adapting to your current mode, available tools, and custom settings."
All applicable rules are combined and injected into every system prompt, whether relevant or not.
Proposed Feature: Smart Rules
Introduce intelligent rule injection that automatically determines which rules are relevant to the current task and includes only those in the chat context.
User Experience
Setup
Users can create "smart rules" with explicit context triggers alongside existing rules:
.roo/smart-rules/supabase.md
---
use-when: "interacting with Supabase client, database queries, or authentication"
---
Supabase Best Practices
When working with Supabase:
- Always use TypeScript for better type safety
Prefer RLS policies over client-side filtering
...
.roo/smart-rules/nextjs-app-router.md
---
use-when: "working with Next.js App Router, server components, or app directory structure"
---
# Next.js App Router Guidelines
For App Router development:
- Use server components by default
- Client components only when needed for interactivity
...
Rule Structure
Each smart rule includes:
- Context trigger: Explicit description of when to use this rule
- Rule content: The actual guidance/instructions
- Optional metadata: Priority, dependencies, etc.
Automatic Selection
When users interact with RooCode, the system:
- Analyzes the query against each rule's "use-when" criteria
- Selects relevant smart rules based on context matching
- Injects them alongside always-applied rules
- Optionally shows which rules were activated
Example Scenarios
| User Query | Smart Rules Applied | Trigger Match |
|---|---|---|
| "Set up Supabase auth in my Next.js app" | supabase.md, nextjs-app-router.md | "Supabase client/authentication" + "Next.js App Router" |
| "Write API documentation for this endpoint" | documentation-style.md | "API documentation" |
| "Debug this database query" | supabase.md, database-patterns.md | "database queries" |
Key Requirements
- Explicit Context Definition: Users define when each rule should apply
- Intelligent Matching: System matches user queries to rule contexts
- Seamless Integration: Works alongside existing rule system without breaking changes
- User Control: Configurable sensitivity and rule limits
- Transparency: Optional visibility into which rules were selected and why
- Global Support: Works at both project and global levels
- Rich Content: Enables detailed rules with examples since they're only used when relevant
Benefits
- Precise Context: User-defined triggers ensure rules apply exactly when intended
- Efficient Tokens: Dramatically reduce irrelevant rule overhead
- Detailed Guidance: Enable rich, "few-shot" example-heavy rules without excessive token cost
- Clear Intent: Explicit "use-when" criteria make rule purpose transparent
- Better Responses: Focused, relevant guidance without conflicting instructions
- Scalable Management: Support extensive rule libraries with predictable activation
- I've searched existing Issues and Discussions for duplicates
- This describes a specific problem with clear impact and context
- Yes, I'd like to help implement this feature
- I understand this needs approval before implementation begins
This feature would enable precise, contextually-intelligent rule management with user-controlled activation criteria, allowing rich guidance libraries while keeping conversations focused and efficient.
Additional context (optional)
No response
Roo Code Task Links (Optional)
No response
Request checklist
Interested in implementing this?
Implementation requirements
How should this be solved? (REQUIRED if contributing, optional otherwise)
No response
How will we know it works? (Acceptance Criteria - REQUIRED if contributing, optional otherwise)
No response
Technical considerations (REQUIRED if contributing, optional otherwise)
No response
Trade-offs and risks (REQUIRED if contributing, optional otherwise)
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status