:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(desktop): use posthog/ prefix for new agent branches (#80956)
Charles Vience3a6a7e08c2
diff --git a/products/desktop/apps/code/README.md b/products/desktop/apps/code/README.mdindex bf74750c9516..b814ee533694 100644--- a/products/desktop/apps/code/README.md+++ b/products/desktop/apps/code/README.md@@ -192,7 +192,7 @@ PostHog automatically sets environment variables in all workspace terminals and| `POSTHOG_CODE_WORKSPACE_PATH` | Absolute path to the workspace | `/Users/dev/.posthog-code/worktrees/repo/my-feature` || `POSTHOG_CODE_ROOT_PATH` | Absolute path to the repository root | `/Users/dev/repos/my-project` || `POSTHOG_CODE_DEFAULT_BRANCH` | Default branch detected from git | `main` |-| `POSTHOG_CODE_WORKSPACE_BRANCH` | Initial branch when workspace was created | `posthog-code/my-feature` |+| `POSTHOG_CODE_WORKSPACE_BRANCH` | Initial branch when workspace was created | `posthog/my-feature` || `POSTHOG_CODE_WORKSPACE_PORTS` | Comma-separated list of allocated ports | `50000,50001,...,50019` || `POSTHOG_CODE_WORKSPACE_PORTS_RANGE` | Number of ports allocated | `20` || `POSTHOG_CODE_WORKSPACE_PORTS_START` | First port in the range | `50000` |diff --git a/products/desktop/apps/code/src/shared/constants.ts b/products/desktop/apps/code/src/shared/constants.tsindex e675a9e70575..413f8d381a59 100644--- a/products/desktop/apps/code/src/shared/constants.ts+++ b/products/desktop/apps/code/src/shared/constants.ts@@ -5,7 +5,7 @@ export const SELF_DRIVING_SETUP_TASK_FLAG ="posthog-code-self-driving-setup-task";export const SYNC_CLOUD_TASKS_FLAG = "posthog-code-sync-cloud-tasks";export const DISCOVERY_RUN_FLAG = "posthog-code-discovery-run";-export const BRANCH_PREFIX = "posthog-code/";+export const BRANCH_PREFIX = "posthog/";export const APP_WINDOW_ARG = "--posthog-app-window";export const ARTIFACT_PREVIEW_ARG = "--posthog-artifact-preview";export const ARTIFACT_OPEN_EXTERNAL_CHANNEL = "posthog-artifact-open-external";diff --git a/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts b/products/desktop/packages/agent/src/adapters/claude/session/instructions.tsindex 17afa579cfff..5d884e0f346e 100644--- a/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts+++ b/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts@@ -3,7 +3,7 @@ const BRANCH_NAMING = `When working in a detached HEAD state, create a descriptive branch name based on the work being done before committing. Do this automatically without asking the user.-When creating a new branch, prefix it with \`posthog-code/\` (e.g. \`posthog-code/fix-login-redirect\`).+When creating a new branch, prefix it with \`posthog/\` (e.g. \`posthog/fix-login-redirect\`).`;const PULL_REQUEST_LINKS = `diff --git a/products/desktop/packages/agent/src/adapters/signed-commit-shared.ts b/products/desktop/packages/agent/src/adapters/signed-commit-shared.tsindex 3c898937c22b..436668223f51 100644--- a/products/desktop/packages/agent/src/adapters/signed-commit-shared.ts+++ b/products/desktop/packages/agent/src/adapters/signed-commit-shared.ts@@ -32,7 +32,7 @@ export const SIGNED_COMMIT_TOOL_DESCRIPTION ="first (or pass `paths`), then call this instead of `git commit`/`git push` — those are " +"blocked because all commits must be signed. The commit is created via GitHub's API and " +"your local checkout is kept in sync. For a new branch, pass `branch` (prefixed with " +- "`posthog-code/`) and the tool creates it on the remote. Refuses while a merge/rebase/" ++ "`posthog/`) and the tool creates it on the remote. Refuses while a merge/rebase/" +"cherry-pick is in progress, refuses staged files that copy base-branch content into the PR " +"(to bring the base branch in, use `git_signed_merge`), and refuses when the remote branch " +"has advanced past your checkout (e.g. a CI bot pushed) — sync it first, then retry.";@@ -44,7 +44,7 @@ export const signedCommitToolSchema = {.string().optional().describe(- "Target branch; defaults to the current branch. Use a posthog-code/ prefix for new branches.",+ "Target branch; defaults to the current branch. Use a posthog/ prefix for new branches.",),paths: z.array(z.string())diff --git a/products/desktop/packages/agent/src/server/agent-server.test.ts b/products/desktop/packages/agent/src/server/agent-server.test.tsindex 53ec42f28fd1..6429d1d591e5 100644--- a/products/desktop/packages/agent/src/server/agent-server.test.ts+++ b/products/desktop/packages/agent/src/server/agent-server.test.ts@@ -4180,7 +4180,7 @@ describe("AgentServer HTTP Mode", () => {process.env.POSTHOG_CODE_INTERACTION_ORIGIN = "slack";const s = createServer();const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt();- expect(prompt).toContain("posthog-code/");+ expect(prompt).toContain("posthog/");expect(prompt).toContain("Create a draft pull request");expect(prompt).toContain("gh pr create --draft");expect(prompt).toContain("Generated-By: PostHog Code");@@ -4210,7 +4210,7 @@ describe("AgentServer HTTP Mode", () => {process.env.POSTHOG_CODE_INTERACTION_ORIGIN = "signal_report";const s = createServer();const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt();- expect(prompt).toContain("posthog-code/");+ expect(prompt).toContain("posthog/");expect(prompt).toContain("Create a draft pull request");expect(prompt).toContain("gh pr create --draft");delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN;diff --git a/products/desktop/packages/agent/src/server/agent-server.ts b/products/desktop/packages/agent/src/server/agent-server.tsindex f6042cfe2e05..f3a8b4c817c8 100644--- a/products/desktop/packages/agent/src/server/agent-server.ts+++ b/products/desktop/packages/agent/src/server/agent-server.ts@@ -3654,7 +3654,7 @@ Commits MUST be signed. \`git commit\` and \`git push\` are blocked in this enviTo commit: stage your changes with \`git add\`, then call the \`git_signed_commit\` tool (fullname \`${SIGNED_COMMIT_QUALIFIED_TOOL_NAME}\`) with a \`message\` (and optional \`body\`/\`paths\`).It creates a GitHub-signed ("Verified") commit on the branch and keeps your local checkout in-sync. To start a new branch, pass \`branch\` (prefixed with \`posthog-code/\`) — the tool creates+sync. To start a new branch, pass \`branch\` (prefixed with \`posthog/\`) — the tool createsit on the remote for you.## Updating from the base branch@@ -3839,7 +3839,7 @@ Do the requested work, but stop with local changes ready for review.Important:- Do NOT create a branch, commit, push, or open a pull request unless the user explicitly asks.-- If the user explicitly asks you to open a pull request: pick a new branch name prefixed with \`posthog-code/\`, stage your changes with \`git add\`, and call the \`git_signed_commit\` tool with \`branch\` set to that name and a clear \`message\` (do NOT use \`git commit\`/\`git push\` — they are blocked). Before opening the PR, check the repo for a PR template at \`.github/pull_request_template.md\` (or variants; fall back to the org's \`.github\` repo via \`gh api\`) and use it as the body structure, and search for matching open issues with \`gh issue list --search\` to include \`Closes #<n>\` / \`Refs #<n>\` links. Keep the description brief overall — summarize only the most important changes.+- If the user explicitly asks you to open a pull request: pick a new branch name prefixed with \`posthog/\`, stage your changes with \`git add\`, and call the \`git_signed_commit\` tool with \`branch\` set to that name and a clear \`message\` (do NOT use \`git commit\`/\`git push\` — they are blocked). Before opening the PR, check the repo for a PR template at \`.github/pull_request_template.md\` (or variants; fall back to the org's \`.github\` repo via \`gh api\`) and use it as the body structure, and search for matching open issues with \`gh issue list --search\` to include \`Closes #<n>\` / \`Refs #<n>\` links. Keep the description brief overall — summarize only the most important changes.${whyContextInstruction.trimStart()}${publicRepoSafetyInstruction.trimStart()}${prMentionSafetyInstruction.trimStart()}@@ -3857,7 +3857,7 @@ ${repositoryWorkspaceInstructions}If the work you are being asked to do already has an open pull request — for example, the inbox report you fetched links an implementation PR (its \`implementation_pr_url\`), or this same thread already produced a PR that you are now being asked to revise — do NOT open a second PR. Check that PR out with \`gh pr checkout <url>\`, continue on its branch, and commit your changes to it with the \`git_signed_commit\` tool (if the branch is behind its base, call \`git_signed_merge\` first). A PR is only the one to continue if it is for this same request; if the thread merely mentions an unrelated or older PR, ignore it. Only open a new, separate PR when the change is genuinely distinct from the existing one.Otherwise, after completing the requested changes:-1. Pick a new branch name prefixed with \`posthog-code/\` (e.g. \`posthog-code/fix-login-redirect\`)+1. Pick a new branch name prefixed with \`posthog/\` (e.g. \`posthog/fix-login-redirect\`)2. Stage your changes with \`git add\`, then call the \`git_signed_commit\` tool with \`branch\` set to that name and a clear \`message\` (do NOT use \`git commit\`/\`git push\` — they are blocked). The tool creates the branch on the remote and a signed commit on it.3. Before opening the PR, prepare the body:- Keep the PR description brief overall. Summarize only the most important changes — do NOT enumerate every change you made. A few sentences or bullets is plenty.diff --git a/products/desktop/packages/core/src/git-interaction/branchName.test.ts b/products/desktop/packages/core/src/git-interaction/branchName.test.tsindex b6247967d98d..863551a348e9 100644--- a/products/desktop/packages/core/src/git-interaction/branchName.test.ts+++ b/products/desktop/packages/core/src/git-interaction/branchName.test.ts@@ -92,24 +92,22 @@ describe("validateBranchName", () => {describe("suggestBranchName", () => {it("returns the base name when no collision exists", () => {- expect(suggestBranchName("Fix bug", "abc", [])).toBe(- "posthog-code/fix-bug",- );+ expect(suggestBranchName("Fix bug", "abc", [])).toBe("posthog/fix-bug");});it("appends -2 on first collision", () => {- expect(suggestBranchName("Fix bug", "abc", ["posthog-code/fix-bug"])).toBe(- "posthog-code/fix-bug-2",+ expect(suggestBranchName("Fix bug", "abc", ["posthog/fix-bug"])).toBe(+ "posthog/fix-bug-2",);});it("increments past consecutive collisions", () => {expect(suggestBranchName("Fix bug", "abc", [- "posthog-code/fix-bug",- "posthog-code/fix-bug-2",- "posthog-code/fix-bug-3",+ "posthog/fix-bug",+ "posthog/fix-bug-2",+ "posthog/fix-bug-3",]),- ).toBe("posthog-code/fix-bug-4");+ ).toBe("posthog/fix-bug-4");});});diff --git a/products/desktop/packages/core/src/git-interaction/deriveBranchName.test.ts b/products/desktop/packages/core/src/git-interaction/deriveBranchName.test.tsindex 1d4cc0b86004..450dc537330b 100644--- a/products/desktop/packages/core/src/git-interaction/deriveBranchName.test.ts+++ b/products/desktop/packages/core/src/git-interaction/deriveBranchName.test.ts@@ -4,48 +4,44 @@ import { deriveBranchName } from "./branchName";describe("deriveBranchName", () => {it("converts a simple title to a branch name", () => {expect(deriveBranchName("Fix authentication login bug", "abc123")).toBe(- "posthog-code/fix-authentication-login-bug",+ "posthog/fix-authentication-login-bug",);});it("handles special characters", () => {expect(deriveBranchName("PostHog issue #1234", "abc123")).toBe(- "posthog-code/posthog-issue-1234",+ "posthog/posthog-issue-1234",);});it("collapses consecutive dashes", () => {expect(deriveBranchName("Fix the bug", "abc123")).toBe(- "posthog-code/fix-the-bug",+ "posthog/fix-the-bug",);});it("strips leading and trailing dashes", () => {- expect(deriveBranchName(" Fix bug ", "abc123")).toBe(- "posthog-code/fix-bug",- );+ expect(deriveBranchName(" Fix bug ", "abc123")).toBe("posthog/fix-bug");});it("truncates long titles", () => {const longTitle ="This is a very long task title that should be truncated to a reasonable length for git";const result = deriveBranchName(longTitle, "abc123");- expect(result.length).toBeLessThanOrEqual(73); // 60 slug + "posthog-code/" prefix- expect(result.startsWith("posthog-code/")).toBe(true);+ expect(result.length).toBeLessThanOrEqual(68); // 60 slug + "posthog/" prefix+ expect(result.startsWith("posthog/")).toBe(true);expect(result.endsWith("-")).toBe(false);});it("falls back to task ID when title is empty", () => {- expect(deriveBranchName("", "abc123")).toBe("posthog-code/task-abc123");+ expect(deriveBranchName("", "abc123")).toBe("posthog/task-abc123");});it("falls back to task ID when title is only whitespace", () => {- expect(deriveBranchName(" ", "abc123")).toBe("posthog-code/task-abc123");+ expect(deriveBranchName(" ", "abc123")).toBe("posthog/task-abc123");});it("falls back to task ID when title is only special characters", () => {- expect(deriveBranchName("!@#$%", "abc123")).toBe(- "posthog-code/task-abc123",- );+ expect(deriveBranchName("!@#$%", "abc123")).toBe("posthog/task-abc123");});});diff --git a/products/desktop/packages/git/src/signed-commit.ts b/products/desktop/packages/git/src/signed-commit.tsindex ff6950a0ed47..43b4f485ad7a 100644--- a/products/desktop/packages/git/src/signed-commit.ts+++ b/products/desktop/packages/git/src/signed-commit.ts@@ -229,7 +229,7 @@ async function resolveBranchName(if (baseBranch && branch === baseBranch) {throw new Error(`Refusing to commit directly to base branch '${baseBranch}'. ` +- `Pass a 'branch' name prefixed with posthog-code/.`,+ `Pass a 'branch' name prefixed with posthog/.`,);}return branch;@@ -239,7 +239,7 @@ async function resolveCurrentBranch(ctx: SignedCommitCtx): Promise<string> {const current = await gitText(["rev-parse", "--abbrev-ref", "HEAD"], ctx.cwd);if (!current || current === "HEAD") {throw new Error(- "Detached HEAD — pass a `branch` to git_signed_commit (e.g. posthog-code/...).",+ "Detached HEAD — pass a `branch` to git_signed_commit (e.g. posthog/...).",);}return current;@@ -802,7 +802,7 @@ async function publishChangesAtomic(return publishChunks(ctx, repo, branch, baseOid, headline, body, chunks);}- const scratch = `posthog-code/commit-tmp/${crypto.randomUUID()}`;+ const scratch = `posthog/commit-tmp/${crypto.randomUUID()}`;await createRef(ctx, repo, scratch, baseOid);try {const published = await publishChunks(@@ -996,7 +996,7 @@ export async function createSignedRewrite(throw new Error(`No commits between ${onto} and HEAD to publish.`);}- const scratch = `posthog-code/rewrite-tmp/${crypto.randomUUID()}`;+ const scratch = `posthog/rewrite-tmp/${crypto.randomUUID()}`;await createRef(ctx, repo, scratch, onto);const commits: { sha: string; url: string }[] = [];diff --git a/products/desktop/packages/shared/src/constants.ts b/products/desktop/packages/shared/src/constants.tsindex 391801716403..0e3f6e615c92 100644--- a/products/desktop/packages/shared/src/constants.ts+++ b/products/desktop/packages/shared/src/constants.ts@@ -7,7 +7,7 @@ export {export const SELF_DRIVING_SETUP_TASK_FLAG ="posthog-code-self-driving-setup-task";-export const BRANCH_PREFIX = "posthog-code/";+export const BRANCH_PREFIX = "posthog/";export const POSTHOG_CODE_INTERNAL_CHILD_ENV = "POSTHOG_CODE_INTERNAL_CHILD";// Mirrors --color-background (dark) in packages/ui globals.css, for surfacesdiff --git a/products/desktop/packages/shared/src/git-naming.ts b/products/desktop/packages/shared/src/git-naming.tsindex 480f9d398b5d..61453c4a5066 100644--- a/products/desktop/packages/shared/src/git-naming.ts+++ b/products/desktop/packages/shared/src/git-naming.ts@@ -1 +1 @@-export const BRANCH_PREFIX = "posthog-code/";+export const BRANCH_PREFIX = "posthog/";diff --git a/products/desktop/packages/workspace-server/src/services/agent/agent.ts b/products/desktop/packages/workspace-server/src/services/agent/agent.tsindex b84c667891be..79ee1336867a 100644--- a/products/desktop/packages/workspace-server/src/services/agent/agent.ts+++ b/products/desktop/packages/workspace-server/src/services/agent/agent.ts@@ -644,7 +644,7 @@ EOF)"\`\`\`-When creating new branches, prefix them with \`posthog-code/\` (e.g. \`posthog-code/fix-login-redirect\`).+When creating new branches, prefix them with \`posthog/\` (e.g. \`posthog/fix-login-redirect\`).When creating pull requests, add the following footer at the end of the PR description:\`\`\`diff --git a/products/tasks/backend/temporal/process_task/activities/start_agent_server.py b/products/tasks/backend/temporal/process_task/activities/start_agent_server.pyindex 21951cd70c00..142562e4b1c1 100644--- a/products/tasks/backend/temporal/process_task/activities/start_agent_server.py+++ b/products/tasks/backend/temporal/process_task/activities/start_agent_server.py@@ -73,7 +73,7 @@ def _resolve_protected_base_branch(ctx: TaskProcessingContext) -> str | None:The task's working branch is normally the PR base it was started from, so protecting it is correct.But when the working branch itself heads an open PR — e.g. a quick action started on an existing- posthog-code/* branch the agent is meant to update — the agent must commit *to* that branch, so the+ posthog/* branch the agent is meant to update — the agent must commit *to* that branch, so theprotected base is the PR's own base instead. Without this the signed-commit guard refuses the verybranch the run needs to update. Best-effort: any failure falls back to the working branch."""