#### Cloud Agents

# Automations

[Video: watch the walkthrough](https://stream.mux.com/00QMZHDmPVrg00wxQglgnYXlXZ639VpcYzMR1g314vvvs.m3u8)

Grok Build Automations run [cloud agents](/build/agents-window/cloud-agent) in the background, either on a schedule or in response to events from GitHub, GitLab, Slack, webhooks, Linear, and more.

Automations can be used to automate tasks like [reviewing recent PR commits for bugs](https://cursor.com/marketplace/automations/find-bugs), [performing deep review for vulnerabilities](https://cursor.com/marketplace/automations/find-vulnerabilities), [triaging bugs in Slack](https://cursor.com/marketplace/automations/fix-slack-bugs), and [summarizing changes to your codebase on a schedule](https://cursor.com/marketplace/automations/daily-digest).

## Getting started

Create a new automation in the [Agents Window](/build/agents-window/agent/agents-window), at [cursor.com/automations](https://cursor.com/automations), with the `/automate` skill from a local agent session, or from a template in the [Grok Build Marketplace](https://cursor.com/marketplace/automations).

The `/automate` skill lets you describe the workflow you want in plain language. Grok Build configures the automation's triggers, instructions, and tools for you.

For any path:

1. Choose a trigger, e.g. every hour or when a pull request is opened.
2. Write a prompt with instructions for the automation.
3. Choose optional tools the agent is able to use, such as Send to Slack, Comment on Pull Request, or tools from MCP.
4. Choose whether the automation needs a repository, multiple repositories, or no repository at all.
5. Save and activate the automation.

The Automations page also includes three managed agents:

* [Bugbot](/build/agents-window/bugbot) reviews pull requests for bugs and code quality issues.
* [Security Review](/build/agents-window/security-review) reviews pull requests for vulnerabilities, and [Vulnerability Remediation](/build/agents-window/vulnerability-remediation) scans codebases and patches what it finds.
* [PR Routing & Approval](/build/agents-window/approval-agents) routes pull requests to reviewers and can approve low-risk changes.

Open these from their cards under **From Cursor**. They don't appear in the **Mine** or **Team** automation lists.

## Billing

Automations create cloud agents and are billed based on cloud agent usage. See [cloud agent pricing](/build/agents-window/models-and-pricing#model-pricing) for details.

> [!NOTE]
>
> Automations use each model's maximum supported context window because they run as cloud agents. There is no context-window toggle.

How usage is billed depends on **Run as** in [Share](#share):

* **Me**: Usage is billed to you. Other members see this option as **Creator**.
* **Service account**: Usage is billed to the team's usage pool. The automation runs as its own dedicated service account, so it does not use any member's personal usage.

Personal accounts always bill to you. They do not have a Share menu.

## Triggers

Triggers decide when an automation runs. An automation can have more than one trigger and is run when any trigger fires.

> [!NOTE]
>
> For certain triggers like Slack or cron schedules, Grok Build defaults to not using a repository. If your automation should make code changes, specify which repository or repositories agents should work in. For source control triggers, specifying a repo or multiple repos is required.

### Scheduled triggers

Scheduled triggers run on a recurring schedule. Choose from preset options or enter a cron expression for precise control.

Scheduled triggers may run with a delay but will not start before the indicated time.

### Source control triggers

Source control triggers respond to pull request and push events from your connected Git provider: GitHub, GitLab, and Bitbucket Cloud. Connect the automation to one repository or a multi-repo environment.

Every connected provider supports the core pull request and push triggers:

* **Draft opened** - When a draft pull request is created.
* **Pull request opened** - When a non-draft PR is created or a draft is marked ready for review.
* **Pull request pushed** - When new commits are pushed to an existing PR.
* **Pull request merged** - When a PR is merged.
* **Push to branch** - When commits are pushed to a specific branch outside a pull request.
* **Comment added** - When someone leaves a top-level comment on a pull request.

GitHub supports the most triggers. GitLab and Bitbucket support the core triggers above, plus a few extras listed in their sections below.

#### GitHub triggers

GitHub is the reference provider and supports every source control trigger. Alongside the core triggers, it adds:

* **Pull request label changed** - When a specific label, or any label, is added to or removed from a pull request.
* **Issue label changed** - When a label is added to or removed from a non-PR issue.
* **CI completed** - When a GitHub check finishes on a pull request or branch.
* **Issue comment** - When a comment is made on a non-PR issue.
* **PR review comment** - When an inline comment is left on a pull request diff.
* **PR review submitted** - When a review is submitted as approved, changes requested, or commented.
* **Review thread updated** - When a review thread on a pull request is marked resolved or unresolved.
* **Workflow run completed** - When a GitHub Actions workflow run started by a `push` event finishes. Runs started by `pull_request`, `workflow_dispatch`, or `schedule` don't match; use **CI completed** for pull request checks. The **Workflow** filter matches the workflow file name, such as `deploy.yml`.

The [Grok Build Marketplace](https://cursor.com/marketplace/automations) includes templates for [triaging failed GitHub Actions](https://cursor.com/marketplace/automations/triage-github-workflow-failures) and [fixing pull request review comments](https://cursor.com/marketplace/automations/autofix-pr-review-comments).

#### GitLab triggers

Alongside the core triggers, GitLab adds:

* **Pull request label changed** - When a label is added to or removed from a merge request.
* **Pull request approved** - When a merge request is approved.

#### Bitbucket triggers

Bitbucket support covers Bitbucket Cloud (`bitbucket.org`) only. Bitbucket Server and Data Center are not supported. Alongside the core triggers, it adds:

* **Pull request approved** - When a pull request is approved.

Bitbucket Cloud has no pull request label or inline review-comment triggers.

> [!NOTE]
>
> Pull request triggers don't run on PRs opened from forks. These runs fail with a "Fork pull requests not supported" error because the branch only exists on the fork, and running external code with the repo's permissions isn't safe. The exception is **Pull request merged** triggers, which still run because they start from the merge commit. To work around this, push the branch to the repo itself and open the PR from there.

### Slack triggers

Slack triggers respond to events from the [Grok Build Slack integration](/build/agents-window/integrations/slack).

> [!NOTE]
>
> Only public Slack channels are visible to Slack triggers at this time.

* **New message in channel** - When a message is sent to a connected Slack channel. Without a message filter, the trigger only fires on top-level channel messages. Add a keyword or regex filter if you want runs from threaded replies as well.
* **Emoji reaction** - When someone reacts to a Slack message with a specific emoji.
* **Channel created** - When a new public Slack channel is created in your workspace.

### Webhook triggers

Webhook triggers create a private HTTP endpoint for your automation. POST to the endpoint to start a run. You can use webhooks to connect automations to internal systems, CI pipelines, monitoring tools, and more.

Save the automation to get its webhook URL, then click **Generate auth header** to create its webhook API key. Send the key in an `Authorization: Bearer` header; **Copy auth header** copies that whole header line, so paste it over `Authorization: Bearer YOUR_WEBHOOK_API_KEY` rather than after `Bearer`. The body can be any JSON. If it's an object with a string `context` field, the agent gets that text with the automation's prompt, and the other fields as the webhook payload.

```bash
curl --request POST \
  --url https://api2.cursor.sh/automations/webhook/YOUR_AUTOMATION_ID \
  --header 'Authorization: Bearer YOUR_WEBHOOK_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{ "context": "Summarize incident INC-4821 for the on-call channel." }'
```

For an automation that runs as the team's service account, you can send a team API key with **Trigger automations** (`agent:*`) or **Admin** (`admin:*`) instead of the webhook API key. **Run Cloud Agents** alone doesn't reach the webhook.

When a cloud agent starts, the `200` response includes its ID as `backgroundComposerId`. Other responses:

* `400`: the request was malformed, the key can't start this automation, or no cloud agent started. The `error` field says why.
* `401`: the key is missing, unknown, or lacks the scope for this automation.
* `403` with `team_ip_allowlist_violation`: the caller's IP address isn't on the team's IP allow list.
* `503` with `team_ip_allowlist_unavailable`: the IP allow list couldn't be checked. Retry the request.
* `422`: for an automation a [Project](/build/agents-window/agent/projects) set up, the `Idempotency-Key` header was already used with a different body. A retry with the same key and body reuses the first run.

To follow the run, use `backgroundComposerId` as the agent ID in the [Cloud Agents API](/build/agents-window/cloud-agent/api/endpoints). Poll [Get An Agent](/build/agents-window/cloud-agent/api/endpoints#get-an-agent) for its `latestRunId`, and [Get A Run](/build/agents-window/cloud-agent/api/endpoints#get-a-run) for that run's status and `result`. A service account automation's webhook API key can make these two calls for the agent it started. To [stream the agent](/build/agents-window/cloud-agent/api/endpoints#stream-an-agent) or [list its runs](/build/agents-window/cloud-agent/api/endpoints#list-runs), use a [service account API key](/build/agents-window/account/enterprise/service-accounts) from the automation's team with **Run Cloud Agents**. For an automation that runs as **Me**, make all of these calls with the creator's user API key.

An automation can continue in later runs on the same agent, for example when its [Terraform workflow](https://registry.terraform.io/providers/cursor/cursor/latest/docs) sets `effort_level = "hard"`, so a `FINISHED` run or an `IDLE` agent doesn't mean it's done. Nothing in the API marks the last run, so keep polling `latestRunId`. As a heuristic, keep polling for 10 minutes after the latest run ends, and stop if no newer run has appeared by then; a later run can still start after that.

### Linear triggers

Linear triggers respond to events from the [Grok Build Linear integration](/build/agents-window/integrations/linear).

* **Issue created** - When a new issue is created.
* **Status changed** - When an issue's status changes. Pick one or more statuses after **to** to run only when an issue moves into one of them, or keep **Any status**.
* **End of cycle** - When a Linear cycle completes.

### Sentry triggers

Sentry triggers run when error and issue events occur in your Sentry project. Use them to automatically investigate errors, identify root causes, and propose fixes. See the [Investigate Sentry issues](https://cursor.com/marketplace/automations/investigate-sentry-issues) marketplace template for a ready-made example.

* **Issue created** - When a new issue is created in Sentry.
* **Issue updated** - When an existing issue changes, such as a status or assignment update.
* **Any issue event** - Matches all issue event types.

### PagerDuty triggers

PagerDuty triggers run on incident events and can be helpful to automatically triage or even resolve incidents. Only team admins can connect or disconnect a team's PagerDuty integration.

* **Incident triggered** - When a new incident is created.
* **Incident acknowledged** - When an incident is acknowledged.
* **Incident resolved** - When an incident is resolved.
* **Any incident event** - Matches all incident event types.

## Tools

Grok Build Automations can have tools enabled for richer capabilities around GitHub, Slack, memory, MCP, and more. Automations also include the same base set of tools as other cloud agents. See [Cloud agent capabilities](/build/agents-window/cloud-agent/capabilities) for details.

When someone follows up on an automation run from the web, Slack, or GitHub, the agent doesn't use messaging or comment tools such as Send to Slack or Comment on pull request for that reply. Grok Build delivers the reply where the follow-up was sent.

### Pull request creation

Repo-backed automations can open pull requests after making code changes requested by the automation prompt. This tool is enabled by default for every automation.

> [!NOTE]
>
> The pull request is opened against the repositories specified for the source control trigger. For other triggers, it uses the repositories specified by the environment.

### Comment on pull request

Posts comments on a target pull request. Supports top-level review comments and inline code comments.

> [!TIP]
>
> If you enable approvals, the agent can also approve, request changes, and dismiss reviews. Otherwise, it can only post comments.

### Request reviewers

Requests reviewers on a target pull request. The agent can use `git`, memory, and other tools to identify domain experts.

### Send to Slack

Sends messages to a Slack channel. You can target a specific channel or let the agent dynamically choose any channel.

> [!NOTE]
>
> When you allow any channel, Grok Build also includes the read access needed for the agent to discover available public channels.

Note that the agent is granted read access to public channels that it can send messages to.

To have the agent tag people or groups, put Slack's mention tokens in your prompt as plain text, without backticks: `<@U123>` for a person and `<!subteam^S123|@handle>` for a user group. A user group's ID starts with `S`.

### Read Slack channels

Gives the agent read-only access to list and read messages from public Slack channels.

Use this when the agent needs more context before it replies or opens a pull request.

### MCP server

Connects an [MCP (Model Context Protocol)](/build/agents-window/mcp) server so the agent can use external tools and data sources.

> [!WARNING]
>
> Connecting an MCP server gives the agent access to every tool exposed by that server. Only connect servers you trust with the permissions your automation needs.

If an MCP server rejects an automation's credentials, the run continues without that server's tools, and its page shows an **MCP authentication failed** event. On Enterprise, [OpenTelemetry Export](/build/agents-window/enterprise/opentelemetry-export/wire#cursorcloud_agentmcp_auth_error) also sends it as a `cursor.cloud_agent.mcp_auth_error` log.

### Memories

Memories let the agent read and write persistent notes across runs for the same automation. Use this to build agents that remember and improve over time. Each memory is stored as a named entry (`MEMORIES.md` by default) that exists outside the agent's working filesystem.

Memories are enabled by default but can be disabled. Memories can be viewed and edited from the tool configuration UI.

Agents can delete outdated memory files during automation runs. You can also delete memory files from the tool configuration UI.

> [!NOTE]
>
> Memories persist across runs and should be used with caution if your automation handles untrusted input. Inputs may lead to misleading or malicious memories that unintentionally impact future automation runs.

### Computer use

Computer use lets cloud agents kicked off by automations use a computer the way a developer would. That means automations can operate a browser, produce screenshots or recordings, or use your internal services. It is included by default for every automation.

To make sure computer use is effective, ensure that you've configured a development environment for your automation. You can then ask for a demo in your automation instructions when you want the agent to show its work. For example, tell the agent to include a short screen recording after it changes a user-facing flow.

## Automation settings

### Model

You can select which model the cloud agent uses for your automation.

### Repositories

Choose whether the automation needs no repository, one repository, or a multi-repo environment.

The repository setting controls the codebase context for each run:

* **No repository**: The agent does not clone code. Use this for workflows that only need Slack, MCP, webhooks, Linear, or PagerDuty. It cannot edit code or open pull requests.
* **Single repository**: The agent works in one repository and branch. Use this when the automation should read, review, or change code in one codebase.
* **Multi-repo environment**: The agent works across the repositories in an environment. Use this when the task spans multiple codebases.

For certain triggers like Slack or cron schedules, Grok Build defaults to not using a repository. If your automation should make code changes, specify which repository or repositories agents should work in.

For source control triggers, specifying a repo or multiple repos is required.

#### Single-repo automations

By default, an automation runs against one repository and branch. This is the right choice when the agent should read, review, or change code in a single codebase.

Source control triggers infer the repository from the pull request. For other triggers, choose the repository and branch in the automation settings.

#### Multi-repo automations

Use a multi-repo environment when an automation needs to work across multiple repositories. Select multiple repos when you configure the environment, or choose an existing one from your [Cloud Agents dashboard](https://grok.com/dashboard/cloud-agents).

On [Self-Hosted Machines](/build/agents-window/cloud-agent/self-hosted#environments-on-self-hosted-machines), an automation uses only the environment's repositories. An any-repo pool worker started with `--clone-git-repos` checks out all of them. Other workers use the checkouts they already have.

When a team admin turns off **Allow Personal Machines**, automation runs can't use a worker registered with a personal login, such as a [My Machines](/build/agents-window/cloud-agent/self-hosted/my-machines) worker. To run automations on your own infrastructure, use a [pool](/build/agents-window/cloud-agent/self-hosted/pool) worker registered with a service account.

## Share

Team accounts set visibility and identity from **Share** on the automation detail header. Personal accounts do not have this menu.

### Run as

* **Me**: The automation runs with your auth. Usage is billed to you. Other members see this option as **Creator**.
* **Service account**: The automation runs as its own dedicated service account. Usage is billed to the team's usage pool. Only team admins can choose this.

### Access

* **Private**: Other team members cannot see the automation. Only you can manage it. Team admins can view and disable it.
* **Members can view**: Team members can view the automation. You manage it when it runs as you. Team admins manage it when it runs as the service account. Admins can turn it on or off, or delete it, in either case.
* **Members can edit**: Team members can view and edit the automation.

The menu also includes **Copy link**.

Changing **Run as** to **Service account** changes the identity the automation uses. It stops using your auth and starts using a service account dedicated to that automation. If the automation uses webhook triggers, [generate a new webhook API key](#webhook-triggers) after the change. If it uses MCPs or other integrations that rely on personal OAuth credentials, make sure those are configured for the team's service account instead. Only team admins can switch an automation to the service account. They can switch one set to **Members can view** or **Members can edit**. For a **Private** automation, only the creator can change **Share**, so the creator picks **Members can view** or **Members can edit** first. Once it runs as the service account, team admins can edit it.

### Service accounts for automations

Each automation set to **Run as: Service account** gets its own service account. Grok Build creates it the first time the automation is saved with that setting, whether from the automation editor or through the API or Terraform provider.

The [Grok Build Terraform provider](https://registry.terraform.io/providers/cursor/cursor/latest/docs) manages automations as `cursor_platform_workflow` resources. Authenticate it with a team service account's API key (the provider's `token`, or the `CURSOR_TOKEN` environment variable) and leave `team_id` unset. A workflow's `scope` sets its Share options: `team` runs as the service account and team admins manage it, `team_editable` runs as the service account and members can edit it, and `team_visible` runs as its owner and members can view it.

On Enterprise teams, these accounts are listed in Dashboard → Settings → API Keys → Service Accounts with names like `automation-<id>`. Neither the ID in the name nor the service account ID (`sa_...`) is the automation's ID.

Some older automations share a single team service account named `automations`. They move to their own service account the next time they are saved.

An automation that runs as a service account stops running if that service account is archived or deleted. Only archive an `automation-` service account once you're sure no automation still uses it.

## Delete and audit

Deleting an automation is permanent. Grok Build removes it and revokes its automation API keys, and it can't be restored.

On Enterprise, the team's [audit log](/build/agents-window/enterprise/compliance-and-monitoring#audit-logs) records when an automation shared with the team is created, edited, turned on or off, or deleted. Private automations aren't recorded.

## Identity

When an automation acts on external services, it uses the following identities:

* GitHub comments, review approvals, and reviewer requests run as `cursor`.
* Automations that run as you open pull requests as your GitHub account.
* Automations that run as the service account open pull requests as `cursor`.
* Slack messages are sent as the Build bot.

## Writing prompts

Prompts define what the agent should do. Write them the same way you would write instructions for a cloud agent run.

Tips:

* Be specific about what the agent should check, change, or produce.
* Reference the actions you enabled - you can at-mention tools or informally mention their names.
* Include decision rules for what to do in different cases.
* Set a quality bar for when the agent should open a pull request, comment, or do nothing.
* Describe the output format you want.

## Related

* [Agents Window](/build/agents-window/agent/agents-window)
* [Cloud agents overview](/build/agents-window/cloud-agent)
* [Cloud agent setup](/build/agents-window/cloud-agent/setup)
* [Cloud agent pricing](/build/agents-window/models-and-pricing#model-pricing)
* [Skills](/build/agents-window/skills)
* [GitHub integration](/build/agents-window/integrations/github)
* [GitLab integration](/build/agents-window/integrations/gitlab)
* [Slack integration](/build/agents-window/integrations/slack)
* [Microsoft Teams integration](/build/agents-window/integrations/microsoft-teams)
* [Linear integration](/build/agents-window/integrations/linear)
* [Automations help](/build/agents-window/help/ai-features/automations)
