feat(dna): auto-detect team rules from CLAUDE.md and similar files#244
Conversation
- Add RULES_FILES constant with priority order: CLAUDE.md, .cursorrules, .codeintel/rules.md, CONVENTIONS.md, .github/copilot-instructions.md, CODING_GUIDELINES.md - Add team_rules and team_rules_source fields to CodebaseDNA - Add Team Rules section to DNA markdown output - First found file wins (priority order) Now any AI using get_codebase_dna via MCP automatically gets the team's explicit coding rules without extra configuration.
|
@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryAdds automatic detection of team convention files (CLAUDE.md, .cursorrules, etc.) to the DNA extraction process, making team-specific coding rules available to AI assistants without manual intervention. Key Changes:
Issues Found:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| backend/services/dna_extractor.py | Added team rules detection from convention files (CLAUDE.md, .cursorrules, etc.) with priority-based file discovery. One missing field in cache reconstruction logic. |
Flowchart
flowchart TD
A[extract_dna called] --> B[Discover files]
B --> C[Extract patterns]
C --> D[_extract_team_rules]
D --> E{Check CLAUDE.md}
E -->|exists| F[Read & return]
E -->|not found| G{Check .cursorrules}
G -->|exists| F
G -->|not found| H{Check .codeintel/rules.md}
H -->|exists| F
H -->|not found| I{Check CONVENTIONS.md}
I -->|exists| F
I -->|not found| J{Check .github/copilot-instructions.md}
J -->|exists| F
J -->|not found| K{Check CODING_GUIDELINES.md}
K -->|exists| F
K -->|not found| L[Return None, None]
F --> M[Create CodebaseDNA with team_rules]
L --> M
M --> N[Save to cache]
N --> O[Return DNA]
Last reviewed commit: ffad962
Additional Comments (1)
|
|
@gretileai can you do a in detail review for this PR? |
Add detected_framework, test_patterns, config_patterns, and middleware_patterns to cache reconstruction.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Summary
Auto-detect team rules from convention files (CLAUDE.md, .cursorrules, etc.) and include them in the DNA output.
Problem
AI assistants using our MCP server don't know about team-specific coding rules. Users have to manually paste their CLAUDE.md or .cursorrules content every time, or the AI generates code that doesn't follow team conventions.
Solution
The DNA extractor now automatically detects and includes team rules files. First file found wins:
CLAUDE.md.cursorrules.codeintel/rules.mdCONVENTIONS.md.github/copilot-instructions.mdCODING_GUIDELINES.mdChanges
team_rulesandteam_rules_sourcefields toCodebaseDNAdataclass_extract_team_rules()method toDNAExtractorload_from_cache()to handle new fieldsExample Output
Testing
Tested locally against this repo - correctly detects and includes CLAUDE.md content.
@coderabbitai ignore
Greptile Summary
adds auto-detection of team coding rules from convention files (CLAUDE.md, .cursorrules, etc.) to the DNA extractor, eliminating the need for manual configuration when AI assistants use the MCP server
team_rulesandteam_rules_sourcefields toCodebaseDNAdataclassload_from_cache()by restoring previously missing fields:detected_framework,test_patterns,config_patterns, andmiddleware_patterns_safe_read_file()method for robust file reading with encoding fallbacksConfidence Score: 5/5
Important Files Changed
Flowchart
flowchart TD Start([extract_dna called]) --> ExtractRules[_extract_team_rules] ExtractRules --> CheckCLAUDE{CLAUDE.md<br/>exists?} CheckCLAUDE -->|Yes| ReadFile[Read file with<br/>_safe_read_file] CheckCLAUDE -->|No| CheckCursor{.cursorrules<br/>exists?} CheckCursor -->|Yes| ReadFile CheckCursor -->|No| CheckCodeintel{.codeintel/rules.md<br/>exists?} CheckCodeintel -->|Yes| ReadFile CheckCodeintel -->|No| CheckConv{CONVENTIONS.md<br/>exists?} CheckConv -->|Yes| ReadFile CheckConv -->|No| CheckGithub{.github/copilot-<br/>instructions.md<br/>exists?} CheckGithub -->|Yes| ReadFile CheckGithub -->|No| CheckGuidelines{CODING_GUIDELINES.md<br/>exists?} CheckGuidelines -->|Yes| ReadFile CheckGuidelines -->|No| NoRules[Return None, None] ReadFile --> ContentValid{Content valid?} ContentValid -->|Yes| ReturnRules[Return content, filename] ContentValid -->|No| Continue[Continue to next file] Continue --> CheckCursor ReturnRules --> StoreDNA[Store in CodebaseDNA] NoRules --> StoreDNA StoreDNA --> Output[Include in<br/>DNA markdown output]Last reviewed commit: 0ce8c12
Context used:
dashboard- CLAUDE.md (source)