# install_package_command

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/update_check/install_package_command)

Return the shell command that adds a package to the dcode tool env.

The result is built for *execution* (via `perform_install_package`), not for
display — surfacing raw `uv tool` invocations to the user is intentionally
avoided. `package` is validated here against PEP 508 grammar and then
`shlex.quote`-d by the shared builder: the validation already blocks shell
metacharacters, so the quoting is defense in depth that keeps the command
safe even if the pattern is later loosened.

Delegates to `_uv_tool_install_command` (the same builder the extras path
uses), passing the new package as a `--with` requirement. That builder folds
already-installed extras into the pinned `deepagents-code[...]` requirement,
and preserves the uv-managed Python interpreter and the receipt's existing
`--with` packages. Without this, reinstalling to add a second package would
replace the tool with a plain `deepagents-code` (dropping extras the user
added through `/install <extra>`), rebuild with only the newest `--with`
package (dropping previously configured custom providers), or silently
downgrade when the latest stable app depends on prerelease packages.

Like the extras path (`_install_extra_uv_tool_command`), passes
`reinstall=True` so the upgrade rebuilds the tool environment cleanly; see
`_uv_tool_install_command`'s `reinstall` parameter for why an in-place
upgrade is unsafe.

## Signature

```python
install_package_command(
    package: str,
    *,
    distribution_name: str = 'deepagents-code',
) -> str
```

## Description

Propagates `ExtrasIntrospectionError` if a receipt-sourced extra name fails
PEP 508 validation, and `ToolRequirementIntrospectionError` if the uv tool
receipt's selected extras, interpreter, or `--with` packages cannot be
determined safely.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `package` | `str` | Yes | Package name to install into the existing tool environment. |
| `distribution_name` | `str` | No | Name of the installed distribution to inspect for already-installed extras and uv receipt requirements. (default: `'deepagents-code'`) |

## Returns

`str`

Shell command string suitable for execution via the shell.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/3812967c84d90619848f3185f22470204fc88bd8/libs/code/deepagents_code/update_check.py#L3491)