chore: update files

This commit is contained in:
Tyr Chen
2025-05-31 11:49:15 -07:00
parent 748d9a862d
commit 54952f38df

View File

@@ -35,10 +35,12 @@ graph TD
Features --> Web{"Web Framework<br>needed?"} Features --> Web{"Web Framework<br>needed?"}
Features --> DB{"Database<br>access needed?"} Features --> DB{"Database<br>access needed?"}
Features --> Concurrent{"Heavy<br>concurrency?"} Features --> Concurrent{"Heavy<br>concurrency?"}
Features --> Config{"Complex config<br>or templating?"}
Web -->|Yes| WebRules["Load Axum Rules"] Web -->|Yes| WebRules["Load Axum Rules"]
DB -->|Yes| DBRules["Load SQLx Rules"] DB -->|Yes| DBRules["Load Database Rules"]
Concurrent -->|Yes| ConcurrencyRules["Load Concurrency Rules"] Concurrent -->|Yes| ConcurrencyRules["Load Concurrency Rules"]
Config -->|Yes| ToolsRules["Load Tools & Config Rules"]
style Start fill:#4da6ff,stroke:#0066cc,color:white style Start fill:#4da6ff,stroke:#0066cc,color:white
style Complex fill:#d94dbb,stroke:#a3378a,color:white style Complex fill:#d94dbb,stroke:#a3378a,color:white
@@ -143,18 +145,39 @@ sequenceDiagram
- [ ] HTTP server needed - [ ] HTTP server needed
- [ ] REST API endpoints - [ ] REST API endpoints
- [ ] OpenAPI documentation required - [ ] OpenAPI documentation required
- [ ] Axum framework planned
- [ ] SSE (Server-Sent Events) needed
- [ ] → Load Axum rules if YES to any - [ ] → Load Axum rules if YES to any
### Database Requirements ### Database Requirements
- [ ] Database queries needed - [ ] Database queries needed
- [ ] SQL database integration - [ ] SQL database integration (PostgreSQL/SQLite)
- [ ] Database migrations - [ ] Database migrations required
- [ ] → Load SQLx rules if YES to any - [ ] Repository pattern needed
- [ ] Connection pooling required
- [ ] → Load Database rules if YES to any
### Concurrency Requirements
- [ ] Multi-threading needed
- [ ] Async/await extensively used
- [ ] Shared state across threads
- [ ] Event-driven architecture
- [ ] Background task processing
- [ ] → Load Concurrency rules if YES to any
### Tools & Configuration Requirements
- [ ] Complex configuration files
- [ ] Template rendering needed
- [ ] Structured logging required
- [ ] Data transformation logic
- [ ] JSON path extraction
- [ ] → Load Tools & Config rules if YES to any
### Serialization Requirements ### Serialization Requirements
- [ ] JSON handling required - [ ] JSON handling required
- [ ] External API integration - [ ] External API integration
- [ ] Configuration files - [ ] Configuration files
- [ ] camelCase JSON serialization
- [ ] → Load Serde rules if YES to any - [ ] → Load Serde rules if YES to any
### Builder Pattern Requirements ### Builder Pattern Requirements
@@ -163,11 +186,21 @@ sequenceDiagram
- [ ] Fluent API needed - [ ] Fluent API needed
- [ ] → Load TypedBuilder rules if YES to any - [ ] → Load TypedBuilder rules if YES to any
### Concurrency Requirements ### Utility Libraries Requirements
- [ ] Multi-threading needed - [ ] Authentication/JWT needed
- [ ] Shared state across threads - [ ] CLI interface required
- [ ] High-performance requirements - [ ] Random data generation
- [ ] → Load Concurrency rules if YES to any - [ ] Enhanced derive macros
- [ ] Custom error types
- [ ] → Load Utilities rules if YES to any
### HTTP Client Requirements
- [ ] External API integration
- [ ] HTTP requests needed
- [ ] REST client functionality
- [ ] Authentication headers
- [ ] Retry/resilience patterns
- [ ] → Load HTTP Client rules if YES to any
``` ```
## 🔧 RULE LOADING COMMANDS ## 🔧 RULE LOADING COMMANDS
@@ -182,25 +215,27 @@ Based on project analysis, load specific rule sets:
# Loads: core + complex + workspace + detected features # Loads: core + complex + workspace + detected features
# Feature-specific loading examples: # Feature-specific loading examples:
# Web: core + axum + serde + typed-builder # Web: core + axum + serde + utilities (JWT)
# Database: core + sqlx + error-handling # Database: core + sqlx + utilities (error handling)
# CLI: core + simple + clap + error-handling # CLI: core + simple + utilities (clap + builders)
# Auth: core + utilities (JWT + validation)
``` ```
## 📚 AVAILABLE RULE MODULES ## 📚 AVAILABLE RULE MODULES
| Module | File | Description | | Module | File | Description |
|--------|------|-------------| |--------|------|-------------|
| **Core** | `core/code-quality.mdc` | DRY/SRP, function size limits | | **Core** | `core/code-quality.mdc` | Rust 2024, no unsafe, production-ready code |
| **Simple** | `simple/single-crate.mdc` | Single crate project structure | | **Simple** | `simple/single-crate.mdc` | Single crate project structure |
| **Complex** | `complex/workspace.mdc` | Multi-crate workspace management | | **Complex** | `complex/workspace.mdc` | Multi-crate workspace management |
| **Web** | `features/axum.mdc` | Axum framework best practices | | **Web** | `features/axum.mdc` | Axum 0.8 patterns, OpenAPI with utoipa |
| **Database** | `features/sqlx.mdc` | SQLx patterns and testing | | **Database** | `features/database.mdc` | SQLx patterns, repository design, testing |
| **Serialization** | `features/serde.mdc` | Serde configuration and patterns | | **Concurrency** | `features/concurrency.mdc` | Tokio, DashMap, async patterns |
| **Builders** | `features/typed-builder.mdc` | TypedBuilder usage patterns | | **Tools & Config** | `features/tools-and-config.mdc` | Tracing, YAML config, MiniJinja templates |
| **Concurrency** | `features/concurrency.mdc` | Rust concurrency best practices | | **Utilities** | `features/utilities.mdc` | JWT auth, CLI tools, builders, enhanced derives |
| **HTTP Client** | `features/http-client.mdc` | reqwest patterns, error handling, retry logic |
| **Testing** | `quality/testing.mdc` | Unit testing standards | | **Testing** | `quality/testing.mdc` | Unit testing standards |
| **Errors** | `quality/error-handling.mdc` | Error handling patterns | | **Errors** | `quality/error-handling.mdc` | thiserror/anyhow patterns |
## 🎯 PROJECT TYPE EXAMPLES ## 🎯 PROJECT TYPE EXAMPLES
@@ -211,11 +246,43 @@ Based on project analysis, load specific rule sets:
- Desktop applications (single-window apps) - Desktop applications (single-window apps)
### Complex Project Examples ### Complex Project Examples
- Multi-service applications (auth + business + gateway) - **Workflow engines** (multi-node processing systems)
- Enterprise applications (multiple domains) - **Multi-service applications** (auth + business + gateway)
- Large web applications (> 20 endpoints) - **Enterprise applications** (multiple domains)
- Database systems with multiple engines - **Database systems** with multiple engines
- Distributed systems - **Distributed systems** with event processing
## 🚀 MODERN RUST STACK PREFERENCES
Based on real-world experience, these are the recommended tools:
### Core Dependencies
- **Rust Edition**: 2024 (always latest)
- **Error Handling**: `thiserror` for libraries, `anyhow` for binaries
- **Async Runtime**: `tokio` with full features
- **Serialization**: `serde` with `camelCase` for JSON APIs
### Web Development Stack
- **Web Framework**: `axum` 0.8+
- **API Documentation**: `utoipa` + `utoipa-swagger-ui`
- **HTTP Client**: `reqwest`
- **Database**: `sqlx` (never `rusqlite` or `tokio-postgres`)
### Concurrency & Data Structures
- **Sync Primitives**: `tokio::sync` (never `std::sync` in async)
- **Concurrent Collections**: `dashmap` (never `Mutex<HashMap>`)
- **Channels**: `tokio::sync::{mpsc, broadcast, oneshot}`
### Configuration & Templates
- **Config Format**: YAML (never TOML for complex configs)
- **Config Loading**: `serde_yaml`
- **Templates**: `minijinja` (never `handlebars`)
- **Data Extraction**: `jsonpath-rust`
### Observability
- **Logging**: `tracing` + `tracing-subscriber` (never `env_logger`)
- **Structured Logging**: Always use `#[instrument]` and context
- **Log Rotation**: `tracing-appender` for production
## ⚡ OPTIMIZATION FEATURES ## ⚡ OPTIMIZATION FEATURES
@@ -223,6 +290,7 @@ Based on project analysis, load specific rule sets:
- **Context Preservation**: Project decisions cached across sessions - **Context Preservation**: Project decisions cached across sessions
- **Template Generation**: Auto-generate boilerplate based on detected patterns - **Template Generation**: Auto-generate boilerplate based on detected patterns
- **Incremental Updates**: Update only changed components - **Incremental Updates**: Update only changed components
- **Workspace Dependencies**: Always prefer workspace deps over crate-specific
## 🚨 MANDATORY VERIFICATION ## 🚨 MANDATORY VERIFICATION
@@ -235,9 +303,29 @@ Before starting any Rust development:
- Appropriate rules loaded? [YES/NO] - Appropriate rules loaded? [YES/NO]
- Cargo.toml structure verified? [YES/NO] - Cargo.toml structure verified? [YES/NO]
- Error handling strategy selected? [thiserror/anyhow] - Error handling strategy selected? [thiserror/anyhow]
- Uses Rust 2024 edition? [YES/NO]
- No unsafe code planned? [YES/NO]
- Workspace dependencies configured? [YES/NO]
→ If all verified: Proceed with development → If all verified: Proceed with development
→ If missing: Complete project setup → If missing: Complete project setup
``` ```
This system ensures optimal Rust development practices while maintaining flexibility for different project scales and requirements. ## 🔄 BUILD VERIFICATION WORKFLOW
Every code change must pass this sequence:
```bash
# 1. Build verification
cargo build
# 2. Test execution
cargo test
# 3. Linting verification
cargo clippy
# All three must pass before code is considered complete
```
This system ensures optimal Rust development practices while maintaining flexibility for different project scales and requirements, based on real-world production experience.