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

# Installation

> Install @staplehire/staplehire-cli with npm, verify the staplehire binary, and run your first health check with staplehire doctor.

Install the Staplehire CLI globally with npm, then verify the `staplehire` binary before logging in.

```bash theme={null}
npm install -g @staplehire/staplehire-cli
staplehire --version
staplehire doctor
```

## Prerequisites

| Requirement        | Notes                                                                                         |
| ------------------ | --------------------------------------------------------------------------------------------- |
| Node.js            | Version 18 or newer                                                                           |
| npm                | Used for global installation                                                                  |
| Staplehire account | Required for `staplehire login` — sign up at [app.staplehire.com](https://app.staplehire.com) |

## Install

<Tabs>
  <Tab title="npm (recommended)">
    Installs the published package globally and puts the `staplehire` binary on your `PATH`.

    ```bash theme={null}
    npm install -g @staplehire/staplehire-cli
    staplehire --version
    ```
  </Tab>

  <Tab title="npx (no install)">
    Run a one-off command without installing globally. Useful in CI or to try the CLI.

    ```bash theme={null}
    npx --yes @staplehire/staplehire-cli doctor -q
    ```
  </Tab>

  <Tab title="From source">
    Use the monorepo build only when contributing to the CLI. The package lives at `packages/hire`.

    ```bash theme={null}
    git clone https://github.com/navindev26/Staplehire.git
    cd Staplehire/packages/hire
    npm install
    npm run build
    node bin/staplehire.mjs --version
    ```
  </Tab>
</Tabs>

The package name is `@staplehire/staplehire-cli`, and the binary it installs is `staplehire`.

## Verify the install

`doctor` checks four things: the CLI version (against the latest on npm), your API key and where it came from, the API gateway URL, and a live `GET /v1/me` roundtrip.

```bash theme={null}
staplehire doctor       # human-readable
staplehire doctor -q    # JSON only (for scripts and agents)
```

Example JSON output:

```json theme={null}
{
  "ok": true,
  "version": "0.7.1",
  "latest": "0.7.1",
  "api_url": "https://api.staplehire.com/…/staplehire-api",
  "checks": [
    { "name": "CLI Version", "status": "pass", "message": "v0.7.1 (latest)" },
    { "name": "API Key", "status": "pass", "message": "sh_live_xxxx…abcd (source: .env)" },
    { "name": "API URL", "status": "pass", "message": "https://api.staplehire.com/…/staplehire-api" },
    { "name": "API Validation", "status": "pass", "message": "GET /v1/me OK (142ms) — Acme Corp" }
  ]
}
```

<Note>
  Before you authenticate, the **API Key** and **API Validation** checks will report `fail` — that is expected. Run [`staplehire login`](/docs/authentication) (or set `STAPLEHIRE_KEY`), then re-run `doctor`.
</Note>

`doctor` exits `1` if any check fails, so it doubles as a CI preflight:

```bash theme={null}
staplehire doctor -q | jq -e '.ok'
```

## Keep the CLI up to date

Check whether a newer version is published on npm:

```bash theme={null}
staplehire update
```

```json theme={null}
{
  "current": "0.7.0",
  "latest": "0.7.1",
  "update_available": true,
  "upgrade_command": "npm install -g @staplehire/staplehire-cli@0.7.1"
}
```

Then run the `upgrade_command` it returns.

## FAQ

<AccordionGroup>
  <Accordion title="What package do I install?">
    `@staplehire/staplehire-cli`. It installs the `staplehire` binary and (for TypeScript users) also exports the `@staplehire/hire` SDK.
  </Accordion>

  <Accordion title="Do I need Node.js installed globally?">
    Yes — Node.js 18 or newer. The CLI runs on Node and is distributed through npm.
  </Accordion>

  <Accordion title="Should CI run `staplehire login`?">
    No. Browser login is for local development. In CI, set `STAPLEHIRE_KEY` as a secret and verify with `staplehire doctor -q`. See [Use in CI](/docs/use-staplehire-cli-in-ci).
  </Accordion>

  <Accordion title="Where can I read the source?">
    The CLI and SDK live in the monorepo at [`navindev26/Staplehire`](https://github.com/navindev26/Staplehire) under `packages/hire`.
  </Accordion>
</AccordionGroup>

Related: [Authentication](/docs/authentication) · [Quickstart](/docs/quickstart) · [Use in CI](/docs/use-staplehire-cli-in-ci)
