Skip to content

feat(dna): auto-detect team rules from CLAUDE.md and similar files#244

Merged
DevanshuNEU merged 2 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:feature/team-rules-detection
Feb 15, 2026
Merged

feat(dna): auto-detect team rules from CLAUDE.md and similar files#244
DevanshuNEU merged 2 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:feature/team-rules-detection

Conversation

@DevanshuNEU

@DevanshuNEU DevanshuNEU commented Feb 15, 2026

Copy link
Copy Markdown
Collaborator

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:

  1. CLAUDE.md
  2. .cursorrules
  3. .codeintel/rules.md
  4. CONVENTIONS.md
  5. .github/copilot-instructions.md
  6. CODING_GUIDELINES.md

Changes

  • Add team_rules and team_rules_source fields to CodebaseDNA dataclass
  • Add _extract_team_rules() method to DNAExtractor
  • Add "Team Rules" section to DNA markdown output with source attribution
  • Update load_from_cache() to handle new fields

Example Output

## Team Rules
*Source: `CLAUDE.md`*

# CodeIntel Development Rules
...

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

  • Implemented priority-based file detection (first found wins) across 6 common convention file names
  • Added team_rules and team_rules_source fields to CodebaseDNA dataclass
  • Integrated team rules into DNA markdown output with source attribution
  • Fixed load_from_cache() by restoring previously missing fields: detected_framework, test_patterns, config_patterns, and middleware_patterns
  • Correctly uses existing _safe_read_file() method for robust file reading with encoding fallbacks

Confidence Score: 5/5

  • safe to merge with no issues found
  • clean implementation with proper error handling, uses existing safety mechanisms (_safe_read_file), fixes pre-existing cache loading bug, and follows established codebase patterns
  • no files require special attention

Important Files Changed

Filename Overview
backend/services/dna_extractor.py adds team rules auto-detection from convention files, restores missing fields in cache loader - clean implementation with no issues

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]
Loading

Last reviewed commit: 0ce8c12

Context used:

  • Context from dashboard - CLAUDE.md (source)

- 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.
@vercel

vercel Bot commented Feb 15, 2026

Copy link
Copy Markdown

@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-apps

greptile-apps Bot commented Feb 15, 2026

Copy link
Copy Markdown

Greptile Summary

Adds 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:

  • Added team_rules and team_rules_source fields to CodebaseDNA dataclass
  • Implemented _extract_team_rules() method with priority-based file discovery (6 file types)
  • Updated markdown output to include Team Rules section with source attribution
  • Extended cache serialization to include new fields

Issues Found:

  • load_from_cache() is missing several fields when reconstructing CodebaseDNA from cached data (lines 1037-1052). This was a pre-existing issue that affects the new fields as well.

Confidence Score: 4/5

  • Safe to merge with one logical bug fix needed in cache reconstruction
  • The implementation is clean and follows existing patterns well. The team rules detection logic is straightforward with proper error handling via _safe_read_file(). However, there's a logical bug in load_from_cache() where several fields are not being reconstructed from cached data, which will cause incomplete DNA objects when loading from cache.
  • backend/services/dna_extractor.py:1037-1052 needs the missing fields added to cache reconstruction

Important Files Changed

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]
Loading

Last reviewed commit: ffad962

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps

greptile-apps Bot commented Feb 15, 2026

Copy link
Copy Markdown
Additional Comments (1)

backend/services/dna_extractor.py
Missing several fields when reconstructing CodebaseDNA from cache - detected_framework, plus the testing, configuration, and middleware pattern fields are not being passed to the constructor but are defined in the dataclass on lines 102-116.

@DevanshuNEU

Copy link
Copy Markdown
Collaborator Author

@gretileai can you do a in detail review for this PR?

Add detected_framework, test_patterns, config_patterns, and
middleware_patterns to cache reconstruction.
@DevanshuNEU

Copy link
Copy Markdown
Collaborator Author

@greptileai

@vercel

vercel Bot commented Feb 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
opencodeintel Ignored Ignored Preview Feb 15, 2026 6:26pm

@DevanshuNEU DevanshuNEU merged commit 03243cf into OpenCodeIntel:main Feb 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant