Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-4-20250514· AnthropicHugging Face LMArena Human Preference 140K

How do I add a dependency to a group like dev using uv add?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Metallama-3.3-70b-instruct’s answer.
  1. User

    How do I add a dependency to a group like dev using uv add?

  2. Claude Assistant

    You can add a dependency to a development group using the --group flag:

    uv add --group dev package-name
    

    For example, to add pytest as a development dependency:

    uv add --group dev pytest
    

    This will add the package to the [dependency-groups.dev] section in your pyproject.toml file rather than the main [project.dependencies] section.

    You can also add multiple packages at once:

    uv add --group dev pytest black mypy
    

    If you need to specify version constraints, you can do that as well:

    uv add --group dev "pytest>=7.0" "black>=22.0"
    
  3. User

    And how do I add a package to one of my extras using uv add?

  4. Claude Assistant

    You can add a package to an optional dependency group (extra) using the --optional flag:

    uv add --optional extra-name package-name
    

    For example, to add a package to a "docs" extra:

    uv add --optional docs sphinx
    

    This will add the package to the [project.optional-dependencies.docs] section in your pyproject.toml file.

    You can add multiple packages to the same extra:

    uv add --optional docs sphinx sphinx-rtd-theme
    

    And you can specify version constraints as well:

    uv add --optional docs "sphinx>=5.0" "sphinx-rtd-theme>=1.0"
    

    The extra will then be installable with:

    uv pip install -e ".[docs]"
    

    or when installing your package:

    uv pip install "your-package[docs]"
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.