Skip to main content
rule

python-github-setup-cursorrules-prompt-file — Cursor rule: Python

Tells Cursor how to write and review Python code: style, tests, GitHub Pull Requests and GitHub Actions CI. Useful when the team has no shared rulebook.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/python-github-setup-cursorrules-prompt-file.mdc
Open on GitHub

What python-github-setup-cursorrules-prompt-file does

The rule spells out how Cursor should handle Python code in your project. It sets 4-space indentation, a 120-character line limit, required comments and docstrings following the Google Python Style Guide. Variables and functions use snake_case, classes use PascalCase.

Processes get their own section. Tests are mandatory with an 80% coverage target, unit and integration types, pytest as the framework. Reviews run through GitHub Pull Requests, branching follows GitHub Flow, commit messages follow Conventional Commits. Black handles formatting, Pylint handles linting against PEP 8. CI runs on GitHub Actions with the config at .github/workflows/main.yml.

Some parts are tied to one specific project: a Python file-organization tool that classifies content with AI. The listed libraries include watchdog, spacy, PyPDF2, python-docx, pandas, transformers, torch and scikit-learn. If your project looks different, rewrite those lines — otherwise Cursor will keep suggesting dependencies you do not have. Secrets live in environment variables, config in .env via python-dotenv.

What it helps with

  • set one Python style across the team
  • make tests and a coverage target mandatory
  • route reviews through GitHub Pull Requests
  • pin commit format and branching strategy
  • keep secrets in environment variables

Example prompts for the agent

  • Add a new module for document classification following the project rules
  • Check this file against PEP 8 and our naming conventions
  • Set up the GitHub Actions workflow from our config

How to install python-github-setup-cursorrules-prompt-file

Manually: put the files in place

.cursor/rules/python-github-setup-cursorrules-prompt-file.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about python-github-setup-cursorrules-prompt-file

How do I install python-github-setup-cursorrules-prompt-file in Cursor?

Create .cursor/rules/python-github-setup-cursorrules-prompt-file.mdc in your project root and paste the rule contents into it.

What does this rule do?

It defines Python development standards for Cursor: code style, naming, tests, reviews, CI and secret handling.

Which tools does the rule assume?

Black for formatting, Pylint for linting, pytest for tests, GitHub Actions for CI and python-dotenv for configuration.

Source text

