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

# link

> Link your local directory to an Openlayer project

The `openlayer link` command links your local directory to an [Openlayer project](https://docs.openlayer.com/workspace-and-projects/creating-and-loading-projects.md).

> [!NOTE]
>
> If you are setting up a directory for the first time, use
> [`openlayer init`](https://docs.openlayer.com/api-reference/cli/commands/init) instead. It signs you in, creates or links
> the project, and scaffolds your `openlayer.json` in one guided flow, so no separate `link`
> step is needed.
>
> Reach for `link` when your configuration already exists and you only need the link — for
> example to connect an existing `openlayer.json` to a project, or to re-point a directory at a
> different project. When creating a new project, `link` reads the task type from the
> `openlayer.json` already in the directory rather than asking for it.

## Usage

```bash theme={null}
openlayer link
```

When no arguments are provided, an interactive prompt will be displayed asking the user
to confirm that they want to set up a link between the local directory and an Openlayer project,
if they want to link to an existing project or create a new one, and for the project name.

The `--project` name can also be provided as a flag:

```bash theme={null}
openlayer link --project=[project name]
```

## Non-interactive linking

For CI and coding agents, `--yes` (or `-y`) links the directory to the project named by
`--project` with no prompts at all. [`--output-mode ci`](https://docs.openlayer.com/api-reference/cli/global-options#output-mode)
implies it:

```bash theme={null}
openlayer link --project my-project --yes
```

The project has to exist already: without `--project`, or when no project in the workspace
has that name, `link` fails instead of asking.

> [!TIP]
>
> If your CI job only needs to push to an existing project, set
> `OPENLAYER_PROJECT_ID` instead of linking — see [environment
> variables](https://docs.openlayer.com/api-reference/cli/global-options.md#environment-variables).

## Flags

| Flag | Default | Description |
| - | - | - |
| `--project` | `""` | Name of the project to link to. |
| `--yes` | `false` | Link non-interactively to the project given by `--project`, skipping all prompts. |

[Global options](https://docs.openlayer.com/api-reference/cli/global-options.md) such as `--api-key`, `--profile-name` and
`--output-mode` also apply.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.