Skip to content

Commit 19a5e42

Browse files
committed
📝 Add Claude and Cursor config for uv
1 parent c940d14 commit 19a5e42

File tree

2 files changed

+96
-4
lines changed

2 files changed

+96
-4
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
Configuring Claude Code or Cursor for uv
2+
========================================
3+
4+
How do we configure `Claude Code <https://claude.com/product/claude-code>`_ or
5+
`Cursor <https://cursor.com>`_ to automatically use uv instead of pip for Python
6+
package management?
7+
8+
.. tab:: Claude Code
9+
10+
Claude Code uses :file:`CLAUDE.md` files to configure your project’s storage
11+
and context, ensuring a consistent tooling environment for your entire
12+
development workflow.
13+
14+
Assuming Claude Code and uv are already installed on your system and you have
15+
already created a uv-based Python project, for example with :ref:`uv init
16+
<uv-package-structure>`.
17+
18+
.. tip::
19+
You can use the ``/init`` command in Claude Code to automatically create a
20+
:file:`CLAUDE.md` file and then add uv-specific instructions to it.
21+
22+
.. code-block:: md
23+
:caption: CLAUDE.md
24+
25+
# Python environment with uv
26+
Use uv exclusively for the Python environment in this project.
27+
28+
## Environment commands
29+
- Use uv to install, sync, and lock Python dependencies
30+
- Never use pip, pip-tools, poetry, or conda for dependency management
31+
32+
Use these commands:
33+
- Install dependencies: `uv add <package>`
34+
- Remove dependencies: `uv remove <package>`
35+
- Sync dependencies: `uv sync`
36+
37+
## Running Python Code
38+
- Run a Python script with `uv run <script-name>.py`
39+
- Run Python tools like pytest with `uv run pytest`
40+
41+
.. tip::
42+
Remember to manage your project-specific :file:`CLAUDE.md` file with
43+
:doc:`Git </productive/git/index>` so that everyone on the team working
44+
with Claude Code automatically receives the same configuration.
45+
46+
.. seealso::
47+
* `Claude Docs <https://docs.claude.com/en/home>`_
48+
* `Manage Claude's memory
49+
<https://docs.claude.com/en/docs/claude-code/memory>`_
50+
51+
.. tab:: Cursor
52+
53+
`Cursor Rules <https://cursor.com/docs/context/rules>`_ can be used to use uv
54+
instead of pip.
55+
56+
This assumes that Cursor and uv are already installed on your system and you
57+
have already created a uv-based Python project, for example, with :ref:`uv
58+
init <uv-package-structure>`.
59+
60+
Then you can create a *Cursor Markdown Context* file :file:`uv.mdc` in
61+
:samp:`{PROJECT}/.cursor/rules/` for your Cursor Rules in
62+
:menuselection:`View Menu --> Command Palette --> New Cursor Rule` with
63+
64+
* Name: ``uv``
65+
* Rule Type: *Agent Requested*
66+
* Description: *Exclusively use uv for the Python environment in this project.*
67+
68+
Afterwards, you can add the following rules:
69+
70+
.. code-block:: md
71+
:caption: .cursor/rules/uv.mdc
72+
73+
# Python environment with uv
74+
Exclusively use uv for the Python environment in this project.
75+
76+
## Environment commands
77+
- Use uv to install, sync, and lock Python dependencies
78+
- Never use pip, pip-tools, poetry, or conda for dependency management
79+
80+
Use these commands:
81+
- Install dependencies: `uv add <package>`
82+
- Remove dependencies: `uv remove <package>`
83+
- Sync dependencies: `uv sync`
84+
85+
## Running Python Code
86+
- Run a Python script with `uv run <script-name>.py`
87+
- Run Python tools like pytest with `uv run pytest`

docs/productive/envs/uv/index.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ Declare, lock and automatically update dependencies
5151

5252
:ref:`update-uv-lock` describes how you can use ``uv lock --upgrade`` to update
5353
all dependencies and :samp:`uv lock --upgrade-package {PACKAGE}=={VERSION}` to
54-
update individual dependencies in a controlled manner. We describe how you can
55-
regularly update the dependencies of your project automatically in
56-
:doc:`dependency-bot`. These measures significantly increase the security of
57-
your project.
54+
update individual dependencies in a controlled manner.
55+
56+
:doc:`claude-cursor` describes how you can create a configuration so that Claude
57+
Code or Cursor also uses uv reliably.
58+
59+
We describe how you can regularly update the dependencies of your project
60+
automatically in :doc:`dependency-bot`. These measures significantly increase
61+
the security of your project.
5862

5963
.. seealso::
6064
* :ref:`lock-dependencies`
@@ -73,4 +77,5 @@ Python environments.
7377

7478
cicd
7579
dependency-bot
80+
claude-cursor
7681
docker

0 commit comments

Comments
 (0)