# Cursor

Learn how to connect Buddy with Cursor and run the Cursor action in your CI/CD pipelines.

## What is Cursor?

Cursor provides an agent that can read your codebase, run commands, and modify files. Buddy uses the Cursor Agent CLI to run this agent inside a pipeline.

By integrating Buddy with Cursor you can add the **Cursor** action to your [pipelines](/docs/ai-agents/pipelines.md) and let the agent review code, generate changes, or automate routine engineering tasks on every push, on a schedule, or on demand.

<Hint type="info">

To use Buddy directly from the Cursor editor, See [Cursor with Buddy](/docs/ai-agents/agents/cursor.md).

</Hint>

## Setting up Cursor integration

1. Go to the <u>Integrations</u> tab and click **New integration**.

2. Look up and click **Cursor**.

![Cursor on the list of available integrations](/docs/integrations/cursor/cursor-integration-list.png 1288x746)

3. A configuration window will show up. Here you provide:

- **Name** and **ID** of the integration
- **Scope** - whether the integration is available across the whole <u>Workspace</u>, a single <u>Project</u>, or a specific <u>Environment</u>
- **API key** - your Cursor User API Key (see below)

<Hint type="info">

You can adjust who can use the integration and where in the <u>Permissions</u> tab.

</Hint>

![Cursor integration configuration](/docs/integrations/cursor/cursor-integration-form.png 1309x584)

4. Once done, click **Add a new integration** to finish configuration.

## Authorization

Authorize with a Cursor **User API Key**. The value always starts with `crsr_`.

To obtain the key:

1. Sign in to your Cursor account.

![Signing in to the Cursor dashboard](/docs/integrations/cursor/cursor-dashboard-login.png 1450x739)

2. Go to [Cursor API Keys](https://cursor.com/dashboard/api?section=user-keys#user-api-keys "seo-nf") (also linked as **Get API key** in the form) and click **New API Key**.

![User API Keys section in the Cursor dashboard](/docs/integrations/cursor/cursor-api-keys.png 1458x627)

3. Name the key and pick how long it stays valid - **30 days**, **90 days**, **180 days** (recommended), **1 year**, or **never expires**. Then click **Save**.

![Naming a User API Key and setting its expiration](/docs/integrations/cursor/cursor-api-key-expiration.png 1444x576)

<Hint type="info">

A key that never expires is convenient for long-running pipelines, but it also never rotates. Prefer a bounded lifetime and set yourself a reminder to swap the key in the integration before it lapses - an expired key fails the action at runtime.

</Hint>

4. Copy the generated key - Cursor shows it only once and it cannot be retrieved later.

![User API Key Created window in the Cursor dashboard](/docs/integrations/cursor/cursor-api-key-created.png 886x584)

5. Paste it into the **API KEY** field in Buddy and click **Add a new integration**. The key is stored as an encrypted secret and passed to the pipeline as a secure environment variable, never saved in plain text in your repository.

![Cursor integration with the API key filled in](/docs/integrations/cursor/cursor-integration-filled.png 1359x675)

<Hint type="warning">

A User API Key carries **Admin** scope over your Cursor account, including the headless Agent CLI and the Cloud Agent API. Create a dedicated key per integration so you can revoke it without breaking anything else, and keep the integration <u>Scope</u> as narrow as the pipelines that use it.

</Hint>

Once the integration is added, you can use the **Cursor** action in your pipeline and reference the integration by its ID.

<Hint type="info">

Read how to configure [Cursor with YAML](/docs/yaml/yaml-actions/cursor.md) and [Cursor POST parameters](/docs/api/actions/add/cursor.md).

</Hint>


---
Original source: https://buddy.works/docs/integrations/cursor