Skip to content

Commit fa2d02a

Browse files
committed
manually ran tt tool for changed class.
1 parent cd6799d commit fa2d02a

15 files changed

+1930
-3
lines changed

.cursor/rules/README.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Cursor Rules - Optimized Structure
2+
3+
This directory contains optimized Cursor rules that follow the latest specification and best practices, including an **auto-improvement system** that automatically detects patterns and suggests rule enhancements.
4+
5+
## Rule Structure
6+
7+
### Core Rules
8+
- **[cursor_rules.mdc](mdc:.cursor/rules/cursor_rules.mdc)** - Main specification and formatting guidelines
9+
- **[self_improve.mdc](mdc:.cursor/rules/self_improve.mdc)** - Continuous improvement and pattern recognition
10+
- **[auto_improvement.mdc](mdc:.cursor/rules/auto_improvement.mdc)** - **NEW**: Automatic rule improvement system
11+
12+
### Domain-Specific Rules
13+
- **[authentication_best_practices.mdc](mdc:.cursor/rules/authentication/authentication_best_practices.mdc)** - Security and authentication guidelines
14+
- **[hotchocolate_best_practices.mdc](mdc:.cursor/rules/hotchocolate/hotchocolate_best_practices.mdc)** - GraphQL and HotChocolate best practices
15+
16+
### Workflow Rules
17+
- **[development_workflow.mdc](mdc:.cursor/rules/development_workflow.mdc)** - Development process and project organization
18+
19+
### Automation Tools
20+
- **[pattern_detector.ps1](mdc:.cursor/rules/pattern_detector.ps1)** - **NEW**: PowerShell script for automatic pattern detection
21+
22+
## 🚀 Auto-Improvement System
23+
24+
### What It Does
25+
The auto-improvement system automatically detects when the same patterns appear multiple times in your codebase and suggests rule improvements:
26+
27+
- **Pattern Detection**: Identifies recurring code patterns across 3+ files
28+
- **Rule Suggestions**: Automatically generates new rule suggestions
29+
- **Quality Metrics**: Assesses rule completeness and effectiveness
30+
- **Cross-Referencing**: Maintains rule relationships and dependencies
31+
32+
### How It Works
33+
1. **Automatic Detection**: Monitors code for recurring patterns
34+
2. **Threshold Triggers**: Suggests improvements when patterns appear 3+ times
35+
3. **Rule Generation**: Creates comprehensive rule suggestions
36+
4. **Quality Assessment**: Evaluates rule effectiveness and completeness
37+
38+
### Pattern Categories Detected
39+
- **Architectural Patterns**: Service registration, DI, middleware
40+
- **Code Quality**: Error handling, logging, validation
41+
- **Performance**: Database queries, caching, async patterns
42+
- **Security**: Authentication, authorization, input validation
43+
44+
### Usage
45+
```powershell
46+
# Run pattern detection (PowerShell)
47+
.\pattern_detector.ps1 -ProjectRoot . -PatternThreshold 3
48+
49+
# Customize detection
50+
.\pattern_detector.ps1 -PatternThreshold 5 -OutputFile "custom_analysis.json"
51+
```
52+
53+
## Rule Format
54+
55+
All rules follow this standardized format:
56+
57+
```markdown
58+
---
59+
description: Clear, one-line description of what the rule enforces
60+
globs: path/to/files/*.ext, other/path/**/*
61+
alwaysApply: boolean
62+
---
63+
64+
# Rule Title
65+
66+
## Section
67+
68+
- **Key Point in Bold**
69+
- Sub-points with details
70+
- Examples and explanations
71+
```
72+
73+
## Usage
74+
75+
1. **Always Apply Rules**: These rules are automatically applied to all relevant files
76+
2. **Domain Rules**: Apply to specific file types or directories
77+
3. **Cross-References**: Rules reference each other for consistency
78+
4. **Auto-Improvement**: Rules automatically improve based on detected patterns
79+
80+
## Optimization Benefits
81+
82+
- **Eliminated Duplication**: Consolidated similar rules into comprehensive files
83+
- **Standardized Format**: All rules follow the same structure and metadata
84+
- **Proper Cross-Referencing**: Rules link to each other for maintainability
85+
- **Focused Scope**: Each rule file has a clear, specific purpose
86+
- **Latest Specification**: Follows current Cursor rules best practices
87+
- **🚀 Auto-Improvement**: Rules automatically evolve based on codebase patterns
88+
89+
## Maintenance
90+
91+
- **Automatic**: The auto-improvement system detects and suggests updates
92+
- **Manual**: Update rules when new patterns emerge
93+
- **Examples**: Add examples from actual codebase
94+
- **Cross-Reference**: Rules automatically maintain references
95+
- **Quality**: Follow the self-improvement guidelines in [self_improve.mdc](mdc:.cursor/rules/self_improve.mdc)
96+
97+
## Auto-Improvement Workflow
98+
99+
1. **Pattern Detection**: System monitors code for recurring patterns
100+
2. **Threshold Trigger**: When pattern appears 3+ times, system suggests improvement
101+
3. **Rule Suggestion**: Generates comprehensive rule or update suggestion
102+
4. **Quality Assessment**: Evaluates rule completeness and effectiveness
103+
5. **Implementation**: Apply approved rule improvements
104+
6. **Continuous Monitoring**: System continues to detect new patterns
105+
106+
## Backup
107+
108+
A complete backup of all rules is available in `cursor-rules-backup-YYYYMMDD-HHMMSS.zip` in the project root.
109+
110+
## Next Steps
111+
112+
1. **Run Pattern Detection**: Execute `.\pattern_detector.ps1` to analyze your codebase
113+
2. **Review Suggestions**: Check generated rule suggestions in `pattern_analysis.json`
114+
3. **Implement Improvements**: Apply high-priority rule enhancements
115+
4. **Monitor Quality**: Use the auto-improvement system for continuous enhancement
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
alwaysApply: false
3+
description: "Security guidelines for authentication and session management"
4+
globs: ["**/*.cs", "**/Controllers/**/*", "**/Services/**/*"]
5+
---
6+
7+
# Authentication Best Practices
8+
9+
## Session Security
10+
- **Always use HTTP-only cookies for session/auth tokens**
11+
- Prevents XSS attacks by making tokens inaccessible to JavaScript
12+
- Example (ASP.NET Core):
13+
```csharp
14+
services.ConfigureApplicationCookie(options =>
15+
{
16+
options.Cookie.HttpOnly = true;
17+
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
18+
options.Cookie.SameSite = SameSiteMode.Strict;
19+
});
20+
```
21+
22+
## Token Management
23+
- **Use secure, short-lived tokens (JWT or MSAL best practices)**
24+
- Set appropriate expiration and validate tokens on every request
25+
- Example (JWT):
26+
```csharp
27+
var token = new JwtSecurityToken(
28+
expires: DateTime.UtcNow.AddMinutes(30),
29+
... // other claims
30+
);
31+
```
32+
33+
## OAuth Integration
34+
- **Integrate social logins via secure OAuth/OpenID Connect flows**
35+
- Use official providers and never expose secrets in client-side code
36+
- Example (ASP.NET Core):
37+
```csharp
38+
services.AddAuthentication().AddGoogle(options =>
39+
{
40+
options.ClientId = Configuration["Authentication:Google:ClientId"];
41+
options.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
42+
});
43+
```
44+
45+
## Security Principles
46+
- **Never expose secrets or tokens in client-side code**
47+
- All sensitive operations must be server-side only
48+
49+
## MSAL Integration
50+
- **Use MSAL or equivalent for secure token acquisition and storage**
51+
- Example (MSAL):
52+
```csharp
53+
var app = PublicClientApplicationBuilder.Create(ClientId)
54+
.WithAuthority(AzureCloudInstance.AzurePublic, TenantId)
55+
.WithRedirectUri("http://localhost")
56+
.Build();
57+
var result = await app.AcquireTokenInteractive(scopes).ExecuteAsync();
58+
```
59+
60+
## References
61+
- Context7/MSAL.NET documentation
62+
- Microsoft authentication documentation
63+
- Project AuthController/AuthMutations implementation

0 commit comments

Comments
 (0)