Skip to content

Commit 9d46d0e

Browse files
committed
docs: update AI_RULES for all backend frameworks
- Enhance AI_RULES.md for Django, FastAPI, Flask, and Node.js templates - Add database integration guidelines for each framework - Include environment variable management best practices - Update development workflow recommendations
1 parent c1ae13d commit 9d46d0e

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

scaffold-backend/django/AI_RULES.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Tech Stack
2+
23
- You are building a Django backend application.
34
- Use Python 3.x.
45
- Follow Django best practices and conventions.
56
- Always put source code in the appropriate Django app folders.
67

78
## File Operations
9+
810
- Use `<write_to_file>` tags to create new files with their complete content
911
- Use `<search_replace>` tags to modify existing files
1012
- Use `<run_terminal_cmd>` tags to execute Django management commands (migrations, startapp, etc.)
1113
- Always provide complete file content, not partial updates
1214

1315
## Project Structure
16+
1417
- `config/`: Main Django project directory containing settings
1518
- `apps/`: Django applications directory
1619
- `apps/core/`: Core functionality and models
@@ -19,6 +22,7 @@
1922
- `requirements.txt`: Python dependencies
2023

2124
## Development Guidelines
25+
2226
- Create Django apps for different features using `python manage.py startapp <app_name>`
2327
- Use Django's ORM for database operations
2428
- Implement proper URL routing in urls.py files
@@ -27,21 +31,24 @@
2731
- Use class-based views for complex logic
2832

2933
## Database
34+
3035
- Default database is SQLite (db.sqlite3)
3136
- Use migrations for database schema changes: `python manage.py makemigrations` and `python manage.py migrate`
3237
- Define models in models.py files within each app
3338

3439
## API Development
40+
3541
- Use Django REST Framework for API endpoints
3642
- Implement serializers for data validation and transformation
3743
- Use ViewSets for CRUD operations
3844
- Implement proper authentication and permissions
3945
- Add comprehensive API documentation
4046

4147
## Best Practices
48+
4249
- Use class-based views for complex logic
4350
- Implement proper error handling and logging
4451
- Use Django's forms for data validation
4552
- Implement proper security measures (CSRF protection, authentication, authorization)
4653
- Write comprehensive tests in tests.py files
47-
- Use Django's caching framework for performance optimization
54+
- Use Django's caching framework for performance optimization

scaffold-backend/fastapi/AI_RULES.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Tech Stack
2+
23
- You are building a FastAPI backend application.
34
- Use Python 3.8+.
45
- Follow FastAPI best practices and async/await patterns.
56
- Always put source code in appropriate modules and packages.
67

78
## File Operations
9+
810
- Use `<write_to_file>` tags to create new files with their complete content
911
- Use `<search_replace>` tags to modify existing files
1012
- Use `<run_terminal_cmd>` tags to execute FastAPI development commands
1113
- Always provide complete file content, not partial updates
1214

1315
## Project Structure
16+
1417
- `main.py`: Main FastAPI application entry point
1518
- `requirements.txt`: Python dependencies
1619
- `app/`: Main application package
@@ -19,6 +22,7 @@
1922
- `app/models/`: Database models (when using ORM)
2023

2124
## Development Guidelines
25+
2226
- Use Pydantic models for request/response validation
2327
- Implement proper async/await patterns for I/O operations
2428
- Use dependency injection with FastAPI's Depends()
@@ -28,6 +32,7 @@
2832
- Use SQLAlchemy or similar ORM for database operations
2933

3034
## API Design
35+
3136
- Use meaningful HTTP status codes
3237
- Implement proper request/response models
3338
- Add comprehensive API documentation with docstrings
@@ -37,18 +42,20 @@
3742
- Add proper error responses with appropriate status codes
3843

3944
## Database Integration
45+
4046
- Consider using SQLAlchemy with Alembic for migrations
4147
- Use async database drivers for better performance
4248
- Implement proper connection pooling
4349
- Use Pydantic models for data validation
4450
- Implement database sessions and transactions properly
4551

4652
## Best Practices
53+
4754
- Use type hints throughout the codebase
4855
- Write comprehensive tests using pytest
4956
- Implement proper logging with Python's logging module
5057
- Use environment variables for configuration
5158
- Implement CORS middleware for frontend integration
5259
- Use background tasks for long-running operations
5360
- Implement rate limiting and security measures
54-
- Add proper authentication and authorization
61+
- Add proper authentication and authorization

