agentleFS
wrm3wrm3/ai_project_template/.cursor/rules/virtual_environments_python.md

ai_project_template / rules

Cursor rule1 starsChanged 12 months agoMITView on GitHub

CRITICAL: This project uses UV as the standard Python package manager and virtual environment tool. If converting an existing project: Remember: UV is the standard. Both requirements.txt and pyproject.toml must always be in sync.

  • Installs packages

The file

Show its rules and text

We split this virtual_environments_python.md into the rules it gives an agent

21 rules. About 0 are common, 12 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    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:

    Always use uv venv to create virtual environments

    line 10
  2. Very specific:

    Never use python -m venv or virtualenv directly

    line 11
  3. Very specific:

    Use uv pip install <package> for installing packages

    line 15
  4. Very specific:

    Use uv pip install -r requirements.txt for bulk installations

    line 16
  5. Very specific:

    Use uv run python <script> to run Python scripts in the UV environment

    line 17
  6. Very specific:

    ALWAYS: keep both requirements.txt AND pyproject.toml synchronized

    line 20
  7. Distinctive:

    When adding a new package, update BOTH files immediately

    line 21
  8. Distinctive:

    When removing a package, remove from BOTH files

    line 22
  9. Distinctive:

    Never let these files get out of sync

    line 23
  10. Distinctive:

    Ensure version matches what's in requirements.txt

    line 65
  11. Distinctive:

    Check that both files contain the same package versions

    line 68
  12. Distinctive:

    Commit both files together

    line 69
  13. Distinctive:

    If converting an existing project:

    line 111
  14. Very specific:

    Create UV environment: uv venv

    line 114
  15. Very specific:

    Update pyproject.toml with all dependencies

    line 116
  16. Distinctive:

    Verify both files are synchronized

    line 117
  17. Distinctive:

    Document UV usage in project README

    line 118
  18. Very specific:

    Code Reviews: Check that both requirements.txt and pyproject.toml are updated

    line 122
  19. Distinctive:

    CI/CD: Add validation to ensure file synchronization

    line 123
  20. Distinctive:

    Documentation: Always mention UV in setup instructions

    line 124
  21. Distinctive:

    Consistency: Never mix pip and UV in the same project

    line 125

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 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
virtual_environments_python.md

Python Virtual Environment Management

UV Package Manager

CRITICAL: This project uses UV as the standard Python package manager and virtual environment tool.

Core Requirements

  1. Virtual Environment Creation
    • Always use uv venv to create virtual environments
    • Never use python -m venv or virtualenv directly
    • UV provides faster, more reliable environment management
  2. Package Installation
    • Use uv pip install <package> for installing packages
    • Use uv pip install -r requirements.txt for bulk installations
    • Use uv run python <script> to run Python scripts in the UV environment
  3. Dependency Management
    • ALWAYS keep both requirements.txt AND pyproject.toml synchronized
    • When adding a new package, update BOTH files immediately
    • When removing a package, remove from BOTH files
    • Never let these files get out of sync

File Synchronization Rules

requirements.txt

# Format: package==version
numpy==1.24.0
pandas==2.0.0
requests==2.31.0

pyproject.toml

[project]
name = "project-name"
version = "0.1.0"
dependencies = [
    "numpy==1.24.0",
    "pandas==2.0.0",
    "requests==2.31.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

Workflow for Adding Dependencies

  1. Install the package:
    uv pip install <package>
  2. Update requirements.txt:
    uv pip freeze > requirements.txt
  3. Update pyproject.toml:
    • Manually add the package with version to the dependencies array
    • Ensure version matches what's in requirements.txt
  4. Verify synchronization:
    • Check that both files contain the same package versions
    • Commit both files together

Common UV Commands

# Create virtual environment
uv venv

# Activate environment (Windows)
.venv\Scripts\activate

# Activate environment (Unix/Mac)
source .venv/bin/activate

# Install package
uv pip install <package>

# Install from requirements
uv pip install -r requirements.txt

# Run script in UV environment
uv run python script.py

# Update all packages
uv pip install --upgrade -r requirements.txt

# List installed packages
uv pip list

# Show package info
uv pip show <package>

Benefits of UV

  • Speed: 10-100x faster than pip for package resolution
  • Reliability: Better dependency conflict resolution
  • Compatibility: Drop-in replacement for pip
  • Modern: Built with Rust for performance and safety

Migration from pip/venv

If converting an existing project:

  1. Install UV: pip install uv
  2. Create UV environment: uv venv
  3. Install existing requirements: uv pip install -r requirements.txt
  4. Update pyproject.toml with all dependencies
  5. Verify both files are synchronized
  6. Document UV usage in project README

Enforcement

  • Code Reviews: Check that both requirements.txt and pyproject.toml are updated
  • CI/CD: Add validation to ensure file synchronization
  • Documentation: Always mention UV in setup instructions
  • Consistency: Never mix pip and UV in the same project

Remember: UV is the standard. Both requirements.txt and pyproject.toml must always be in sync.

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.