Configuring Claude Code or Cursor for uv¶
How do we configure Claude Code or Cursor to automatically use uv instead of pip for Python package management?
Claude Code uses CLAUDE.md files to configure your project’s storage
and context, ensuring a consistent tooling environment for your entire
development workflow.
Assuming Claude Code and uv are already installed on your system and you have already created a uv-based Python project, for example with uv init.
Tip
You can use the /init command in Claude Code to automatically create a
CLAUDE.md file and then add uv-specific instructions to it.
# Python environment with uv
Use uv exclusively for the Python environment in this project.
## Environment commands
- Use uv to install, sync, and lock Python dependencies
- Never use pip, pip-tools, poetry, or conda for dependency management
Use these commands:
- Install dependencies: `uv add <package>`
- Remove dependencies: `uv remove <package>`
- Sync dependencies: `uv sync`
## Running Python Code
- Run a Python script with `uv run <script-name>.py`
- Run Python tools like pytest with `uv run pytest`
Tip
Remember to manage your project-specific CLAUDE.md file with
Git so that everyone on the team working
with Claude Code automatically receives the same configuration.
See also
Cursor Rules can be used to use uv instead of pip.
This assumes that Cursor and uv are already installed on your system and you have already created a uv-based Python project, for example, with uv init.
Then you can create a Cursor Markdown Context file uv.mdc in
PROJECT/.cursor/rules/ for your Cursor Rules in
with
Name:
uvRule Type: Agent Requested
Description: Exclusively use uv for the Python environment in this project.
Afterwards, you can add the following rules:
# Python environment with uv
Exclusively use uv for the Python environment in this project.
## Environment commands
- Use uv to install, sync, and lock Python dependencies
- Never use pip, pip-tools, poetry, or conda for dependency management
Use these commands:
- Install dependencies: `uv add <package>`
- Remove dependencies: `uv remove <package>`
- Sync dependencies: `uv sync`
## Running Python Code
- Run a Python script with `uv run <script-name>.py`
- Run Python tools like pytest with `uv run pytest`