---
title: "Init"
description: "Scaffold AI-agent-safe ignore files in your project."
canonical_url: "https://shelve.cloud/docs/cli/init"
---
# Init

> Scaffold AI-agent-safe ignore files in your project.

The `init` command prepares a repository for use with Shelve and, crucially, keeps your `.env*` files out of the context of AI coding agents. Running it is a one-off setup step — run it once per project.

```bash [terminal]
shelve init
shelve init --cwd ./packages/my-app
shelve --json init
```

## What it does

- Creates (or updates) an ignore file for every major AI agent so they can never read cached secrets:

  - `.cursorignore`
  - `.aiderignore`
  - `.codeiumignore`
  - `.continueignore`
  - `.aigignore`
- Appends a managed block to your `.gitignore` if one is not already present, so the encrypted cache directory (`.shelve/`) and all `.env*` files stay out of version control. `.env.example` and `.env.template` are whitelisted so you can still commit references.

Each ignore file is framed with `# shelve-managed-block` / `# end shelve-managed-block` markers. Running `shelve init` again only rewrites the managed block — your own entries above and below are preserved.

## Options

<field-group>
<field name="cwd" type="string">

Directory to initialize. Defaults to the current working directory.

</field>
</field-group>

With global `--json`, stdout returns `{ writtenFiles, skippedFiles, gitignoreUpdated }`.

## Why this matters

AI coding agents (Cursor, Claude Code, Codex, Aider, Continue…) can read every file in your workspace unless you tell them otherwise. If you ever run `shelve pull` to write a `.env` to disk, an agent can trivially exfiltrate its contents into a prompt or a suggested commit. `shelve init` closes that hole in one command.

<callout type="info">

Even with agent ignore files in place, prefer `shelve run -- <cmd>`: it pipes secrets to your subprocess through the environment and never writes them to disk in the first place.

</callout>


## Sitemap

See the full [sitemap](https://shelve.cloud/sitemap.md) for all pages.
