# CrewAI Project & CursorRules Configuration
# Ensuring consistent code quality, simplicity, and maintainability
# 1. Core Principles
- Prefer simple, readable code over clever solutions
- Each function or class has a single responsibility
- Use type hints consistently
- Avoid premature optimization
- Delete unnecessary code and comments
# 2. Code Style and Structure
- Comply with PEP 8
- Use 4 spaces for indentation
- Keep a flat project structure if possible
- Group related code together by feature
- Maximum line length: 88 (Black default)
- Write functions with early returns for better readability
- Keep functions short (< 20 lines) and focused
- Limit function parameters to 3 or fewer
- Remove comments that aren’t strictly necessary
# 3. Naming Conventions
- snake_case for variables, functions, and filenames
- PascalCase for class names
- Prefix environment variables with provider-specific tags:
- OLLAMA_ for Ollama-specific variables
- OPENAI_ for OpenAI-specific variables
# 4. Environment and Configuration
- Use python-dotenv for environment variables
- Keep .env.example with default configurations
- Validate .env at runtime with clear error messages
- Enforce LiteLLM-specific rules:
- OLLAMA_MODEL_NAME must include ollama/
- No fallback to something like llama3.1 alone
- Maintain .env in .gitignore
- Never hardcode credentials or sensitive data
# 5. Dependencies
- Use standard libraries whenever possible
- Keep external dependencies minimal
- Required packages:
- crewai
- python-dotenv
- pytest (for testing)
# 6. Error Handling and Validation
- Validate environment configs on startup
- Raise exceptions for invalid/missing LLM_PROVIDER, OLLAMA_MODEL_NAME, OPENAI_MODEL_NAME
- Use explicit error handling with try-except
- Log errors at ERROR level
- Return meaningful error messages
- Sanitize external inputs
# 7. Integration Guidelines
- Support Ollama and OpenAI as LLM providers
- LLM_PROVIDER determines which is used
- Do not modify LLM_PROVIDER logic without authorization
- Agents and tasks must fetch model/provider from .env
- Prohibit fallback logic for model names in critical files (e.g., agents.py, main.py)
# 8. Syntax and Formatting
- Auto-format with Black
- Lint with Flake8
- Avoid complex one-liners
- Keep code comprehensible and minimal
# 9. Testing
- Use pytest for tests
- Write tests first (TDD) when possible
- Keep tests independent
- Test edge cases and error conditions
- Use meaningful test names
# 10. Security
- Do not commit API keys or sensitive data
- Validate all inputs
- Keep .env in .gitignore
# 11. OOP Guidelines
- Single Responsibility Principle: one class, one purpose
- Encapsulation: hide internal details
- Clear constructor initialization
- Favor composition over inheritance
- Make dependencies explicit (use dependency injection)
- Use strong types to define interfaces
- Keep methods short and focused
# 12. Project Integrity Checks
- Flag changes to critical files (e.g., main.py, agents.py, crew.py, .env.example)
- Do not bypass LiteLLM rules or environment variable constraints
# 13. Anti-Patterns to Avoid
- Deep inheritance hierarchies
- God classes that do too much
- Unnecessary comments and docstrings
- Feature envy (excessive usage of other classes’ data)
- Premature optimization
- Complex, unreadable one-liners
golang
openai
python