python-github-setup-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for Python development with GitHub setup integration."
globs: **/*
alwaysApply: false
---
{
    "general": {
        "coding_style": {
            "language": "Python",
            "use_strict": true,
            "indentation": "4 spaces",
            "max_line_length": 120,
            "comments": {
                "style": "# for single-line, ''' for multi-line",
                "require_comments": true
            }
        },
        
        "naming_conventions": {
            "variables": "snake_case",
            "functions": "snake_case",
            "classes": "PascalCase",
            "interfaces": "PascalCase",
            "files": "snake_case"
        },
        
        "error_handling": {
            "prefer_try_catch": true,
            "log_errors": true
        },
        
        "testing": {
            "require_tests": true,
            "test_coverage": "80%",
            "test_types": ["unit", "integration"]
        },
        
        "documentation": {
            "require_docs": true,
            "doc_tool": "docstrings",
            "style_guide": "Google Python Style Guide"
        },
        
        "security": {
            "require_https": true,
            "sanitize_inputs": true,
            "validate_inputs": true,
            "use_env_vars": true
        },
        
        "configuration_management": {
            "config_files": [".env"],
            "env_management": "python-dotenv",
            "secrets_management": "environment variables"
        },
        
        "code_review": {
            "require_reviews": true,
            "review_tool": "GitHub Pull Requests",
            "review_criteria": ["functionality", "code quality", "security"]
        },
        
        "version_control": {
            "system": "Git",
            "branching_strategy": "GitHub Flow",
            "commit_message_format": "Conventional Commits"
        },
        
        "logging": {
            "logging_tool": "Python logging module",
            "log_levels": ["debug", "info", "warn", "error"],
            "log_retention_policy": "7 days"
        },
        
        "monitoring": {
            "monitoring_tool": "Not specified",
            "metrics": ["file processing time", "classification accuracy", "error rate"]
        },
        
        "dependency_management": {
            "package_manager": "pip",
            "versioning_strategy": "Semantic Versioning"
        },
        
        "accessibility": {
            "standards": ["Not applicable"],
            "testing_tools": ["Not applicable"]
        },
        
        "internationalization": {
            "i18n_tool": "Not applicable",
            "supported_languages": ["English"],
            "default_language": "English"
        },
        
        "ci_cd": {
            "ci_tool": "GitHub Actions",
            "cd_tool": "Not specified",
            "pipeline_configuration": ".github/workflows/main.yml"
        },
        
        "code_formatting": {
            "formatter": "Black",
            "linting_tool": "Pylint",
            "rules": ["PEP 8", "project-specific rules"]
        },
        
        "architecture": {
            "patterns": ["Modular design"],
            "principles": ["Single Responsibility", "DRY"]
        }
    },
    
    "project_specific": {
        "use_framework": "None",
        "styling": "Not applicable",
        "testing_framework": "pytest",
        "build_tool": "setuptools",
        
        "deployment": {
            "environment": "Local machine",
            "automation": "Not specified",
            "strategy": "Manual deployment"
        },
        
        "performance": {
            "benchmarking_tool": "Not specified",
            "performance_goals": {
                "response_time": "< 5 seconds per file",
                "throughput": "Not specified",
                "error_rate": "< 1%"
            }
        }
    },
    
    "context": {
        "codebase_overview": "Python-based file organization tool using AI for content analysis and classification",
        "libraries": [
            "watchdog", "spacy", "PyPDF2", "python-docx", "pandas", "beautifulsoup4", 
            "transformers", "scikit-learn", "joblib", "python-dotenv", "torch", "pytest", 
            "shutil", "logging", "pytest-mock"
        ],
        
        "coding_practices": {
            "modularity": true,
            "DRY_principle": true,
            "performance_optimization": true
        }
    },
    
    "behavior": {
        "verbosity": {
            "level": 2,
            "range": [0, 3]
        },
        "handle_incomplete_tasks": "Provide partial solution and explain limitations",
        "ask_for_clarification": true,
        "communication_tone": "Professional and concise"
    }
}

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Programming languages →

From the same set68

react-native-expo-cursorrules-prompt-file A Cursor rule that tells the agent how to write React Native code with Expo. Useful when you want new screens and components to follow one stack. ★ 41,011repo stars rails-cursorrules-prompt-file A Cursor rule file that tells the agent how to write Rails 8 code: generators, bin/dev, the Solid stack, Minitest and Hotwire. ★ 41,011repo stars qwik-basic-cursorrules-prompt-file A Cursor rule that sets Qwik conventions for the agent: lazy functions with the $ suffix, signals, tasks, and a TypeScript plus Vite project layout. ★ 41,011repo stars python A Cursor rule that sets project layout, code style and stack choices for Python work with Flask and SQLite. Useful when the agent edits files in your repo. ★ 41,011repo stars python-fastapi-best-practices-cursorrules-prompt-f A Cursor rule that sets the agent's coding style for Python and FastAPI: functional code, Pydantic v2, async operations. ★ 41,011repo stars python-cursorrules-prompt-file-best-practices A Cursor rule that makes the assistant write Python with type annotations, PEP 257 docstrings and pytest tests. ★ 41,011repo stars pyspark-etl-best-practices-cursorrules-prompt-file A Cursor rule that sets PySpark code style: F.col(), explicit joins, select over withColumn, and Iceberg-aware ETL structure. ★ 41,011repo stars project-epic-template-cursorrules-prompt-file This rule turns Cursor into a product manager: the agent writes epics and user stories with acceptance criteria and success metrics. ★ 41,011repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor