Created
December 13, 2024 00:42
-
-
Save audiojak/31b7d955fd726450e373c9135a218c8d to your computer and use it in GitHub Desktop.
This is an example of a .cursorrules file for a Python / Supabase / AWS Lambda function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python Version: 3.9+ | |
# Code Style: PEP 8 | |
# Naming Conventions: | |
# - Classes: PascalCase | |
# - Functions and variables: snake_case | |
# - Constants: UPPER_SNAKE_CASE | |
# - Private attributes/methods: _leading_underscore | |
# Project Type: | |
# - AWS Lambda Function | |
# File Structure: | |
# - Main script: main.py (containing lambda_handler) | |
# - Database operations: db_operations.py | |
# - Configuration: config.py | |
# - Utility functions: utils.py | |
# Dependencies: | |
# - supabase-py | |
# - python-dotenv | |
# - asyncio | |
# - boto3 | |
# Environment Variables: | |
# - SOURCE_SUPABASE_URL | |
# - SOURCE_SUPABASE_KEY | |
# - TARGET_SUPABASE_URL | |
# - TARGET_SUPABASE_KEY | |
# Error Handling: | |
# - Use try-except blocks for database operations and AWS SDK calls | |
# - Log errors with appropriate level (info, warning, error) | |
# Asynchronous Programming: | |
# - Use asyncio for concurrent database operations | |
# Data Validation: | |
# - Validate data types and formats before writing to database | |
# - Validate Lambda event and context objects | |
# Security: | |
# - Store sensitive information in environment variables or AWS Secrets Manager | |
# - Use parameterized queries to prevent SQL injection | |
# - Follow AWS Lambda security best practices | |
# Testing: | |
# - Write unit tests for each function, including the lambda_handler | |
# - Use pytest for testing framework | |
# - Implement integration tests with AWS SAM Local | |
# Documentation: | |
# - Use docstrings for functions and classes | |
# - Include inline comments for complex logic | |
# - Document Lambda function configuration and deployment process | |
# Logging: | |
# - Use Python's built-in logging module | |
# - Log important events and errors | |
# - Utilize AWS CloudWatch for log management | |
# Configuration: | |
# - Use a config.py file for storing configuration variables | |
# - Utilize AWS Lambda environment variables for runtime configuration | |
# Version Control: | |
# - Use Git for version control | |
# - Follow conventional commits for commit messages | |
# Code Organization: | |
# - Group related functions and classes together | |
# - Use type hints for function parameters and return values | |
# Performance: | |
# - Use batch operations for database queries when possible | |
# - Implement caching for frequently accessed data | |
# - Optimize Lambda function for cold starts | |
# Error Messages: | |
# - Provide clear and informative error messages | |
# - Return appropriate HTTP status codes in Lambda responses | |
# Maintainability: | |
# - Keep functions small and focused on a single task | |
# - Use meaningful variable and function names | |
# Scalability: | |
# - Design the system to handle increasing amounts of data | |
# - Consider using pagination for large data sets | |
# - Utilize AWS Lambda concurrency and provisioned concurrency features | |
# Monitoring: | |
# - Implement basic monitoring for script execution and database operations | |
# - Use AWS CloudWatch metrics and alarms for Lambda function monitoring | |
# Deployment: | |
# - Use AWS SAM or Serverless Framework for Lambda deployment | |
# - Implement CI/CD pipeline for automated testing and deployment | |
# AWS Lambda Specific: | |
# - Implement proper error handling and status code returns | |
# - Optimize function for AWS Lambda execution environment | |
# - Consider Lambda layers for managing dependencies |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment