Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(agents): apply cursor label to Cursor PRs (#17165)

Nikita Kabardin0e0458a11ee2
diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md
index 858f262111..aeb4c6e88e 100644
--- a/.agents/AGENTS.md
+++ b/.agents/AGENTS.md
@@ -209,6 +209,8 @@ langfuse/
- Open a same-repo reviewable PR after local verification (not a draft) and
test the resulting `pr-<N>.preview.langfuse.com` deployment with synthetic
data. Previews normally run Mon-Fri 08:00-24:00 Europe/Berlin.
+- After opening a PR, apply the GitHub `cursor` label. Do not wait for a
+ human to add it.
- Use Linear's git branch name (`lfe-XXXX-short-title`). Never create a
`cursor/` branch, even if a Cursor Cloud prompt suggests that prefix.
Repo guidance wins.
diff --git a/.agents/skills/cursor-agents-workflow/SKILL.md b/.agents/skills/cursor-agents-workflow/SKILL.md
index 852a072809..2f7759f8fb 100644
--- a/.agents/skills/cursor-agents-workflow/SKILL.md
+++ b/.agents/skills/cursor-agents-workflow/SKILL.md
@@ -1,12 +1,13 @@
---
name: cursor-agents-workflow
description: |
- Human handoff, Linear branch names, reviewable (non-draft) PRs, Claude,
- Greptile, and Codex review comments, preview test steps, proof of work
- posted on the GitHub PR, and review-doubt notes for Cursor agents. Use
- when a Cursor Cloud or Cursor desktop agent implements a Linear issue,
- opens a GitHub PR, asks a human to test, posts screenshots or videos,
- or handles Claude, Greptile, or Codex code-review comments.
+ Human handoff, Linear branch names, reviewable (non-draft) PRs, the
+ `cursor` GitHub label, Claude, Greptile, and Codex review comments,
+ preview test steps, proof of work posted on the GitHub PR, and
+ review-doubt notes for Cursor agents. Use when a Cursor Cloud or
+ Cursor desktop agent implements a Linear issue, opens a GitHub PR,
+ asks a human to test, posts screenshots or videos, or handles Claude,
+ Greptile, or Codex code-review comments.
---
# Cursor Agents Workflow
@@ -51,6 +52,13 @@ Open the GitHub PR as reviewable, not as a draft. Draft PRs hide the work
from reviewers and skip Claude/Greptile review workflows. Use a draft only
when a human asks for one.
+After opening the PR, apply the GitHub `cursor` label. Use the PR label
+tool. Do not wait for a human to add it, and do not substitute a `codex`
+or other agent label. A same-repo workflow also applies `cursor` when the
+author is `cursor[bot]`, the branch starts with `cursor/`, or the PR body
+contains the Cursor agent marker — still apply it yourself so the tag is
+present immediately.
+
Cursor Cloud PRs are opened as the Langfuse user who launched the agent. On
a non-draft same-repo PR from a write-access user, github-actions posts
`@claude review` automatically. Do not post that comment yourself on open.
diff --git a/.agents/skills/cursor-agents-workflow/agents/openai.yaml b/.agents/skills/cursor-agents-workflow/agents/openai.yaml
index 2fccbb803d..305f3c8f6d 100644
--- a/.agents/skills/cursor-agents-workflow/agents/openai.yaml
+++ b/.agents/skills/cursor-agents-workflow/agents/openai.yaml
@@ -1,4 +1,4 @@
interface:
display_name: "Cursor Agents Workflow"
- short_description: "Linear branches, PR proof, and review notes"
- default_prompt: "Use $cursor-agents-workflow for Cursor agent branch names, reviewable (non-draft) PRs, Claude/Greptile/Codex review comments, human preview test steps, proof-of-work posted on the GitHub PR, and review-doubt PR notes."
+ short_description: "Linear branches, cursor PR label, and review notes"
+ default_prompt: "Use $cursor-agents-workflow for Cursor agent branch names, reviewable (non-draft) PRs, the cursor GitHub label, Claude/Greptile/Codex review comments, human preview test steps, proof-of-work posted on the GitHub PR, and review-doubt PR notes."
diff --git a/.agents/skills/git-workflow/SKILL.md b/.agents/skills/git-workflow/SKILL.md
index 4918869f6a..2de6b2d8a0 100644
--- a/.agents/skills/git-workflow/SKILL.md
+++ b/.agents/skills/git-workflow/SKILL.md
@@ -56,6 +56,8 @@ operations.
- When a change is too large for one reviewable PR, split it into a chained
stack instead of widening the PR: use `pr-stack-workflow`.
- Open PRs as reviewable, not as drafts, unless a human asks for a draft.
+- Cursor agents apply the GitHub `cursor` label after opening a PR; see
+ `cursor-agents-workflow`. Do not leave that tag for a human.
- Do not post GitHub PR comments as the human author. Cursor agents that
comment as Cursor should leave one last comment with proof of user-visible
work (screenshot, video, or before/after on the PR, not only in chat) and
diff --git a/.agents/skills/langfuse-codebase-navigator/SKILL.md b/.agents/skills/langfuse-codebase-navigator/SKILL.md
index 1d286c9719..b5e7f9bb07 100644
--- a/.agents/skills/langfuse-codebase-navigator/SKILL.md
+++ b/.agents/skills/langfuse-codebase-navigator/SKILL.md
@@ -25,7 +25,7 @@ Use this as the first stop for Langfuse org navigation. Your job is to choose th
## Quick Skill Routing
- Product implementation in `langfuse/langfuse`: choose the matching repo-local skill under `.agents/skills`, such as `backend-dev-guidelines`, `frontend-browser-review`, `clickhouse-best-practices`, `add-model-price`, `turborepo`, `pnpm-upgrade-package`, `code-review`, or production-debug skills as applicable.
-- Cursor Cloud or Cursor desktop agents implementing a Linear issue, opening a PR, asking a human to test, or handling Claude, Greptile, or Codex review comments: use `cursor-agents-workflow`.
+- Cursor Cloud or Cursor desktop agents implementing a Linear issue, opening a PR, applying the `cursor` GitHub label, asking a human to test, or handling Claude, Greptile, or Codex review comments: use `cursor-agents-workflow`.
- A change too large for one reviewable PR, splitting a long-lived branch into PRs, or propagating and retargeting a stack: use `pr-stack-workflow`.
- Someone new, or you do not know whether you are talking to an outside contributor or a maintainer: use `langfuse-onboarding`.
- "What should I do today", or preparing a weekly project update: use `linear-work-rhythm`.
diff --git a/.agents/skills/langfuse-codebase-navigator/references/repository-map.md b/.agents/skills/langfuse-codebase-navigator/references/repository-map.md
index 185a2737d4..486c49188e 100644
--- a/.agents/skills/langfuse-codebase-navigator/references/repository-map.md
+++ b/.agents/skills/langfuse-codebase-navigator/references/repository-map.md
@@ -93,7 +93,7 @@ Repo-local skills in `langfuse/.agents/skills`:
- `changelog-writing`: user-facing release notes.
- `clickhouse-best-practices`: ClickHouse schema/query/migration review.
- `code-review`: repo-specific correctness/regression review.
-- `cursor-agents-workflow`: Cursor agent Linear branch names, human test steps, proof of work posted on the GitHub PR, Claude/Greptile/Codex review comments, and review-doubt PR notes.
+- `cursor-agents-workflow`: Cursor agent Linear branch names, the `cursor` GitHub label, human test steps, proof of work posted on the GitHub PR, Claude/Greptile/Codex review comments, and review-doubt PR notes.
- `datadog-query-recipes`: reusable Datadog query shapes for production research.
- `debug-issue-with-datadog`: production debugging tied to Langfuse code paths.
- `frontend-browser-review`: user-visible `web/**` changes and browser verification.
diff --git a/.github/workflows/label-cursor-prs.yml b/.github/workflows/label-cursor-prs.yml
new file mode 100644
index 0000000000..0adc59c9c1
--- /dev/null
+++ b/.github/workflows/label-cursor-prs.yml
@@ -0,0 +1,89 @@
+name: Label Cursor PRs
+
+# Apply the `cursor` label to PRs opened by Cursor. Skill guidance tells the
+# agent to add the label itself; this workflow is the backstop when it does
+# not — cursor[bot] authorship, a `cursor/` head ref, or the Cursor agent
+# PR-body marker.
+#
+# Uses the plain `pull_request` trigger (NOT pull_request_target): no cloud
+# credentials, no checkout, no PR-code execution — only GitHub API calls.
+on:
+ pull_request:
+ types: [opened, reopened, edited, synchronize]
+
+permissions: {}
+
+jobs:
+ label-cursor:
+ name: Apply cursor label
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ pull-requests: write
+ steps:
+ - name: Label Cursor PRs
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ script: |
+ const LABEL = "cursor";
+ const pr = context.payload.pull_request;
+ const { owner, repo } = context.repo;
+
+ if (pr.head.repo.full_name !== `${owner}/${repo}`) {
+ core.info("Fork PR; Cursor auto-label is limited to same-repo branches.");
+ return;
+ }
+
+ const alreadyLabeled = pr.labels.some((label) => label.name === LABEL);
+ if (alreadyLabeled) {
+ core.info(`PR #${pr.number} already has the '${LABEL}' label.`);
+ return;
+ }
+
+ const author = pr.user?.login ?? "";
+ const headRef = pr.head?.ref ?? "";
+ const body = pr.body ?? "";
+ const isCursorPr =
+ author === "cursor[bot]" ||
+ headRef.startsWith("cursor/") ||
+ body.includes("CURSOR_AGENT_PR_BODY_BEGIN");
+
+ if (!isCursorPr) {
+ core.info(
+ `PR #${pr.number} is not a Cursor PR (author=${author}, head=${headRef}).`,
+ );
+ return;
+ }
+
+ try {
+ await github.rest.issues.getLabel({ owner, repo, name: LABEL });
+ } catch (error) {
+ if (error.status !== 404) {
+ throw error;
+ }
+ try {
+ await github.rest.issues.createLabel({
+ owner,
+ repo,
+ name: LABEL,
+ color: "000000",
+ description: "Opened by a Cursor agent",
+ });
+ core.info("Created missing 'cursor' repository label.");
+ } catch (createError) {
+ // Concurrent runs can both see 404 and race createLabel.
+ // 422 means the other run won; continue to addLabels.
+ if (createError.status !== 422) {
+ throw createError;
+ }
+ core.info("Label already exists; continuing to apply it.");
+ }
+ }
+
+ await github.rest.issues.addLabels({
+ owner,
+ repo,
+ issue_number: pr.number,
+ labels: [LABEL],
+ });
+ core.info(`Applied '${LABEL}' label to PR #${pr.number}.`);
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 01ade07a5c..91d91e7c95 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -194,7 +194,8 @@ catalog described in `.agents/README.md`; credentials and OAuth grants belong
in Cursor, never in repository files.
After local verification, a Cursor agent should open a same-repo reviewable
-PR (not a draft) and test its `pr-<N>.preview.langfuse.com` deployment.
+PR (not a draft), apply the GitHub `cursor` label, and test its
+`pr-<N>.preview.langfuse.com` deployment.
Use Linear's git branch name (`lfe-XXXX-short-title`), not a `cursor/` prefix.
When handing work to a human, give a one-sentence TL;DR, a preview URL with
exact test steps (including how to seed or hit the same path on
diff --git a/scripts/github/is-cursor-pr.mjs b/scripts/github/is-cursor-pr.mjs
new file mode 100644
index 0000000000..4c7278ca0f
--- /dev/null
+++ b/scripts/github/is-cursor-pr.mjs
@@ -0,0 +1,11 @@
+/**
+ * Whether a GitHub pull request should receive the `cursor` label.
+ * Keep the same three signals in `.github/workflows/label-cursor-prs.yml`.
+ */
+export function isCursorPr({ author = "", headRef = "", body = "" } = {}) {
+ return (
+ author === "cursor[bot]" ||
+ headRef.startsWith("cursor/") ||
+ body.includes("CURSOR_AGENT_PR_BODY_BEGIN")
+ );
+}
diff --git a/scripts/github/label-cursor-prs.test.mjs b/scripts/github/label-cursor-prs.test.mjs
new file mode 100644
index 0000000000..44a02de435
--- /dev/null
+++ b/scripts/github/label-cursor-prs.test.mjs
@@ -0,0 +1,69 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { test } from "node:test";
+import { fileURLToPath } from "node:url";
+
+import { isCursorPr } from "./is-cursor-pr.mjs";
+
+const workflow = readFileSync(
+ join(
+ dirname(fileURLToPath(import.meta.url)),
+ "../../.github/workflows/label-cursor-prs.yml",
+ ),
+ "utf8",
+);
+
+test("cursor[bot] authorship is enough", () => {
+ assert.equal(isCursorPr({ author: "cursor[bot]" }), true);
+});
+
+test("cursor/ head ref is enough", () => {
+ assert.equal(
+ isCursorPr({ author: "nkabardin", headRef: "cursor/label-prs-231f" }),
+ true,
+ );
+});
+
+test("Cursor agent PR-body marker is enough", () => {
+ assert.equal(
+ isCursorPr({
+ author: "nkabardin",
+ headRef: "lfe-15605-cursor-pr-tag",
+ body: "<!-- CURSOR_AGENT_PR_BODY_BEGIN -->\nhello\n",
+ }),
+ true,
+ );
+});
+
+test("ordinary maintainer PRs are not labeled", () => {
+ assert.equal(
+ isCursorPr({
+ author: "maxdeichmann",
+ headRef: "lfe-12345-fix-filters",
+ body: "## What does this PR do?\n",
+ }),
+ false,
+ );
+});
+
+test("workflow stays on pull_request and does not check out PR code", () => {
+ assert.match(workflow, /^on:\n pull_request:/m);
+ assert.doesNotMatch(workflow, /^on:\n pull_request_target:/m);
+ assert.match(
+ workflow,
+ /uses: actions\/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3/,
+ );
+ assert.doesNotMatch(workflow, /actions\/checkout@/);
+});
+
+test("workflow uses the same three Cursor signals as isCursorPr", () => {
+ assert.match(workflow, /author === "cursor\[bot]"/);
+ assert.match(workflow, /headRef\.startsWith\("cursor\/"\)/);
+ assert.match(workflow, /body\.includes\("CURSOR_AGENT_PR_BODY_BEGIN"\)/);
+});
+
+test("workflow treats a concurrent createLabel 422 as success", () => {
+ assert.match(workflow, /createError\.status !== 422/);
+ assert.match(workflow, /Label already exists; continuing to apply it/);
+});