Creates Python projects with proper structure, virtual environments, and dependency management...
Use 'uv' instead of 'pip'
Always use pytest, never unittest
This skill creates well-structured Python projects with best practices for dependency management, testing, and code organization. It sets up virtual environments, installs dependencies, and configures common development tools.
Ask the user about:
Standard Python project structure:
project-name/
āāā src/
ā āāā project_name/
ā āāā __init__.py
ā āāā main.py
āāā tests/
ā āāā __init__.py
ā āāā test_main.py
āāā .gitignore
āāā README.md
āāā requirements.txt
āāā setup.py (optional, for libraries)
Create and activate virtual environment:
# Create virtual environment
python3 -m venv venv
# Activate (instructions for user)
# macOS/Linux: source venv/bin/activate
# Windows: venv\Scripts\activate
Install packages using uv:
uv pip install <package-name>
uv pip freeze > requirements.txt
For development dependencies:
uv pip install pytest black flake8 mypy
git init
git add .
git commit -m "Initial commit: project setup"
argparse or click for command-line argumentsmain.py with proper entry pointif __name__ == "__main__": guardsetup.py for packagingnotebooks/ directory for Jupyter notebooksdata/ directory (with .gitignore)Always use pytest for testing:
uv pip install pytest pytest-cov
Example test file:
# tests/test_main.py
import pytest
from src.project_name.main import my_function
def test_my_function():
assert my_function(2, 3) == 5
Run tests:
pytest
pytest --cov=src # with coverage
uv pip install black
black src/ tests/
uv pip install flake8
flake8 src/ tests/
uv pip install mypy
mypy src/
# src/project_name/main.py
def main():
"""Main application entry point."""
print("Hello, World!")
if __name__ == "__main__":
main()
# src/project_name/config.py
import os
from pathlib import Path
# Project root directory
PROJECT_ROOT = Path(__file__).parent.parent.parent
# Load environment variables
DEBUG = os.getenv("DEBUG", "False") == "True"
class ProjectError(Exception):
"""Base exception for this project."""
pass
class ConfigError(ProjectError):
"""Configuration-related errors."""
pass
# Virtual environment
venv/
env/
.venv/
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
*.egg-info/
dist/
build/
# IDE
.vscode/
.idea/
*.swp
*.swo
# Environment
.env
.env.local
# Testing
.pytest_cache/
.coverage
htmlcov/
# OS
.DS_Store
Thumbs.db
package==1.2.3package>=1.2,<2.0src/ layout to avoid import issuesmkdir my-cli-tool && cd my-cli-tool
python3 -m venv venv
source venv/bin/activate
uv pip install click
# Create main.py, tests, etc.
mkdir my-api && cd my-api
python3 -m venv venv
source venv/bin/activate
uv pip install fastapi uvicorn
# Create app structure
mkdir my-analysis && cd my-analysis
python3 -m venv venv
source venv/bin/activate
uv pip install pandas numpy matplotlib jupyter
# Create notebooks/, data/, src/
This skill includes examples in the bundled directories:
example.py - Template Python script with best practicesapi_reference.md - Common library documentation references