Learn Cursor

Master Cursor IDE for AI-assisted development

Let's build a Python Hello World Project with uv Using Cursor IDE's AI Agent

Introduction

This tutorial demonstrates how to build a Python project using uv dependency manager while leveraging Cursor IDE's AI agent to do most of the work automatically. Instead of typing code manually, you'll learn to use Cursor's AI capabilities to generate, modify, and manage your entire project.

Why Use Cursor's AI Agent?

Cursor's AI agent can:

  • Generate entire project structures
  • Write complete code files from descriptions
  • Execute terminal commands for you
  • Fix errors automatically
  • Refactor and improve code
  • Add tests and documentation
  • Manage dependencies

Prerequisites

You only need:

That's it! Cursor will help with everything else.

Setting up Cursor IDE

Step 1: Install and Launch Cursor

  1. Download Cursor from https://cursor.com/download
  2. Install it like any regular application
  3. Open Cursor IDE

Step 2: Enable AI Features

  1. When Cursor opens, sign in for full AI capabilities (recommended)
  2. You'll get access to ChatGPT, Claude, and other models
  3. The AI features will be available immediately

Step 3: Configure Cursor for Maximum Automation

  1. Press Cmd+, (Mac) or Ctrl+, (Windows/Linux) to open settings
  2. Search for "AI" in settings
  3. Enable:
    • "Auto-generate commit messages"
    • "Apply suggestions automatically"

Installing uv Through Cursor

Instead of installing uv manually, let Cursor do it for you!

Method 1: Using Cursor's Terminal with AI

  1. Open Cursor's integrated terminal: `Ctrl+`` (backtick) or View → Terminal
  2. Click the AI Terminal button (sparkle icon) or press Cmd+K in the terminal
  3. Type this request:
    install uv package manager on my system
    
  4. Cursor will:
    • Detect your operating system
    • Generate the correct installation command
    • Ask for confirmation to run it
  5. Press Enter to execute

Method 2: Using Cursor Chat

  1. Press Cmd+L (Mac) or Ctrl+L (Windows/Linux) to open Cursor Chat
  2. Type:
    Please install uv Python package manager on my system and verify it's working
    
  3. Cursor will provide the commands
  4. Click "Run" button next to each command

Creating Project with Cursor AI

Now let's create the entire project structure using Cursor's AI:

Step 1: Create Project Folder with AI

  1. Open Cursor Chat (Cmd+L / Ctrl+L)
  2. Type this prompt:
    Create a new Python project folder called "hello-world-uv" on my desktop,
    open it in Cursor, and initialize it with uv
    
  3. Cursor will generate and run the necessary commands

Step 2: Generate Complete Project Structure

In Cursor Chat, use this comprehensive prompt:

Please create a complete Python Hello World project with the following:
1. Initialize with uv init
2. Create a main.py file with:
   - A colorful hello world function
   - Input to get user's name
   - Display personalized greeting
   - Use rich and colorama for formatting
3. Add dependencies: rich, colorama, click
4. Create a tests folder with pytest tests
5. Add a README.md with project description
6. Create a .gitignore file for Python projects
7. Set up pre-commit hooks with black and flake8

Execute all necessary commands and create all files.

Cursor will:

  • Run all uv commands
  • Create all files with content
  • Install dependencies
  • Set up the complete project structure

Using Cursor Composer

Cursor Composer is the most powerful way to work with multiple files simultaneously:

Activating Composer

  1. Press Cmd+I (Mac) or Ctrl+I (Windows/Linux)
  2. Or click the "Composer" button in the sidebar

Creating an Entire Application with Composer

In Composer, type this single prompt:

Create a complete Python Hello World application with these features:

Project structure:
- src/hello_world/ directory with __init__.py, main.py, greetings.py, utils.py
- tests/ directory with comprehensive pytest tests
- Modern pyproject.toml with uv configuration
- GitHub Actions workflow for CI/CD
- Dockerfile for containerization
- Makefile with common commands

Features:
- Interactive CLI using Click
- Multiple greeting styles (formal, casual, excited)
- Support for multiple languages (English, Spanish, French, Japanese)
- ASCII art banner
- Configuration file support (YAML)
- Logging with colored output
- Progress bars for batch processing
- Export greetings to JSON/CSV

Make it production-ready with:
- Type hints everywhere
- Comprehensive error handling
- 100% test coverage
- Documentation strings
- Performance optimizations

Use these libraries: click, rich, pyyaml, tqdm, colorlog, pandas

Create all files and run all necessary uv commands to set this up.

Composer will:

  1. Create the entire directory structure
  2. Write all Python files with full implementation
  3. Generate test files with test cases
  4. Create configuration files
  5. Set up CI/CD pipeline
  6. Install all dependencies
  7. Create documentation

Reviewing Composer's Work

After Composer finishes:

  1. It shows all created/modified files in the sidebar
  2. You can review each file by clicking on it
  3. Accept all changes with "Accept All" or review individually
  4. Composer automatically runs necessary terminal commands