Comprehensive .cursorrules Configuration for Python Monorepo Development with Cursor AI

Posted by u/equipmentmobbingthro9 months agoCurated from Reddit

Project Information

Project Type
Large
Type of Project
Data Analysis and Development Environment
Problem Type
Development Environment Configuration and Best Practices Documentation

Tags

python
cursor-ai
monorepo
polylith
testing
code-organization
development-guidelines
data-analysis

AI Models Mentioned

Claude 3.5 Sonnet v20241022
Development assistance and code generation

Summary

A detailed configuration guide for .cursorrules in a Python monorepo project using the polylith architecture. The post outlines project structure, development guidelines, and testing practices, with specific focus on code organization, environment management using UV, and integration with Cursor AI assistant.

Prompt

Project Requirements:
1. Implement a Python monorepo following polylith architecture
2. Structure:
   - notebooks/ for Jupyter analysis
   - src/ for shared Python code
   - data/ for raw and processed data
   - tests/ with pytest (aim for high coverage)
3. Environment:
   - Use UV for package management
   - Implement ruff for code formatting
   - Use absolute imports
4. Development Guidelines:
   - Minimize complexity
   - Create focused, atomic commits
   - Refactor common code to src/
   - Implement comprehensive error handling
   - Add appropriate logging
   - Write atomic tests
Please provide implementation guidance or review existing code following these requirements.

Best Practices

Modular Code Organization

critical

Share common Python code in src/ folder for reuse across different notebooks, following polylith architecture

Controlled Code Changes

important

Make minimal and focused commits, only changing code related to specific tasks

Comprehensive Test Coverage

important

Aim for 100% code coverage, with reasonable exceptions for difficult-to-test functionality

Secure Credential Management

critical

Store database credentials in .env file

Common Mistakes to Avoid

Avoid Unnecessary Code Changes

critical

Don't modify code in places unrelated to the current task

Prevent Test Duplication

important

Don't test the same functionality multiple times

Avoid Excessive Error Classes

important

Don't introduce new error classes unless worth the additional complexity

Avoid Verbose Logging

important

Don't implement overly verbose logging

Related Posts