# Installation

prek provides multiple installation methods to suit different needs and environments.

## Standalone Installer

The standalone installer automatically downloads and installs the correct binary for your platform:

Use `curl` to download the script and execute it with `sh`:

```bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.10/prek-installer.sh | sh
```

Use `irm` to download the script and execute it with `iex`:

```powershell
powershell -ExecutionPolicy ByPass -c "irm https://github.com/j178/prek/releases/download/v0.3.10/prek-installer.ps1 | iex"
```

Changing the [execution policy](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies) allows running a script from the internet.

Tip

The installation script may be inspected before use. Alternatively, binaries can be downloaded directly from [GitHub Releases](#github-releases).

## Package Managers

### PyPI

prek is published as Python binary wheel to PyPI, you can install it using `pip`, `uv` (recommended), or `pipx`:

```bash
# Using uv (recommended)
uv tool install prek

# Using uvx (install and run in one command)
uvx prek

# Adding prek to the project dev-dependencies
uv add --dev prek

# Using pip
pip install prek

# Using pipx
pipx install prek
```

### Homebrew (macOS/Linux)

```bash
brew install prek
```

### mise

To use prek with [mise](https://mise.jdx.dev) ([v2025.8.11](https://github.com/jdx/mise/releases/tag/v2025.8.11) or later):

```bash
mise use prek
```

### npm

prek is published as a [Node.js package](https://www.npmjs.com/package/@j178/prek) and can be installed with any npm-compatible package manager:

```bash
# npm
npm install -g @j178/prek

# pnpm
pnpm add -g @j178/prek

# bun
bun install -g @j178/prek
```

Or as a project dependency:

```bash
npm add -D @j178/prek
```

### Nix

prek is available via [Nixpkgs](https://search.nixos.org/packages?channel=unstable&show=prek&query=prek).

```shell
# Choose what's appropriate for your use case.
# One-off in a shell:
nix-shell -p prek

# NixOS or non-NixOS without flakes:
nix-env -iA nixos.prek

# Non-NixOS with flakes:
nix profile install nixpkgs#prek
```

### Conda

prek is available as `prek` via [conda-forge](https://anaconda.org/conda-forge/prek).

```shell
conda install conda-forge::prek
```

### Scoop (Windows)

prek is available via [Scoop](https://scoop.sh/#/apps?q=prek).

```powershell
scoop install main/prek
```

### Winget (Windows)

prek is available via [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/).

```powershell
winget install --id j178.Prek
```

### MacPorts

prek is available via [MacPorts](https://ports.macports.org/port/prek/).

```bash
sudo port install prek
```

### cargo-binstall

Install pre-compiled binaries from GitHub using [cargo-binstall](https://github.com/cargo-bins/cargo-binstall):

```bash
cargo binstall prek
```

## Docker

prek provides a Docker image at [`ghcr.io/j178/prek`](https://github.com/j178/prek/pkgs/container/prek).

See the guide on [using prek in Docker](../integrations/#docker) for more details.

## GitHub Releases

Pre-built binaries are available for download from the [GitHub releases](https://github.com/j178/prek/releases) page.

## Build from Source

Build from source using Cargo (Rust 1.89+ is required):

```bash
cargo install --locked prek
```

## prek skill for agents

To let agents use `prek`, install the `prek` skill with `gh skill` (`v2.90.0+`):

```bash
gh skill install j178/prek prek
```

## Updating

If installed via the standalone installer, prek can update itself to the latest version:

```bash
prek self update
```

For other installation methods, follow the same installation steps again.

## Shell Completion

Tip

Run `echo $SHELL` to determine your shell.

To enable shell autocompletion for prek commands, run one of the following:

```bash
echo 'eval "$(COMPLETE=bash prek)"' >> ~/.bashrc
```

```bash
echo 'eval "$(COMPLETE=zsh prek)"' >> ~/.zshrc
```

```bash
echo 'COMPLETE=fish prek | source' >> ~/.config/fish/config.fish
```

```powershell
Add-Content -Path $PROFILE -Value '$env:COMPLETE = "powershell"; prek | Out-String | Invoke-Expression; Remove-Item Env:\COMPLETE'
```

Then restart your shell or source the config file.

## Artifact Verification

Release artifacts are signed with [GitHub Attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations) to provide cryptographic proof of their origin. Verify downloads using the [GitHub CLI](https://cli.github.com/):

```console
$ gh attestation verify prek-x86_64-unknown-linux-gnu.tar.gz --repo j178/prek
Loaded digest sha256:xxxx... for file://prek-x86_64-unknown-linux-gnu.tar.gz
Loaded 1 attestation from GitHub API
✓ Verification succeeded!

- Attestation #1
  - Build repo:..... j178/prek
  - Build workflow:. .github/workflows/release.yml@refs/tags/vX.Y.Z
```

This confirms the artifact was built by the official release workflow.
