# gpm list

List packages installed in the current project or globally.

## Usage

```bash
gpm list [flags]
```

## Flags

| Flag            | Description                              | Default |
| --------------- | ---------------------------------------- | ------- |
| `--depth <int>` | Maximum depth of dependency tree to show | `1`     |
| `--dev`         | List only development dependencies       | `false` |
| `--global`      | List globally installed packages         | `false` |
| `--production`  | List only production dependencies        | `false` |
| `--json`        | Output results in JSON format            | `false` |

## Description

The `gpm list` command displays all packages installed in the current project or globally. This command provides detailed information about package versions, dependencies, and installation status.

### Supported Operations

* **Project Packages**: List packages in current project
* **Global Packages**: List globally installed packages
* **Dependency Tree**: Show package dependency hierarchy
* **Filter by Type**: Production or development dependencies

## Examples

### Basic Usage

```bash
# List all installed packages
gpm list

# List with dependency tree
gpm list --depth 2

# List only production dependencies
gpm list --production
```

### Global Packages

```bash
# List global packages
gpm list --global

# List global packages with details
gpm list --global --depth 2
```

### Advanced Usage

```bash
# JSON output for scripting
gpm list --json

# List development dependencies
gpm list --dev

# List with full dependency tree
gpm list --depth 0
```

## Output Formats

### Human Format (Default)

```
Installed Packages
─────────────────────────────────────────
Engine:   unity
Project:  /path/to/project
Registry: https://registry.gpm.sh
─────────────────────────────────────────

Production Dependencies:
  com.unity.analytics@2.1.0
  com.unity.timeline@1.7.4
  com.unity.textmeshpro@3.0.6

Development Dependencies:
  com.company.test-utils@1.0.0

─────────────────────────────────────────
4 packages installed
```

### JSON Format (`--json`)

```json
{
  "success": true,
  "engine": "unity",
  "project": "/path/to/project",
  "registry": "https://registry.gpm.sh",
  "packages": {
    "production": [
      {
        "name": "com.unity.analytics",
        "version": "2.1.0",
        "registry": "https://registry.gpm.sh"
      }
    ],
    "development": [
      {
        "name": "com.company.test-utils",
        "version": "1.0.0",
        "registry": "https://registry.gpm.sh"
      }
    ]
  },
  "total": 4,
  "message": "4 packages installed"
}
```

## Dependency Tree

### Tree Structure

```bash
# Show dependency tree
gpm list --depth 2
```

```
Installed Packages
─────────────────────────────────────────
Engine:   unity
Project:  /path/to/project
Registry: https://registry.gpm.sh
─────────────────────────────────────────

com.unity.analytics@2.1.0
├── com.unity.services.core@1.10.1
└── com.unity.services.analytics@1.0.0
    └── com.unity.services.core@1.10.1

com.unity.timeline@1.7.4
├── com.unity.ugui@1.0.0
└── com.unity.animation@6.0.0

─────────────────────────────────────────
2 packages installed
```

### Tree Depth Control

```bash
# Show only top-level packages
gpm list --depth 0

# Show 2 levels of dependencies
gpm list --depth 2

# Show all dependencies
gpm list --depth 10
```

## Global Package Management

### Listing Global Packages

```bash
# List all global packages
gpm list --global

# List global packages with tree
gpm list --global --depth 2
```

### Global Package Output

```
Global Packages
─────────────────────────────────────────
Registry: https://registry.gpm.sh
─────────────────────────────────────────

com.unity.analytics@2.1.0
com.unity.timeline@1.7.4
com.company.global-utils@1.0.0

─────────────────────────────────────────
3 packages installed globally
```

## Filtering Options

### Production Dependencies

```bash
# List only production dependencies
gpm list --production
```

### Development Dependencies

```bash
# List only development dependencies
gpm list --dev
```

### Combined Filters

```bash
# List production dependencies with tree
gpm list --production --depth 2

# List global development packages
gpm list --global --dev
```

## Engine-Specific Behavior

### Unity

For Unity projects, `gpm list` reads from:

* **Packages/manifest.json**: Package dependencies
* **Scoped Registries**: Registry configuration
* **Package Cache**: Installed package information

### Godot (Planned)

For Godot projects, `gpm list` will read from:

* **addons/**: Installed addon packages
* **project.godot**: Package references

### Unreal Engine (Planned)

For Unreal projects, `gpm list` will read from:

* **Plugins/**: Installed plugin packages
* **.uproject**: Plugin references

## Error Handling

### Common Scenarios

* **No packages found**: `No packages directory found`
* **Engine not detected**: `No supported engine detected`
* **Invalid project**: `Project validation failed`
* **Registry error**: `Failed to fetch package information`

### Troubleshooting

1. **No packages found**: Run `gpm install <package>` to install packages
2. **Engine not detected**: Specify `--engine unity` or check project structure
3. **Invalid project**: Verify project is a valid game engine project
4. **Registry error**: Check network connection and registry URL

## Use Cases

### Development Workflow

```bash
# Check installed packages
gpm list

# Check for updates
gpm update --dry-run

# Update packages
gpm update
```

### CI/CD Integration

```bash
# Verify package installation
gpm list --json | jq '.packages.production | length'

# Check specific package
gpm list --json | jq '.packages.production[] | select(.name == "com.unity.analytics")'
```

### Team Collaboration

```bash
# Share package list
gpm list --json > packages.json

# Restore packages
gpm install
```

## Best Practices

### Regular Maintenance

```bash
# List packages regularly
gpm list

# Check for unused packages
gpm list --depth 2

# Clean up unused packages
gpm uninstall unused-package
```

### Production Monitoring

```bash
# Monitor production dependencies
gpm list --production --json

# Check for security updates
gpm update --dry-run
```

## Related Commands

* [`gpm add`](/cli-reference/cli/package-management/add.md) - Add packages to project
* [`gpm install`](/cli-reference/cli/package-management/install.md) - Install packages
* [`gpm update`](/cli-reference/cli/package-management/update.md) - Update packages
* [`gpm uninstall`](/cli-reference/cli/package-management/uninstall.md) - Remove packages

## See Also

* [Package Management Overview](/cli-reference/cli/package-management.md)
* [Unity Engine Support](https://github.com/gpm-sh/docs/blob/main/engines/unity.md)
* [Package Dependencies](https://github.com/gpm-sh/docs/blob/main/packages/dependencies.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gpm.sh/cli-reference/cli/package-management/list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
