agentleFS
sontallivesontallive/mcp-server-python-template/.cursor/rules/python.mdc

mcp-server-python-template / rules

Cursor rule17 starsChanged 21 months agoMITView on GitHub

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. ChiragAgg5k/poke-mcp★ 2100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 4,263 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

Show its rules and text

We split this python.mdc into the rules it gives an agent

45 rules. About 0 are common, 36 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈36

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use src-layout with src/your_package_name/

    line 14
  2. Very specific:

    Place tests in tests/ directory parallel to src/

    line 15
  3. Very specific:

    Keep configuration in config/ or as environment variables

    line 16
  4. Very specific:

    Place static files in static/ directory

    line 18
  5. Very specific:

    Use templates/ for Jinja2 templates

    line 19
  6. Distinctive:

    Follow Black code formatting

    line 22
  7. Distinctive:

    Use isort for import sorting

    line 23
  8. Distinctive:

    Follow PEP 8 naming conventions:

    line 24
  9. Distinctive:

    Use absolute imports over relative imports

    line 29
  10. Distinctive:

    Use type hints for all function parameters and returns

    line 32
  11. Very specific:

    Import types from typing module

    line 33
  12. Very specific:

    Use Optional[Type] instead of Type | None

    line 34
  13. Very specific:

    Use TypeVar for generic types

    line 35
  14. Very specific:

    Use Protocol for duck typing

    line 37
  15. Distinctive:

    Use Flask factory pattern

    line 40
  16. Distinctive:

    Use Flask-SQLAlchemy for database

    line 42
  17. Distinctive:

    Use Flask-Login for authentication

    line 44
  18. Distinctive:

    Use proper connection pooling

    line 50
  19. Distinctive:

    Use proper indexing strategies

    line 53
  20. Distinctive:

    Use Flask-Login for session management

    line 56
  21. Distinctive:

    Use proper session security

    line 59
  22. Distinctive:

    Use proper role-based access control

    line 61
  23. Distinctive:

    Use Flask-RESTful for REST APIs

    line 64
  24. Distinctive:

    Use proper HTTP status codes

    line 66
  25. Distinctive:

    Use proper response formats

    line 68
  26. Distinctive:

    Use pytest for testing

    line 72
  27. Distinctive:

    Write tests for all routes

    line 73
  28. Distinctive:

    Use pytest-cov for coverage

    line 74
  29. Distinctive:

    Use proper mocking with pytest-mock

    line 76
  30. Distinctive:

    Test all error scenarios

    line 77
  31. Distinctive:

    Use HTTPS in production

    line 80
  32. Distinctive:

    Use proper session configuration

    line 83
  33. Distinctive:

    Use proper caching with Flask-Caching

    line 88
  34. Distinctive:

    Use background tasks for heavy operations

    line 92
  35. Distinctive:

    Create custom exception classes

    line 96
  36. Distinctive:

    Use proper try-except blocks

    line 97
  37. Distinctive:

    Use proper error messages

    line 101
  38. Distinctive:

    Document all public APIs

    line 105
  39. Distinctive:

    Use proper inline comments

    line 107
  40. Distinctive:

    Use virtual environments (venv)

    line 112
  41. Distinctive:

    Use proper Git workflow

    line 114
  42. Distinctive:

    Use proper CI/CD practices

    line 116
  43. Distinctive:

    Use requirements.txt for production

    line 121
  44. Distinctive:

    Use proper package versions

    line 123
  45. Distinctive:

    Check for security vulnerabilities

    line 125

≈ “Common” is an estimate: at least 1 in 5 of the 7,111 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
python.mdc
---
description: 
globs: 
alwaysApply: false
---
---
description: Python best practices and patterns for modern software development with Flask and SQLite
globs: **/*.py, src/**/*.py, tests/**/*.py
---

# Python Best Practices

## Project Structure
- Use src-layout with `src/your_package_name/`
- Place tests in `tests/` directory parallel to `src/`
- Keep configuration in `config/` or as environment variables
- Store requirements in `requirements.txt` or `pyproject.toml`
- Place static files in `static/` directory
- Use `templates/` for Jinja2 templates

## Code Style
- Follow Black code formatting
- Use isort for import sorting
- Follow PEP 8 naming conventions:
  - snake_case for functions and variables
  - PascalCase for classes
  - UPPER_CASE for constants
- Maximum line length of 88 characters (Black default)
- Use absolute imports over relative imports

## Type Hints
- Use type hints for all function parameters and returns
- Import types from `typing` module
- Use `Optional[Type]` instead of `Type | None`
- Use `TypeVar` for generic types
- Define custom types in `types.py`
- Use `Protocol` for duck typing

## Flask Structure
- Use Flask factory pattern
- Organize routes using Blueprints
- Use Flask-SQLAlchemy for database
- Implement proper error handlers
- Use Flask-Login for authentication
- Structure views with proper separation of concerns

## Database
- Use SQLAlchemy ORM
- Implement database migrations with Alembic
- Use proper connection pooling
- Define models in separate modules
- Implement proper relationships
- Use proper indexing strategies

## Authentication
- Use Flask-Login for session management
- Implement Google OAuth using Flask-OAuth
- Hash passwords with bcrypt
- Use proper session security
- Implement CSRF protection
- Use proper role-based access control

## API Design
- Use Flask-RESTful for REST APIs
- Implement proper request validation
- Use proper HTTP status codes
- Handle errors consistently
- Use proper response formats
- Implement proper rate limiting

## Testing
- Use pytest for testing
- Write tests for all routes
- Use pytest-cov for coverage
- Implement proper fixtures
- Use proper mocking with pytest-mock
- Test all error scenarios

## Security
- Use HTTPS in production
- Implement proper CORS
- Sanitize all user inputs
- Use proper session configuration
- Implement proper logging
- Follow OWASP guidelines

## Performance
- Use proper caching with Flask-Caching
- Implement database query optimization
- Use proper connection pooling
- Implement proper pagination
- Use background tasks for heavy operations
- Monitor application performance

## Error Handling
- Create custom exception classes
- Use proper try-except blocks
- Implement proper logging
- Return proper error responses
- Handle edge cases properly
- Use proper error messages

## Documentation
- Use Google-style docstrings
- Document all public APIs
- Keep README.md updated
- Use proper inline comments
- Generate API documentation
- Document environment setup

## Development Workflow
- Use virtual environments (venv)
- Implement pre-commit hooks
- Use proper Git workflow
- Follow semantic versioning
- Use proper CI/CD practices
- Implement proper logging

## Dependencies
- Pin dependency versions
- Use requirements.txt for production
- Separate dev dependencies
- Use proper package versions
- Regularly update dependencies
- Check for security vulnerabilities

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.