scaffold-backend/flask/AI_RULES.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Tech Stack
2+
23
- You are building a Flask backend application.
34
- Use Python 3.x.
45
- Follow Flask best practices and patterns.
56
- Always put source code in appropriate modules and packages.
67

78
## File Operations
9+
810
- Use `<write_to_file>` tags to create new files with their complete content
911
- Use `<search_replace>` tags to modify existing files
1012
- Use `<run_terminal_cmd>` tags to execute Flask development commands
1113
- Always provide complete file content, not partial updates
1214

1315
## Project Structure
16+
1417
- `run.py`: Main Flask application entry point
1518
- `requirements.txt`: Python dependencies
1619
- `app/`: Main application package
@@ -19,13 +22,15 @@
1922
- `migrations/`: Database migration files (Flask-Migrate)
2023

2124
## Development Guidelines
25+
2226
- Use Flask blueprints for larger applications to organize routes
2327
- Implement proper error handling with Flask's error handlers
2428
- Use Flask-WTF for form handling and validation
2529
- Implement proper JSON responses for API endpoints
2630
- Use Flask-SQLAlchemy or similar ORM for database operations
2731

2832
## API Design
33+
2934
- Use meaningful HTTP status codes
3035
- Implement proper request/response handling
3136
- Add comprehensive API documentation
@@ -34,16 +39,18 @@
3439
- Use consistent JSON response formats
3540

3641
## Database Integration
42+
3743
- Use SQLAlchemy with Flask-SQLAlchemy for ORM
3844
- Use Flask-Migrate for database migrations
3945
- Implement proper database connection handling
4046
- Use database sessions and transactions properly
4147

4248
## Best Practices
49+
4350
- Use environment variables for configuration (consider python-dotenv)
4451
- Implement proper logging with Flask's logger
4552
- Write comprehensive tests using pytest or Flask's testing client
4653
- Use Flask's before_request and after_request decorators for middleware-like functionality
4754
- Implement CORS handling for frontend integration
4855
- Use Flask's session management for user sessions
49-
- Implement security measures (input validation, XSS protection, CSRF protection)
56+
- Implement security measures (input validation, XSS protection, CSRF protection)

scaffold-backend/nodejs/AI_RULES.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Tech Stack
2+
23
- You are building a Node.js backend application.
34
- Use modern JavaScript (ES6+) or TypeScript.
45
- Follow Node.js best practices and Express.js patterns.
56
- Always put source code in appropriate modules and directories.
67

78
## File Operations
9+
810
- Use `<write_to_file>` tags to create new files with their complete content
911
- Use `<search_replace>` tags to modify existing files
1012
- Use `<run_terminal_cmd>` tags to execute Node.js development commands
1113
- Always provide complete file content, not partial updates
1214

1315
## Project Structure
16+
1417
- `server.js`: Main Express application entry point
1518
- `package.json`: Node.js dependencies and scripts
1619
- Consider creating separate directories for larger applications:
@@ -23,6 +26,7 @@
2326
- `tests/`: Test files
2427

2528
## Development Guidelines
29+
2630
- Use Express.js for routing and middleware
2731
- Implement proper error handling with middleware
2832
- Use environment variables for configuration (consider dotenv package)
@@ -31,6 +35,7 @@
3135
- Implement authentication and authorization (JWT, Passport.js, etc.)
3236

3337
## API Design
38+
3439
- Follow REST API conventions
3540
- Use consistent JSON response formats
3641
- Implement proper error responses with appropriate status codes
@@ -39,18 +44,20 @@
3944
- Use middleware for authentication and authorization
4045

4146
## Database Integration
47+
4248
- Consider using MongoDB with Mongoose
4349
- Or use SQL databases with Sequelize or TypeORM
4450
- Implement proper database connection handling
4551
- Use migrations for database schema changes
4652
- Implement data validation at the model level
4753

4854
## Best Practices
55+
4956
- Use async/await or Promises for asynchronous operations
5057
- Implement proper error handling and logging
5158
- Write comprehensive tests using Jest or Mocha
5259
- Use ESLint for code linting
5360
- Implement security best practices (input validation, XSS protection, etc.)
5461
- Use environment-specific configurations
5562
- Implement rate limiting and other security measures
56-
- Use clustering or PM2 for production deployment
63+
- Use clustering or PM2 for production deployment

0 commit comments

Comments
 (0)