|
| 1 | +Claude Code oder Cursor für uv konfigurieren |
| 2 | +============================================ |
| 3 | + |
| 4 | +Wie konfigurieren wir `Claude Code <https://claude.com/product/claude-code>`_ |
| 5 | +oder `Cursor <https://cursor.com>`_, damit automatisch uv anstelle von pip für |
| 6 | +die Python-Paketverwaltung verwendet wird? |
| 7 | + |
| 8 | +.. tab:: Claude Code |
| 9 | + |
| 10 | + Claude Code verwendet :file:`CLAUDE.md`-Dateien, um Speicher und Kontext |
| 11 | + eures Projekts zu konfigurieren, wodurch eine einheitliche Tooling-Umgebung |
| 12 | + für euren gesamten Entwicklungs-Workflow gewährleistet wird. |
| 13 | + |
| 14 | + Vorausgesetzt, Claude Code und uv sind bereits auf eurem System installiert |
| 15 | + und ihr habt bereits ein uv-basiertes Python-Projekt :abbr:`z. B. (zum |
| 16 | + Beispiel)` erstellt mit :ref:`uv init <uv-package-structure>`. |
| 17 | + |
| 18 | + .. tip:: |
| 19 | + Ihr könnt den ``/init``-Befehl in Claude Code verwenden um euch |
| 20 | + automatisch eine :file:`CLAUDE.md`-Datei erstellen zu lassen und sie |
| 21 | + anschließend mit uv-spezifischen Instruktionen zu ergänzen. |
| 22 | + |
| 23 | + .. code-block:: md |
| 24 | + :caption: CLAUDE.md |
| 25 | +
|
| 26 | + # Python environment with uv |
| 27 | + Exclusively use uv for the Python environment in this project. |
| 28 | +
|
| 29 | + ## Environment commands |
| 30 | + - Use uv to install, sync, and lock Python dependencies |
| 31 | + - Never use pip, pip-tools, poetry, or conda for dependency management |
| 32 | +
|
| 33 | + Use these commands: |
| 34 | + - Install dependencies: `uv add <package>` |
| 35 | + - Remove dependencies: `uv remove <package>` |
| 36 | + - Sync dependencies: `uv sync` |
| 37 | +
|
| 38 | + ## Running Python Code |
| 39 | + - Run a Python script with `uv run <script-name>.py` |
| 40 | + - Run Python tools like pytest with `uv run pytest` |
| 41 | +
|
| 42 | + .. tip:: |
| 43 | + Denkt daran, eure projektspezifische :file:`CLAUDE.md`-Datei mit :doc:`Git |
| 44 | + </productive/git/index>` zu verwalten, damit alle im Team, die mit Claude |
| 45 | + Code arbeiten, automatisch die gleiche Konfiguration erhalten. |
| 46 | + |
| 47 | + .. seealso:: |
| 48 | + * `Claude Docs <https://docs.claude.com/en/home>`_ |
| 49 | + * `Manage Claude's memory |
| 50 | + <https://docs.claude.com/en/docs/claude-code/memory>`_ |
| 51 | + |
| 52 | +.. tab:: Cursor |
| 53 | + |
| 54 | + `Cursor Rules <https://cursor.com/docs/context/rules>`_ können verwendet |
| 55 | + werden, um uv anstelle von pip zu verwenden. |
| 56 | + |
| 57 | + Vorausgesetzt, Cursor und uv sind bereits auf eurem System installiert und |
| 58 | + ihr habt bereits ein uv-basiertes Python-Projekt :abbr:`z. B. (zum Beispiel)` |
| 59 | + erstellt mit :ref:`uv init <uv-package-structure>`. |
| 60 | + |
| 61 | + Anschließend könnt ihr für eure Cursor Rules eine *Cursor Markdown |
| 62 | + Context*-Datei :file:`uv.mdc` in :samp:`{PROJECT}/.cursor/rules/` erstellen |
| 63 | + in :menuselection:`View Menu --> Command Palette --> New Cursor Rule` mit |
| 64 | + |
| 65 | + * Name: ``uv`` |
| 66 | + * Rule Type: *Agent Requested* |
| 67 | + * Description: *Exclusively use uv for the Python environment in this project.* |
| 68 | + |
| 69 | + Anschließend könnt ihr folgende Regeln hinzufügen: |
| 70 | + |
| 71 | + .. code-block:: md |
| 72 | + :caption: .cursor/rules/uv.mdc |
| 73 | +
|
| 74 | + # Python environment with uv |
| 75 | + Exclusively use uv for the Python environment in this project. |
| 76 | +
|
| 77 | + ## Environment commands |
| 78 | + - Use uv to install, sync, and lock Python dependencies |
| 79 | + - Never use pip, pip-tools, poetry, or conda for dependency management |
| 80 | +
|
| 81 | + Use these commands: |
| 82 | + - Install dependencies: `uv add <package>` |
| 83 | + - Remove dependencies: `uv remove <package>` |
| 84 | + - Sync dependencies: `uv sync` |
| 85 | +
|
| 86 | + ## Running Python Code |
| 87 | + - Run a Python script with `uv run <script-name>.py` |
| 88 | + - Run Python tools like pytest with `uv run pytest` |
0 commit comments