> ## Documentation Index
> Fetch the complete documentation index at: https://better-pm.fdarian.com/llms.txt
> Use this file to discover all available pages before exploring further.

# pm add

> Add dependencies to your project

## Overview

The `pm add` command adds dependencies to your project. It supports paste-friendly syntax that automatically extracts package names and flags from common package manager commands.

## Syntax

```bash theme={null}
pm add <packages...> [options]
```

## Options

<ParamField path="-D" type="boolean" default="false">
  Add as a dev dependency
</ParamField>

## Arguments

<ParamField path="packages" type="string[]" required>
  One or more package names to install. Supports paste-friendly syntax.
</ParamField>

## Paste-Friendly Syntax

Better PM intelligently parses common package manager commands, allowing you to paste commands directly from READMEs:

<CodeGroup>
  ```bash npm install theme={null}
  pm add "npm install -D typescript"
  # Automatically extracts: -D flag and package name
  ```

  ```bash pnpm add theme={null}
  pm add "pnpm add foo bar"
  # Extracts: foo and bar as packages
  ```

  ```bash bun add theme={null}
  pm add "bun add -D @scope/pkg"
  # Extracts: -D flag and scoped package name
  ```
</CodeGroup>

<Tip>
  You can paste entire install commands and Better PM will automatically extract the packages and flags.
</Tip>

## Examples

### Add Production Dependency

```bash theme={null}
pm add express
```

```bash Output theme={null}
Running: pnpm add express
```

### Add Development Dependency

```bash theme={null}
pm add -D typescript
```

```bash Output theme={null}
Running: pnpm add -D typescript
```

### Add Multiple Packages

```bash theme={null}
pm add react react-dom
```

```bash Output theme={null}
Running: pnpm add react react-dom
```

### Add Scoped Package

```bash theme={null}
pm add @types/node -D
```

```bash Output theme={null}
Running: pnpm add -D @types/node
```

### Paste Package Manager Commands

```bash theme={null}
# Copy from a README
pm add "npm install --save-dev eslint prettier"
```

```bash Output theme={null}
Running: pnpm add -D eslint prettier
```

<Info>
  Better PM automatically detects your project's package manager (pnpm, bun, or npm) and uses the appropriate command.
</Info>

## How It Works

The `add` command uses the `resolveAddArgs` function from `src/lib/parse-pm-command.ts` to intelligently parse the input:

1. Detects common package manager command patterns
2. Extracts the `-D` (or `--save-dev`) flag if present
3. Extracts package names, including scoped packages
4. Passes clean arguments to the underlying package manager

## Related Commands

* [pm remove](/commands/remove) - Remove dependencies
* [pm install](/commands/install) - Install dependencies
* [pm up](/commands/up) - Update dependencies
