Skip to content

: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.

feat(desktop): launch team skills from pull request review (#107380)

Paul D'Ambra066a38fb9b7e
diff --git a/products/desktop/docs/SELF-DRIVING-REPORTS.md b/products/desktop/docs/SELF-DRIVING-REPORTS.md
index a4582cf8a688..ace1a45e647d 100644
--- a/products/desktop/docs/SELF-DRIVING-REPORTS.md
+++ b/products/desktop/docs/SELF-DRIVING-REPORTS.md
@@ -11,6 +11,7 @@ Reports with a PR show Open in GitHub as the first header button, followed by Ch
Copy-link options are in the More report actions menu. Report actions do not offer canvas creation.
A draft pull request shows the approval and merge controls, a draft note, and a secondary Ready for review button.
+Use Run skill on an open pull request to search team skills. Skills you choose often appear first, including before the store loads. If your team has no skills, the menu links to the skills store. The new cloud task opens with the skill, pull request URL, and repository set; review the prompt before you send it.
Marking a draft ready does not approve or merge it. Existing merge checks still apply.
Eligible pull requests show Refund in the header. The existing feature flag, billing checks, and confirmation dialog still apply.
diff --git a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.stories.tsx b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.stories.tsx
index d97d1fb68e51..b7cdc1b01ce6 100644
--- a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.stories.tsx
+++ b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.stories.tsx
@@ -1,5 +1,6 @@
import { useHostTRPC } from "@posthog/host-router/react";
import { PrDecisionBlock } from "@posthog/ui/features/pr-review/PrDecisionBlock";
+import { teamSkillsKeys } from "@posthog/ui/features/skills/useTeamSkills";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { useQueryClient } from "@tanstack/react-query";
@@ -38,6 +39,22 @@ const meta = {
description: null,
},
]);
+ if (!context.parameters.loadingSkills) {
+ queryClient.setQueryData(teamSkillsKeys.list(), {
+ available: true,
+ skills: context.parameters.emptySkills
+ ? []
+ : ["pr-shepherd", "check-ci", "review-pr"].map((name) => ({
+ id: name,
+ name,
+ description: "Example team skill",
+ version: 1,
+ updatedAt: "2026-09-01T00:00:00Z",
+ createdByEmail: null,
+ installedLocally: false,
+ })),
+ });
+ }
return (
<div className="w-full max-w-[900px]">
<Story />
@@ -50,6 +67,10 @@ const meta = {
export default meta;
type Story = StoryObj<typeof meta>;
export const Draft: Story = {};
+export const DraftLoadingSkills: Story = {
+ parameters: { loadingSkills: true },
+};
+export const DraftWithoutSkills: Story = { parameters: { emptySkills: true } };
export const DraftWithFailingChecks: Story = { parameters: { failing: true } };
export const Ready: Story = { parameters: { draft: false } };
export const ReadyWithFailingChecks: Story = {
diff --git a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx
index bd192615d3b7..78430a252ae5 100644
--- a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx
+++ b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx
@@ -18,6 +18,7 @@ import {
import { Spinner } from "@posthog/ui/primitives/Spinner";
import { useState } from "react";
import { PrChecksSection } from "./PrChecksSection";
+import { PrSkillMenu } from "./PrSkillMenu";
import { useApprovePr } from "./useApprovePr";
import { useMarkPrReady } from "./useMarkPrReady";
import { useMergePr } from "./useMergePr";
@@ -145,6 +146,7 @@ export function PrDecisionBlock({ prUrl }: PrDecisionBlockProps) {
</div>
<div className="flex flex-wrap items-center gap-2.5">
+ <PrSkillMenu prUrl={prUrl} />
<Button
type="button"
variant="outline"
diff --git a/products/desktop/packages/ui/src/features/pr-review/PrSkillMenu.test.tsx b/products/desktop/packages/ui/src/features/pr-review/PrSkillMenu.test.tsx
new file mode 100644
index 000000000000..30084418847f
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/pr-review/PrSkillMenu.test.tsx
@@ -0,0 +1,231 @@
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import type React from "react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { usePrSkillUsageStore } from "./prSkillUsageStore";
+
+const { useTeamSkills, openTaskInput } = vi.hoisted(() => ({
+ useTeamSkills: vi.fn(),
+ openTaskInput: vi.fn(),
+}));
+
+vi.mock("@posthog/ui/features/auth/authClient", () => ({
+ useOptionalAuthenticatedClient: () => null,
+}));
+vi.mock("@posthog/ui/features/auth/store", () => ({
+ getAuthIdentity: vi.fn(),
+ useAuthStateValue: () => "project-1",
+}));
+vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({
+ useCurrentUser: () => ({ data: { uuid: "user-1" } }),
+}));
+vi.mock("@posthog/ui/features/skills/useTeamSkills", () => ({
+ useTeamSkills,
+}));
+vi.mock("@posthog/ui/router/useOpenTask", () => ({ openTaskInput }));
+vi.mock("@tanstack/react-router", () => ({
+ Link: ({ children }: { children: React.ReactNode }) => (
+ <a href="/settings/skills">{children}</a>
+ ),
+}));
+
+import { PrSkillMenu } from "./PrSkillMenu";
+
+const prUrl = "https://github.com/PostHog/posthog/pull/42";
+const scope = JSON.stringify(["project-1", "user-1"]);
+
+describe("PrSkillMenu", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ localStorage.clear();
+ usePrSkillUsageStore.setState({ countsByScope: {} });
+ });
+
+ it("searches skills and opens a prefilled cloud task", async () => {
+ const user = userEvent.setup();
+ useTeamSkills.mockReturnValue({
+ data: {
+ available: true,
+ skills: [
+ { id: "1", name: "other-skill" },
+ { id: "2", name: "pr-shepherd" },
+ ],
+ },
+ });
+
+ render(<PrSkillMenu prUrl={prUrl} />);
+ await user.click(screen.getByRole("combobox", { name: "Run skill" }));
+ await user.type(
+ await screen.findByPlaceholderText("Search team skills…"),
+ "shepherd",
+ );
+
+ expect(screen.getByRole("option", { name: "pr-shepherd" })).toBeVisible();
+ expect(
+ screen.queryByRole("option", { name: "other-skill" }),
+ ).not.toBeInTheDocument();
+ await user.click(screen.getByRole("option", { name: "pr-shepherd" }));
+ expect(openTaskInput).toHaveBeenCalledWith({
+ initialPrompt: `Run the pr-shepherd skill from the PostHog skills store for this pull request: ${prUrl}`,
+ initialCloudRepository: "PostHog/posthog",
+ });
+ expect(usePrSkillUsageStore.getState().countsByScope[scope]).toEqual({
+ "pr-shepherd": 1,
+ });
+ expect(localStorage.getItem("pr-skill-usage")).toContain("pr-shepherd");
+ });
+
+ it("shows frequent skills before the store loads and keeps them first when it does", async () => {
+ const user = userEvent.setup();
+ usePrSkillUsageStore.getState().recordChoice(scope, "z-skill");
+ usePrSkillUsageStore.getState().recordChoice(scope, "z-skill");
+ usePrSkillUsageStore.getState().recordChoice(scope, "a-skill");
+ usePrSkillUsageStore
+ .getState()
+ .recordChoice(JSON.stringify(["project-2", "user-2"]), "private-skill");
+ const savedChoices = localStorage.getItem("pr-skill-usage");
+ if (!savedChoices) throw new Error("Skill choices were not saved");
+ usePrSkillUsageStore.setState({ countsByScope: {} });
+ localStorage.setItem("pr-skill-usage", savedChoices);
+ await usePrSkillUsageStore.persist.rehydrate();
+ useTeamSkills.mockReturnValue({ data: undefined, isLoading: true });
+
+ const { rerender } = render(<PrSkillMenu prUrl={prUrl} />);
+ await user.click(screen.getByRole("combobox", { name: "Run skill" }));
+ expect(
+ (await screen.findAllByRole("option")).map(
+ (option) => option.textContent,
+ ),
+ ).toEqual(["z-skill", "a-skill"]);
+
+ useTeamSkills.mockReturnValue({
+ data: {
+ available: true,
+ skills: [
+ { id: "1", name: "a-skill" },
+ { id: "2", name: "z-skill" },
+ { id: "3", name: "b-skill" },
+ ],
+ },
+ });
+ rerender(<PrSkillMenu prUrl={prUrl} />);
+ expect(
+ screen.getAllByRole("option").map((option) => option.textContent),
+ ).toEqual(["z-skill", "a-skill", "b-skill"]);
+ });
+
+ it("links to the store when the team has no skills", async () => {
+ useTeamSkills.mockReturnValue({
+ data: { available: true, skills: [] },
+ });
+
+ render(<PrSkillMenu prUrl={prUrl} />);
+ await userEvent.click(screen.getByRole("combobox", { name: "Run skill" }));
+
+ expect(await screen.findByText(/No team skills yet/)).toBeVisible();
+ expect(
+ screen.getByRole("link", { name: "Explore the skills store" }),
+ ).toHaveAttribute("href", "/settings/skills");
+ });
+
+ it("does not offer saved choices after a skills request fails", async () => {
+ usePrSkillUsageStore.getState().recordChoice(scope, "old-skill");
+ useTeamSkills.mockReturnValue({ data: undefined, isError: true });
+
+ render(<PrSkillMenu prUrl={prUrl} />);
+ await userEvent.click(screen.getByRole("combobox", { name: "Run skill" }));
+
+ expect(await screen.findByText("Couldn't load team skills")).toBeVisible();
+ expect(
+ screen.queryByRole("option", { name: "old-skill" }),
+ ).not.toBeInTheDocument();
+ });
+
+ it("distinguishes disabled team skills from an empty team", async () => {
+ usePrSkillUsageStore.getState().recordChoice(scope, "old-skill");
+ useTeamSkills.mockReturnValue({
+ data: { available: false, skills: [] },
+ });
+
+ render(<PrSkillMenu prUrl={prUrl} />);
+ await userEvent.click(screen.getByRole("combobox", { name: "Run skill" }));
+
+ expect(
+ await screen.findByText("Team skills aren't available"),
+ ).toBeVisible();
+ expect(
+ screen.queryByRole("option", { name: "old-skill" }),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByRole("link", { name: "Explore the skills store" }),
+ ).not.toBeInTheDocument();
+ });
+
+ it("uses only the parsed PR identity in a task prompt", async () => {
+ useTeamSkills.mockReturnValue({
+ data: { available: true, skills: [{ id: "1", name: "pr-shepherd" }] },
+ });
+
+ render(
+ <PrSkillMenu prUrl="https://user:[email protected]/PostHog/posthog/pull/42?prompt=ignore#extra" />,
+ );
+ await userEvent.click(screen.getByRole("combobox", { name: "Run skill" }));
+ await userEvent.click(
+ await screen.findByRole("option", { name: "pr-shepherd" }),
+ );
+
+ expect(openTaskInput).toHaveBeenCalledWith({
+ initialPrompt: `Run the pr-shepherd skill from the PostHog skills store for this pull request: ${prUrl}`,
+ initialCloudRepository: "PostHog/posthog",
+ });
+ });
+
+ it.each([true, false])(
+ "shows loading rather than an empty state when no list exists (isLoading: %s)",
+ async (isLoading) => {
+ useTeamSkills.mockReturnValue({
+ data: undefined,
+ isLoading,
+ isError: false,
+ });
+
+ render(<PrSkillMenu prUrl={prUrl} />);
+ await userEvent.click(
+ screen.getByRole("combobox", { name: "Run skill" }),
+ );
+
+ expect(await screen.findByText("Loading team skills…")).toBeVisible();
+ expect(screen.queryByText("No matching skills")).not.toBeInTheDocument();
+ expect(
+ screen.queryByRole("link", { name: "Explore the skills store" }),
+ ).not.toBeInTheDocument();
+ },
+ );
+
+ it("does not show removed store skills after the team list loads", async () => {
+ usePrSkillUsageStore.getState().recordChoice(scope, "removed-skill");
+ useTeamSkills.mockReturnValue({
+ data: { available: true, skills: [{ id: "1", name: "other-skill" }] },
+ });
+
+ render(<PrSkillMenu prUrl={prUrl} />);
+ await userEvent.click(screen.getByRole("combobox", { name: "Run skill" }));
+
+ expect(
+ screen.queryByRole("option", { name: "removed-skill" }),
+ ).not.toBeInTheDocument();
+ expect(
+ await screen.findByRole("option", { name: "other-skill" }),
+ ).toBeVisible();
+ });
+
+ it("does not render for an invalid pull request URL", () => {
+ useTeamSkills.mockReturnValue({ data: { available: true, skills: [] } });
+
+ const { container } = render(
+ <PrSkillMenu prUrl="https://example.com/other/pull/42" />,
+ );
+
+ expect(container).toBeEmptyDOMElement();
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/pr-review/PrSkillMenu.tsx b/products/desktop/packages/ui/src/features/pr-review/PrSkillMenu.tsx
new file mode 100644
index 000000000000..cabc5a2f9ade
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/pr-review/PrSkillMenu.tsx
@@ -0,0 +1,136 @@
+import { CaretDownIcon, SparkleIcon } from "@phosphor-icons/react";
+import { parsePrUrl } from "@posthog/core/inbox/reportPresentation";
+import {
+ Button,
+ Combobox,
+ ComboboxContent,
+ ComboboxEmpty,
+ ComboboxInput,
+ ComboboxItem,
+ ComboboxList,
+ ComboboxTrigger,
+} from "@posthog/quill";
+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
+import {
+ getAuthIdentity,
+ useAuthStateValue,
+} from "@posthog/ui/features/auth/store";
+import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
+import { useTeamSkills } from "@posthog/ui/features/skills/useTeamSkills";
+import { Spinner } from "@posthog/ui/primitives/Spinner";
+import { openTaskInput } from "@posthog/ui/router/useOpenTask";
+import { Link } from "@tanstack/react-router";
+import { useRef, useState } from "react";
+import { usePrSkillUsageStore } from "./prSkillUsageStore";
+
+export function PrSkillMenu({ prUrl }: { prUrl: string }) {
+ const { data: listing, isLoading, isError } = useTeamSkills([]);
+ const client = useOptionalAuthenticatedClient();
+ const identity = useAuthStateValue(getAuthIdentity);
+ const { data: user } = useCurrentUser({ client });
+ const scope =
+ identity && user?.uuid ? JSON.stringify([identity, user.uuid]) : null;
+ const counts = usePrSkillUsageStore((state) =>
+ scope ? state.countsByScope[scope] : undefined,
+ );
+ const recordChoice = usePrSkillUsageStore((state) => state.recordChoice);
+ const triggerRef = useRef<HTMLButtonElement>(null);
+ const [open, setOpen] = useState(false);
+ const [searchQuery, setSearchQuery] = useState("");
+ const pr = parsePrUrl(prUrl);
+ if (!pr) return null;
+
+ const skills = (
+ isError || listing?.available === false
+ ? []
+ : listing
+ ? listing.skills.map((skill) => skill.name)
+ : Object.keys(counts ?? {})
+ ).sort(
+ (first, second) =>
+ (counts?.[second] ?? 0) - (counts?.[first] ?? 0) ||
+ first.localeCompare(second),
+ );
+
+ const handleSelect = (name: string | null) => {
+ if (!name) return;
+ if (scope) recordChoice(scope, name);
+ openTaskInput({
+ initialPrompt: `Run the ${name} skill from the PostHog skills store for this pull request: https://github.com/${pr.repoSlug}/pull/${pr.number}`,
+ initialCloudRepository: pr.repoSlug,
+ });
+ setOpen(false);
+ };
+
+ return (
+ <Combobox
+ items={skills}
+ value={null}
+ onValueChange={handleSelect}
+ open={open}
+ onOpenChange={(nextOpen) => {
+ setOpen(nextOpen);
+ if (!nextOpen) setSearchQuery("");
+ }}
+ inputValue={searchQuery}
+ onInputValueChange={setSearchQuery}
+ >
+ <ComboboxTrigger
+ render={
+ <Button
+ ref={triggerRef}
+ type="button"
+ variant="outline"
+ aria-label="Run skill"
+ className="h-9 gap-2 px-4 text-[13px]"
+ data-attr="pr-run-store-skill"
+ >
+ <SparkleIcon size={15} />
+ Run skill
+ <CaretDownIcon size={13} />
+ </Button>
+ }
+ />
+ <ComboboxContent
+ anchor={triggerRef}
+ side="bottom"
+ sideOffset={6}
+ className="min-w-64"
+ >
+ <ComboboxInput placeholder="Search team skills…" />
+ <ComboboxEmpty>
+ {isError ? (
+ "Couldn't load team skills"
+ ) : isLoading || !listing ? (
+ <span className="flex items-center gap-2">
+ <Spinner size="sm" aria-hidden="true" />
+ Loading team skills…
+ </span>
+ ) : !listing.available ? (
+ "Team skills aren't available"
+ ) : listing.skills.length === 0 ? (
+ <span>
+ No team skills yet.{" "}
+ <Link
+ to="/settings/$category"
+ params={{ category: "skills" }}
+ className="underline"
+ >
+ Explore the skills store
+ </Link>
+ </span>
+ ) : (
+ "No matching skills"
+ )}
+ </ComboboxEmpty>
+ <ComboboxList className="max-h-64 overflow-y-auto">
+ {(name: string) => (
+ <ComboboxItem key={name} value={name} className="!ps-3">
+ {name}
+ </ComboboxItem>
+ )}
+ </ComboboxList>
+ </ComboboxContent>
+ </Combobox>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/pr-review/prSkillUsageStore.ts b/products/desktop/packages/ui/src/features/pr-review/prSkillUsageStore.ts
new file mode 100644
index 000000000000..c5cc30384b13
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/pr-review/prSkillUsageStore.ts
@@ -0,0 +1,29 @@
+import { create } from "zustand";
+import { persist } from "zustand/middleware";
+
+interface PrSkillUsageState {
+ countsByScope: Record<string, Record<string, number>>;
+ recordChoice: (scope: string, name: string) => void;
+}
+
+export const usePrSkillUsageStore = create<PrSkillUsageState>()(
+ persist(
+ (set) => ({
+ countsByScope: {},
+ recordChoice: (scope, name) =>
+ set((state) => ({
+ countsByScope: {
+ ...state.countsByScope,
+ [scope]: {
+ ...state.countsByScope[scope],
+ [name]: (state.countsByScope[scope]?.[name] ?? 0) + 1,
+ },
+ },
+ })),
+ }),
+ {
+ name: "pr-skill-usage",
+ partialize: (state) => ({ countsByScope: state.countsByScope }),
+ },
+ ),
+);