Convention Learner
Core Principles
- Observe before enforcing — Never impose conventions without first analyzing the existing codebase. A project with 200
internal sealed classhandlers should not get a newpublic classhandler. Detect first, then match. - Project conventions override generic rules — If the project uses
*Serviceinstead of*Handler, follow the project's convention even if the kit default is different. Explicit.editorconfigandDirectory.Build.propsrules always win. - Use MCP tools for analysis —
get_public_apireveals naming patterns,get_project_graphshows structure conventions,detect_antipatternstracks quality trends. Tools provide objective data; file reads provide confirmation. - Document findings — After detecting conventions, suggest adding them to the project's CLAUDE.md. Undocumented conventions are lost when the original developers leave.
- Consistency over perfection — A project with consistent
snake_casedatabase columns is better than a project with halfsnake_caseand halfPascalCase. Match the existing pattern, even if another convention is theoretically superior.
Patterns
Convention Detection Flow
Systematic analysis to understand a project's coding conventions. Run this when joining an existing project or before generating new code.
Step 1: Project Structure Analysis
Step 2: Type Naming Patterns
Step 3: Folder Structure Patterns Scan the file system for structural conventions:
- Feature folders:
Features/{FeatureName}/with all files together? - Layer folders:
Controllers/,Services/,Repositories/separate? - Shared patterns:
Common/,Extensions/,Middleware/? - Configuration location: root?
Config/folder?Infrastructure/?
Step 4: Configuration Detection Check for explicit convention enforcers:
Step 5: Build Convention Summary Compile findings into a structured summary:
Add categories as needed: EF Core (configurations, naming, migrations), Testing (framework, naming, fixtures), etc.
Convention Enforcement
Apply detected conventions when generating new code or reviewing existing code.
When Generating Code: Match every detected pattern:
When Reviewing Code: Flag deviations from detected conventions:
Suggesting Enforcement Rules:
After detecting conventions, suggest .editorconfig rules to enforce them automatically:
Anti-pattern Tracking
Use detect_antipatterns to track recurring quality issues across sessions.
Periodic Check:
Prioritization:
When patterns recur, add explicit rules to CLAUDE.md:


