---
title: Installation
description: How to install and set up Varlock in your project
---

import ExecCommandWidget from "@/components/ExecCommandWidget.astro";
import { LinkButton, TabItem, Tabs } from "@astrojs/starlight/components";

There are two ways to install Varlock:

1. Install as a `package.json` dependency in JavaScript/TypeScript projects (the `varlock` CLI package)
2. Install as a standalone binary

If you prefer to let your AI agent install Varlock for you, you can skip these instructions and build a prompt for your agent:

<div class="cta-button-row">
  <LinkButton href="/prompt-builder/">Open Prompt Builder</LinkButton>
</div>

### Docs MCP

There is also a Docs MCP server that exposes a search tool. See more details [here](/guides/mcp/#docs-mcp).

## As a JavaScript/TypeScript dependency

Requires:
- Node.js version 22 or higher

### Installation

To install `varlock` in your project, run:

<ExecCommandWidget command="varlock init" showBinary={false} dlx={true} />

This will install `varlock` as a dependency and scan your project for `.env` files and create a `.env.schema` file in the root of your project. Depending on your project configuration, it will optionally:
- Remove your existing `.env.example` file
- Add decorators to your `.env.schema` file to specify the type of each environment variable

For AI agent workflows, use non-interactive mode instead:

<ExecCommandWidget command="varlock init --agent" showBinary={false} dlx={true} />

## As a standalone binary

To install `varlock` CLI as a binary, run:

```bash
# Install via homebrew
brew install dmno-dev/tap/varlock

# OR via cURL
curl -sSfL https://varlock.dev/install.sh | sh -s
```

Then run the setup wizard to help you get started:
```bash
varlock init
```

:::note[Windows Defender]
If Windows flags `varlock-local-encrypt.exe`, see the [local encryption guide, Windows Defender false positives](/guides/local-encryption/#windows-defender-false-positives) for verification and recovery steps.
:::

## Varlock skill

Then install the Varlock agent skill:

<Tabs>
  <TabItem label="skills">

```bash
npx skills add dmno-dev/varlock
```

  </TabItem>
  <TabItem label="GitHub CLI">

Requires GitHub CLI v2.90+.

```bash
gh skill install dmno-dev/varlock varlock
```

  </TabItem>
</Tabs>

See the [AI Tools guide](/guides/ai-tools/#install-the-varlock-skill) for update commands and agent-specific options.

## Editor and shell tooling

Varlock ships with first-party tooling that makes authoring `.env.schema` files much easier. Set these up right after installing the CLI.

### VS Code extension

Install the [**@env-spec VS Code extension**](/env-spec/vs-code-ext/) from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=varlock.env-spec-language) or [Open VSX](https://open-vsx.org/extension/varlock/env-spec-language) (for Cursor, Windsurf, and other VS Code forks).

It provides syntax highlighting, decorator and `@type` IntelliSense, `$KEY` reference completion, and inline validation while you edit `.env.schema` and other `@env-spec` files.

### Shell completion

Enable tab completion for varlock commands and flags in bash, zsh, or fish. See the [Shell completion guide](/guides/shell-completion/) for one-time setup. Usually, adding `eval "$(varlock complete)"` to your shell profile is enough.

