AI SummaryA comprehensive Cursor rules file that enforces Python best practices and coding standards across projects, helping developers maintain clean, secure, and maintainable code through automated linting guidelines.
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to add the "service — Cursor Rules" prompt rules to my project. Repository: https://github.com/wangkuntian/service Please read the repo to find the rules/prompt file, then: 1. Download it to the correct location (.cursorrules, .windsurfrules, .github/prompts/, or project root — based on the file type) 2. If there's an existing rules file, merge the new rules in rather than overwriting 3. Confirm what was added
Description
python daemon service
Python Best Practices and Coding Standards
This document outlines comprehensive best practices and coding standards for Python development, aiming to promote clean, efficient, maintainable, and secure code.
1.1. Directory Structure Best Practices
• Flat is better than nested (but not always). Start with a simple structure and refactor as needed. • Packages vs. Modules: Use packages (directories with __init__.py) for logical grouping of modules. • src layout: Consider using a src directory to separate application code from project-level files (setup.py, requirements.txt, etc.). This helps avoid import conflicts and clarifies the project's boundaries. • Typical Project Structure: project_name/ ├── src/ │ ├── package_name/ │ │ ├── __init__.py │ │ ├── module1.py │ │ ├── module2.py │ ├── main.py # Entry point ├── tests/ │ ├── __init__.py │ ├── test_module1.py │ ├── test_module2.py ├── docs/ │ ├── conf.py │ ├── index.rst ├── .gitignore ├── pyproject.toml or setup.py ├── README.md ├── requirements.txt or requirements-dev.txt
1.2. File Naming Conventions
• Modules: Lowercase, with underscores for readability (e.g., my_module.py). • Packages: Lowercase (e.g., my_package). Avoid underscores unless necessary. • Tests: Start with test_ (e.g., test_my_module.py).
1.3. Module Organization Best Practices
• Single Responsibility Principle: Each module should have a well-defined purpose. • Imports: • Order: standard library, third-party, local. • Absolute imports are generally preferred (e.g., from my_package.module1 import function1). • Use explicit relative imports (from . import sibling_module) when dealing with complex package layouts where absolute imports are overly verbose or impractical. • Constants: Define module-level constants in uppercase (e.g., MAX_ITERATIONS = 100). • Dunder names: __all__, __version__, etc. should be after the module docstring but before any imports (except from __future__). Use __all__ to explicitly define the public API.
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster
Works With
Any AI assistant that accepts custom rules or system prompts