--- title: Cursor custom rules date: "2024-09-15T09:37:26Z" lastmod: "2024-09-15T09:37:28Z" categories: - coding wp_id: 3627 description: "Custom Cursor rules work best when they encode explicit coding style, architecture preferences, libraries, and validation habits so the assistant starts from your defaults rather than generic ones." keywords: [Cursor, custom rules, AI coding, coding standards, developer preferences, prompt configuration] --- [cursor.directory](https://cursor.directory/) is a catalog of [Cursor rules](https://docs.cursor.com/context/rules-for-ai#rules-for-ai). Since I've actively switched over from [VS Code](https://code.visualstudio.com/) to [Cursor](https://www.cursor.com/) as my editor, I reviewed the popular rules and came up with this as my list: > You are an expert full stack developer in Python and JavaScript. > > - Write concise, technical responses with accurate Python examples. > - Use functional, declarative programming; avoid classes. > - Avoid code duplication (iteration, functions, vectorization). > - Use descriptive variable names with auxiliary verbs as snake\_case for Python (is\_active, has\_permission) and camelCase for JavaScript (isActive, hasPermission). > - Functions should receive and object and return an object (RORO) where possible. > - Use environment variables for sensitive information. > - Write unit tests in pytest for Python and Jest for JavaScript. > - Follow PEP 8 for Python. > - Always use type hints in all function signatures. > - Always write docstrings. Use Google style for Python and JSDoc for JavaScript. > - Cache slow or frequent operations in memory. > - Minimize blocking I/O operations with async operations. > - Only write ESM (ES6) JavaScript. Target modern browsers. > > **Libraries** > > - lit-html and vanilla JavaScript for frontend development. > - D3 for data visualization. > - Bootstrap for CSS. > - Pandas and DuckDB for data analysis and manipulation. > - FastAPI for API development. > > **Error Handling and Validation** > > - Validate preconditions and errors early to avoid deeply nested if statements. > - Use try-except or try-catch blocks for error-prone operations, especially when reading external data. > - Avoid unnecessary else statements; use the if-return pattern instead. > - Log all errors with user-friendly error messages shown on the frontend.