: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(skills): let users rename a skill in the skills store (#95499)
posthog[bot]d40f274a1f7e
diff --git a/products/skills/backend/api/skill_serializers.py b/products/skills/backend/api/skill_serializers.pyindex 96290c866d55..b18beb6d52cd 100644--- a/products/skills/backend/api/skill_serializers.py+++ b/products/skills/backend/api/skill_serializers.py@@ -632,8 +632,10 @@ class LLMSkillSerializer(serializers.ModelSerializer):return attrsif name is not None and self.instance.name != name:+ # Renaming moves every version row and the owner rows together, which this path can't+ # do — the dedicated rename endpoint owns it.raise serializers.ValidationError(- {"name": "Skill name cannot be changed after creation."},+ {"name": "Use the rename endpoint to change a skill's name."},code="immutable",)@@ -755,6 +757,17 @@ class LLMSkillDuplicateSerializer(serializers.Serializer):return validate_skill_name_value(value)+class LLMSkillRenameSerializer(serializers.Serializer):+ new_name = serializers.CharField(+ max_length=MAX_SKILL_NAME_LENGTH,+ help_text="New name for the skill. Must be unique in the project, and must not start with "+ "'signals-scout-' or 'review-hog-'.",+ )++ def validate_new_name(self, value: str) -> str:+ return validate_skill_name_value(value)++class LLMSkillResolveResponseSerializer(serializers.Serializer):skill = LLMSkillSerializer()versions = LLMSkillVersionSummarySerializer(many=True)diff --git a/products/skills/backend/api/skill_services.py b/products/skills/backend/api/skill_services.pyindex a9a8ad1aa996..d75b247afaeb 100644--- a/products/skills/backend/api/skill_services.py+++ b/products/skills/backend/api/skill_services.py@@ -11,6 +11,7 @@ from posthog.models import Team, Userfrom ..marketplace.packaging import SPEC_DESCRIPTION_MAX_LENGTHfrom ..models.skills import (+ CATEGORY_BY_NAME_PREFIX,LLMSkill,LLMSkillFile,LLMSkillOwner,@@ -115,6 +116,19 @@ class LLMSkillDuplicateNameConflictError(Exception):pass+@frozen+class LLMSkillRenameNotAllowedError(Exception):+ """The rename would move a skill in or out of a name prefix another product keys its rows on.++ `signals-scout-` and `review-hog-` rows (schedules, pauses, per-user enablement, run history) are+ keyed on the skill name, and products can't reach into each other to move them. A rename that+ touches either prefix would leave those rows pointing at a name nothing holds, so it is refused+ rather than half-applied.+ """++ prefix: str++@frozenclass LLMSkillDescriptionTooLongError(Exception):max_length: int@@ -707,6 +721,55 @@ def archive_skill(team: Team, skill_name: str) -> list[int]:return skill_versions+def _product_owned_name_prefix(name: str) -> str:+ """The registered prefix `name` carries, or "" when it carries none."""+ return next((prefix for prefix, _ in CATEGORY_BY_NAME_PREFIX if name.startswith(prefix)), "")+++def rename_skill(team: Team, *, skill_name: str, new_name: str) -> LLMSkill:+ """Move a logical skill to `new_name`, keeping its versions, files, and owners.++ Every version row carries the name, and owners are keyed on `(team, skill_name)`, so the rename+ has to move all of them together or it loses history and ownership — which is exactly what the+ duplicate-then-archive workaround did.+ """+ blocked_prefix = _product_owned_name_prefix(skill_name) or _product_owned_name_prefix(new_name)+ if blocked_prefix:+ raise LLMSkillRenameNotAllowedError(prefix=blocked_prefix)++ with transaction.atomic():+ locked_version_ids = list(+ LLMSkill.objects.select_for_update()+ .filter(team=team, name=skill_name, deleted=False)+ .order_by("version", "created_at", "id")+ .values_list("id", flat=True)+ )+ if not locked_version_ids:+ raise LLMSkillNotFoundError()+ if new_name == skill_name:+ return _renamed_skill_or_missing(team, new_name)+ if LLMSkill.objects.filter(team=team, name=new_name, deleted=False).exists():+ raise LLMSkillDuplicateNameConflictError()++ # Bump updated_at (the .update() bypasses auto_now) so the marketplace plugin version,+ # derived from max(updated_at) across all team rows, advances — a renamed skill changes+ # the directory name in the exported tree, so installs must pick the rename up.+ LLMSkill.objects.filter(team=team, name=skill_name, deleted=False).update(+ name=new_name,+ updated_at=timezone.now(),+ )+ rename_skill_owners(team, skill_name, new_name)++ return _renamed_skill_or_missing(team, new_name)+++def _renamed_skill_or_missing(team: Team, name: str) -> LLMSkill:+ skill = get_skill_by_name_from_db(team, name)+ if skill is None:+ raise LLMSkillNotFoundError()+ return skill++# --- Skill owners ---------------------------------------------------------------------------------# Owners are keyed on the *logical* skill `(team, skill_name)`, so nothing here touches a version row:# editing a skill body never changes who owns it. Every read and write goes through `_owner_qs`, which@@ -803,6 +866,16 @@ def clear_skill_owners(team: Team, skill_name: str) -> None:_owner_qs(team).filter(skill_name=skill_name).delete()+def rename_skill_owners(team: Team, skill_name: str, new_name: str) -> None:+ """Move every owner row of a logical skill onto `new_name`, so a rename keeps its owners.++ Owner rows for `new_name` are dropped first: they can only be leftovers from a name nothing+ active holds, and the `(team, skill_name, user)` unique constraint would otherwise reject the move.+ """+ _owner_qs(team).filter(skill_name=new_name).delete()+ _owner_qs(team).filter(skill_name=skill_name).update(skill_name=new_name)++def seed_skill_owner(team: Team, skill_name: str, user: User) -> None:"""Idempotently record `user` as an owner — the default seed on skill creation.diff --git a/products/skills/backend/api/skills.py b/products/skills/backend/api/skills.pyindex 2a96e8aa5ee1..f2089dd8c16d 100644--- a/products/skills/backend/api/skills.py+++ b/products/skills/backend/api/skills.py@@ -84,6 +84,7 @@ from .skill_serializers import (LLMSkillMarketplaceIssueSerializer,LLMSkillPublishSerializer,LLMSkillPublishToCommunitySerializer,+ LLMSkillRenameSerializer,LLMSkillResolveQuerySerializer,LLMSkillResolveResponseSerializer,LLMSkillSerializer,@@ -102,6 +103,7 @@ from .skill_services import (LLMSkillFilePathConflictError,LLMSkillNotFoundError,LLMSkillOwnerNotFoundError,+ LLMSkillRenameNotAllowedError,LLMSkillVersionConflictError,LLMSkillVersionLimitError,archive_skill,@@ -113,6 +115,7 @@ from .skill_services import (get_latest_skills_queryset,get_skill_by_name_from_db,publish_skill_version,+ rename_skill,rename_skill_file,resolve_owner_users,resolve_skill_owners,@@ -1192,6 +1195,63 @@ class LLMSkillViewSet()return Response(self._serialize_skill(new_skill), status=status.HTTP_201_CREATED)+ @extend_schema(request=LLMSkillRenameSerializer, responses={200: LLMSkillSerializer})+ @action(+ methods=["POST"],+ detail=False,+ url_path=r"name/(?P<skill_name>[^/]+)/rename",+ required_scopes=["llm_skill:write"],+ )+ @llma_track_latency("llma_skills_rename")+ @monitor(feature=None, endpoint="llma_skills_rename", method="POST")+ def rename(self, request: Request, skill_name: str = "", **kwargs) -> Response:+ auth_error = self._ensure_web_authenticated(request)+ if auth_error is not None:+ return auth_error++ payload = LLMSkillRenameSerializer(data=request.data)+ payload.is_valid(raise_exception=True)+ new_name = payload.validated_data["new_name"]++ try:+ renamed_skill = rename_skill(self.team, skill_name=skill_name, new_name=new_name)+ except LLMSkillNotFoundError:+ return self._skill_not_found_response(skill_name)+ except LLMSkillDuplicateNameConflictError:+ raise serializers.ValidationError(+ {"new_name": "A skill with this name already exists."},+ code="unique",+ )+ except LLMSkillRenameNotAllowedError as err:+ raise serializers.ValidationError(+ {+ "new_name": (+ f"Names starting with '{err.prefix}' keep product settings under the skill name, "+ "so a skill can't be renamed into or out of them. Duplicate the skill instead."+ )+ },+ code="reserved_prefix",+ )++ props = {+ **_skill_analytics_props(renamed_skill),+ "previous_skill_name": skill_name,+ }+ logger.info(+ "llma_skill_renamed",+ team_id=self.team.id,+ user_id=cast(User, request.user).id,+ **props,+ )+ report_user_action(+ cast(User, request.user),+ "llma skill renamed",+ props,+ team=self.team,+ request=request,+ )+ return Response(self._serialize_skill(renamed_skill))+@extend_schema(request=LLMSkillPublishToCommunitySerializer, responses={201: CommunitySkillPublishResultSerializer})@action(methods=["POST"],diff --git a/products/skills/backend/api/test/test_skills.py b/products/skills/backend/api/test/test_skills.pyindex 92505f16e996..ae484a5b8edd 100644--- a/products/skills/backend/api/test/test_skills.py+++ b/products/skills/backend/api/test/test_skills.py@@ -1006,6 +1006,84 @@ class TestLLMSkillAPI(APIBaseTest):assert response.status_code == status.HTTP_400_BAD_REQUEST+ # --- Rename ---++ def test_rename_moves_every_version_with_its_files_and_owners(self):+ v1 = self.create_skill(name="typoo", version=1, is_latest=False)+ v2 = self.create_skill(name="typoo", version=2)+ LLMSkillFile.objects.create(skill=v2, path="scripts/run.sh", content="#!/bin/bash")+ member = User.objects.create_and_join(self.organization, "[email protected]", None)+ set_skill_owners(self.team, "typoo", [member])+ updated_at_before = v2.updated_at++ response = self.client.post(+ self._url("name/typoo/rename"),+ data={"new_name": "typo-free"},+ format="json",+ )++ assert response.status_code == status.HTTP_200_OK, response.json()+ data = response.json()+ assert data["name"] == "typo-free"+ # A rename is not an edit: the version history carries over intact rather than restarting.+ assert data["version"] == 2+ assert data["version_count"] == 2+ assert not LLMSkill.objects.filter(team=self.team, name="typoo", deleted=False).exists()+ assert sorted(+ LLMSkill.objects.filter(team=self.team, name="typo-free", deleted=False).values_list("version", flat=True)+ ) == [1, 2]+ assert [f["path"] for f in data["files"]] == ["scripts/run.sh"]+ assert [o.email for o in resolve_skill_owners(self.team, "typo-free")] == [member.email]+ assert resolve_skill_owners(self.team, "typoo") == []+ # The marketplace plugin version is max(updated_at) across the team, so the rename has to+ # advance it or installs keep the old directory name.+ v1.refresh_from_db()+ v2.refresh_from_db()+ assert v2.updated_at > updated_at_before+ assert v1.name == "typo-free"++ def test_rename_to_an_existing_name_is_rejected(self):+ self.create_skill(name="source")+ self.create_skill(name="taken")++ response = self.client.post(+ self._url("name/source/rename"),+ data={"new_name": "taken"},+ format="json",+ )++ assert response.status_code == status.HTTP_400_BAD_REQUEST+ assert LLMSkill.objects.filter(team=self.team, name="source", deleted=False).exists()++ @parameterized.expand(+ [+ ("out_of_scout", "signals-scout-churn", "churn-watch"),+ ("into_scout", "churn-watch", "signals-scout-churn"),+ ("into_review_hog", "churn-watch", "review-hog-perspective-churn"),+ ]+ )+ def test_rename_touching_a_product_owned_prefix_is_rejected(self, _name: str, old_name: str, new_name: str):+ self.create_skill(name=old_name)++ response = self.client.post(+ self._url(f"name/{old_name}/rename"),+ data={"new_name": new_name},+ format="json",+ )++ assert response.status_code == status.HTTP_400_BAD_REQUEST+ assert LLMSkill.objects.filter(team=self.team, name=old_name, deleted=False).exists()+ assert not LLMSkill.objects.filter(team=self.team, name=new_name).exists()++ def test_rename_of_a_missing_skill_is_not_found(self):+ response = self.client.post(+ self._url("name/nope/rename"),+ data={"new_name": "still-nope"},+ format="json",+ )++ assert response.status_code == status.HTTP_404_NOT_FOUND+# --- Get file ---def test_get_file_by_path(self):@@ -1539,6 +1617,7 @@ class TestSkillAccessControlRBAC(APIBaseTest):[("create",),("update_by_name",),+ ("rename",),])def test_member_without_skill_access_cannot_write(self, action):@@ -1546,6 +1625,12 @@ class TestSkillAccessControlRBAC(APIBaseTest):response = self.client.post(self._url(), data={"name": "new-skill", "description": "d", "body": "x"}, format="json")+ elif action == "rename":+ response = self.client.post(+ self._url(f"name/{self.skill.name}/rename"),+ data={"new_name": "renamed-fractals"},+ format="json",+ )else:response = self.client.patch(self._url(f"name/{self.skill.name}"),diff --git a/products/skills/frontend/LLMSkillScene.tsx b/products/skills/frontend/LLMSkillScene.tsxindex 2254a5e726f2..2941400f7c95 100644--- a/products/skills/frontend/LLMSkillScene.tsx+++ b/products/skills/frontend/LLMSkillScene.tsx@@ -48,14 +48,35 @@ import type { LLMSkillFileManifestApi, LLMSkillVersionSummaryApi } from 'productimport type { SkillFormFileValues } from './llmSkillLogic'import { SkillLogicProps, SkillMode, isSkill, llmSkillLogic } from './llmSkillLogic'import { llmSkillsLogic } from './llmSkillsLogic'-import { SKILL_NAME_MAX_LENGTH, SKILL_DESCRIPTION_MAX_LENGTH } from './skillConstants'+import {+ PRODUCT_OWNED_SKILL_NAME_PREFIXES,+ SKILL_NAME_MAX_LENGTH,+ SKILL_DESCRIPTION_MAX_LENGTH,+} from './skillConstants'import { skillFileLogic } from './skillFileLogic'import { collectFilesFromDrop } from './skillFileUpload'import { SkillOwners } from './SkillOwners'-import { SkillPublishReviewModal, openArchiveSkillDialog, openPublishToCommunityDialog } from './skillSceneComponents'+import {+ SkillPublishReviewModal,+ openArchiveSkillDialog,+ openPublishToCommunityDialog,+ openRenameSkillDialog,+} from './skillSceneComponents'const MonacoDiffEditor = lazyWithRetry(() => import('lib/components/MonacoDiffEditor'))+/** Why this skill cannot be renamed, or undefined when it can be.+ *+ * Scouts and ReviewHog skills keep their settings under the skill name, so the backend refuses to+ * rename them. Say so up front instead of letting the click come back a 400.+ */+function renameBlockedReason(skillName: string | null): string | undefined {+ if (skillName === null || !PRODUCT_OWNED_SKILL_NAME_PREFIXES.some((prefix) => skillName.startsWith(prefix))) {+ return undefined+ }+ return 'Skills that run on a schedule or a pull request keep settings under their name, so they cannot be renamed'+}+export const scene: SceneExport<SkillLogicProps> = {component: LLMSkillScene,logic: llmSkillLogic,@@ -90,6 +111,7 @@ export function LLMSkillScene(): JSX.Element {selectedVersion,isSkillAccessDenied,hasSkillLoadError,+ renamingSkill,} = useValues(llmSkillLogic)const { searchParams } = useValues(router)// Reuse the list scene's publish flow: its action, per-skill in-flight guard, and resolved@@ -103,6 +125,7 @@ export function LLMSkillScene(): JSX.Element {submitSkillForm,requestPublish,deleteSkill,+ renameSkill,setMode,setSkillFormValues,loadMoreVersions,@@ -179,6 +202,8 @@ export function LLMSkillScene(): JSX.Element {: undefined: undefined+ const renameDisabledReason = renameBlockedReason(isSkill(skill) ? skill.name : null)+const content =isViewMode || !canEditSkill ? (<SceneContent>@@ -259,6 +284,22 @@ export function LLMSkillScene(): JSX.Element {</AccessControlAction>)}+ {isSkill(skill) && (+ <AccessControlAction+ resourceType={AccessControlResourceType.LlmSkill}+ minAccessLevel={AccessControlLevel.Editor}+ >+ <LemonButton+ onClick={() => openRenameSkillDialog(skill.name, renameSkill)}+ disabledReason={renamingSkill ? 'Renaming…' : renameDisabledReason}+ data-attr="llma-skill-rename-button"+ fullWidth+ >+ Rename+ </LemonButton>+ </AccessControlAction>+ )}+<AccessControlActionresourceType={AccessControlResourceType.LlmSkill}minAccessLevel={AccessControlLevel.Editor}@@ -866,8 +907,8 @@ function SkillEditForm({label="Name"help={isNewSkill- ? `Lowercase letters, numbers, and hyphens only. Max ${SKILL_NAME_MAX_LENGTH} characters. Cannot be changed later.`- : 'This name is used to fetch the skill from your code.'+ ? `Lowercase letters, numbers, and hyphens only. Max ${SKILL_NAME_MAX_LENGTH} characters.`+ : 'This name is used to fetch the skill from your code. Change it with Rename in the More menu.'}><LemonInput@@ -875,7 +916,7 @@ function SkillEditForm({placeholder="my-skill-name"maxLength={SKILL_NAME_MAX_LENGTH}fullWidth- disabledReason={!isNewSkill ? 'Skill name cannot be changed after creation' : undefined}+ disabledReason={!isNewSkill ? 'Use Rename in the More menu to change the name' : undefined}/></LemonField>diff --git a/products/skills/frontend/generated/api.schemas.ts b/products/skills/frontend/generated/api.schemas.tsindex b2f7bf39011c..d082ea4eff39 100644--- a/products/skills/frontend/generated/api.schemas.ts+++ b/products/skills/frontend/generated/api.schemas.ts@@ -691,6 +691,14 @@ export interface CommunitySkillPublishResultApi {branch: string}+export interface LLMSkillRenameApi {+ /**+ * New name for the skill. Must be unique in the project, and must not start with 'signals-scout-' or 'review-hog-'.+ * @maxLength 64+ */+ new_name: string+}+export interface LLMSkillVersionSummaryApi {readonly id: stringreadonly version: numberdiff --git a/products/skills/frontend/generated/api.ts b/products/skills/frontend/generated/api.tsindex fe424d0dc1d3..6f98ada0b32c 100644--- a/products/skills/frontend/generated/api.ts+++ b/products/skills/frontend/generated/api.ts@@ -24,6 +24,7 @@ import type {LLMSkillMarketplaceCommandApi,LLMSkillMarketplaceIssueApi,LLMSkillPublishToCommunityApi,+ LLMSkillRenameApi,LLMSkillResolveResponseApi,LlmSkillsBundleRetrieveParams,LlmSkillsListParams,@@ -501,6 +502,24 @@ export const llmSkillsNamePublishCommunityCreate = async (})}+export const getLlmSkillsNameRenameCreateUrl = (projectId: string, skillName: string) => {+ return `/api/projects/${projectId}/llm_skills/name/${skillName}/rename/`+}++export const llmSkillsNameRenameCreate = async (+ projectId: string,+ skillName: string,+ lLMSkillRenameApi: LLMSkillRenameApi,+ options?: RequestInit+): Promise<LLMSkillApi> => {+ return apiMutator<LLMSkillApi>(getLlmSkillsNameRenameCreateUrl(projectId, skillName), {+ ...options,+ method: 'POST',+ headers: { 'Content-Type': 'application/json', ...options?.headers },+ body: JSON.stringify(lLMSkillRenameApi),+ })+}+export const getLlmSkillsResolveNameRetrieveUrl = (projectId: string,skillName: string,diff --git a/products/skills/frontend/generated/api.zod.ts b/products/skills/frontend/generated/api.zod.tsindex 10f996ededec..33dab738ff51 100644--- a/products/skills/frontend/generated/api.zod.ts+++ b/products/skills/frontend/generated/api.zod.ts@@ -334,3 +334,14 @@ export const LlmSkillsNamePublishCommunityCreateBody = /* @__PURE__ */ zod.objec"The publisher's GitHub username, used for public attribution on the listing and PR. Optional, and self-reported: it is not verified against the publisher's PostHog account."),})++export const llmSkillsNameRenameCreateBodyNewNameMax = 64++export const LlmSkillsNameRenameCreateBody = /* @__PURE__ */ zod.object({+ new_name: zod+ .string()+ .max(llmSkillsNameRenameCreateBodyNewNameMax)+ .describe(+ "New name for the skill. Must be unique in the project, and must not start with 'signals-scout-' or 'review-hog-'."+ ),+})diff --git a/products/skills/frontend/llmSkillLogic.test.ts b/products/skills/frontend/llmSkillLogic.test.tsindex dc58edb66390..59f8c935d1f2 100644--- a/products/skills/frontend/llmSkillLogic.test.ts+++ b/products/skills/frontend/llmSkillLogic.test.ts@@ -1,3 +1,4 @@+import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'@@ -8,6 +9,7 @@ import { initKeaTests } from '~/test/init'import {llmSkillsNameFilesRetrieve,llmSkillsNamePartialUpdate,+ llmSkillsNameRenameCreate,llmSkillsResolveNameRetrieve,} from 'products/skills/frontend/generated/api'import type { LLMSkillApi, LLMSkillResolveResponseApi } from 'products/skills/frontend/generated/api.schemas'@@ -25,12 +27,14 @@ jest.mock('products/skills/frontend/generated/api', () => ({llmSkillsNameArchiveCreate: jest.fn(),llmSkillsNameFilesRetrieve: jest.fn(),llmSkillsNamePartialUpdate: jest.fn(),+ llmSkillsNameRenameCreate: jest.fn(),llmSkillsResolveNameRetrieve: jest.fn(),}))const mockPartialUpdate = llmSkillsNamePartialUpdate as jest.MockedFunction<typeof llmSkillsNamePartialUpdate>const mockResolve = llmSkillsResolveNameRetrieve as jest.MockedFunction<typeof llmSkillsResolveNameRetrieve>const mockFilesRetrieve = llmSkillsNameFilesRetrieve as jest.MockedFunction<typeof llmSkillsNameFilesRetrieve>+const mockRename = llmSkillsNameRenameCreate as jest.MockedFunction<typeof llmSkillsNameRenameCreate>const MOCK_FILE = { path: 'scripts/run.sh', content: 'echo hi', content_type: 'text/x-shellscript' }@@ -236,6 +240,50 @@ describe('llmSkillLogic', () => {})})+ describe('renaming', () => {+ let logic: ReturnType<typeof llmSkillLogic.build>++ beforeEach(async () => {+ jest.clearAllMocks()+ initKeaTests()+ mockResolve.mockResolvedValue(resolveResponse(mockSkill))+ logic = llmSkillLogic({ skillName: 'my-test-skill' })+ logic.mount()+ await expectLogic(logic).toDispatchActions(['loadSkillSuccess'])+ })++ afterEach(() => {+ logic?.unmount()+ })++ it('sends the rename and follows the skill to its new URL', async () => {+ mockRename.mockResolvedValue({ ...mockSkill, name: 'renamed-skill' } as unknown as LLMSkillApi)++ logic.actions.renameSkill('renamed-skill')+ await expectLogic(logic).toFinishAllListeners()++ expect(mockRename).toHaveBeenCalledWith(expect.anything(), 'my-test-skill', {+ new_name: 'renamed-skill',+ })+ // The old name no longer resolves, so staying on it would show a "skill not found" page.+ expect(router.values.location.pathname).toContain('renamed-skill')+ expect(logic.values.renamingSkill).toBe(false)+ })++ it('surfaces the reason and stays put when the rename is rejected', async () => {+ mockRename.mockRejectedValue(+ new ApiError('invalid', 400, undefined, { detail: 'A skill with this name already exists.' })+ )++ logic.actions.renameSkill('taken')+ await expectLogic(logic).toFinishAllListeners()++ expect(lemonToast.error).toHaveBeenCalledWith('A skill with this name already exists.')+ expect(router.values.location.pathname).not.toContain('taken')+ expect(logic.values.renamingSkill).toBe(false)+ })+ })+describe('file uploads', () => {let logic: ReturnType<typeof llmSkillLogic.build>diff --git a/products/skills/frontend/llmSkillLogic.ts b/products/skills/frontend/llmSkillLogic.tsindex 5ffab6943065..336c79055a90 100644--- a/products/skills/frontend/llmSkillLogic.ts+++ b/products/skills/frontend/llmSkillLogic.ts@@ -28,6 +28,7 @@ import {llmSkillsNameArchiveCreate,llmSkillsNameFilesRetrieve,llmSkillsNamePartialUpdate,+ llmSkillsNameRenameCreate,llmSkillsResolveNameRetrieve,} from 'products/skills/frontend/generated/api'import type {@@ -228,6 +229,7 @@ export interface llmSkillLogicValues {ownerDraftChanged: booleanownersEditing: booleanpublishConflict: PublishConflict | null+ renamingSkill: booleansavingOwners: booleanselectedVersion: number | nullshouldDisplaySkeleton: boolean@@ -315,6 +317,9 @@ export interface llmSkillLogicActions {openPublishReview: () => {value: true}+ renameSkill: (newName: string) => {+ newName: string+ }requestPublish: () => {value: true}@@ -342,6 +347,9 @@ export interface llmSkillLogicActions {setPublishConflict: (publishConflict: PublishConflict | null) => {publishConflict: PublishConflict | null}+ setRenamingSkill: (renaming: boolean) => {+ renaming: boolean+ }setSavingOwners: (saving: boolean) => {saving: boolean}@@ -460,6 +468,8 @@ export const llmSkillLogic = kea<llmSkillLogicType>([addUploadedFiles: (files: SkillFileUpload[]) => ({ files }),setSkill: (skill: ResolvedLLMSkill | SkillFormValues) => ({ skill }),deleteSkill: true,+ renameSkill: (newName: string) => ({ newName }),+ setRenamingSkill: (renaming: boolean) => ({ renaming }),loadMoreVersions: true,setVersionsLoading: (versionsLoading: boolean) => ({ versionsLoading }),setMode: (mode: SkillMode) => ({ mode }),@@ -615,6 +625,13 @@ export const llmSkillLogic = kea<llmSkillLogicType>([setSavingOwners: (_, { saving }) => saving,},],+ renamingSkill: [+ false,+ {+ renameSkill: () => true,+ setRenamingSkill: (_, { renaming }) => renaming,+ },+ ],})),loaders(({ props }) => ({@@ -1031,6 +1048,28 @@ export const llmSkillLogic = kea<llmSkillLogicType>([}},+ renameSkill: async ({ newName }) => {+ const currentSkill = values.skill+ if (props.skillName === 'new' || !isSkill(currentSkill) || newName === currentSkill.name) {+ actions.setRenamingSkill(false)+ return+ }+ try {+ await llmSkillsNameRenameCreate(String(ApiConfig.getCurrentTeamId()), currentSkill.name, {+ new_name: newName,+ })+ lemonToast.success(`Skill renamed to "${newName}".`)+ llmSkillsLogic.findMounted()?.actions.loadSkills(false)+ // The name is the route key, so the open page has to follow the skill to its new URL.+ router.actions.replace(urls.skill(newName))+ } catch (error) {+ console.error('Failed to rename skill', error)+ lemonToast.error(getApiErrorDetail(error) || "Couldn't rename the skill. Try again.")+ } finally {+ actions.setRenamingSkill(false)+ }+ },+loadMoreVersions: async () => {if (props.skillName === 'new' || !isSkill(values.skill)) {actions.setVersionsLoading(false)diff --git a/products/skills/frontend/skillConstants.ts b/products/skills/frontend/skillConstants.tsindex 49c33300f003..ae05f49826dd 100644--- a/products/skills/frontend/skillConstants.ts+++ b/products/skills/frontend/skillConstants.ts@@ -9,6 +9,11 @@ export const SKILL_FILE_MAX_COUNT = 200// Kept in sync with MAX_SKILL_OWNERS in the backend skill_serializers.export const SKILL_OWNER_MAX_COUNT = 25+// Name prefixes that Signals and ReviewHog key their own per-skill settings on, so a skill cannot+// be renamed into or out of one. Kept in sync with CATEGORY_BY_NAME_PREFIX in the backend+// products/skills/backend/models/skills.py.+export const PRODUCT_OWNED_SKILL_NAME_PREFIXES = ['signals-scout-', 'review-hog-']+// Names that collide with reserved /skills routes: 'new' (the create form) and the tab slugs// registered under /skills/<slug> in manifest.tsx. A skill with one of these names would be// shadowed by its route. Kept in sync with RESERVED_SKILL_NAMES in the backend skill_serializers.diff --git a/products/skills/frontend/skillSceneComponents.tsx b/products/skills/frontend/skillSceneComponents.tsxindex b3a6aad106fa..538a2902ccbe 100644--- a/products/skills/frontend/skillSceneComponents.tsx+++ b/products/skills/frontend/skillSceneComponents.tsx@@ -12,6 +12,7 @@ import { LemonDialog } from '~/lib/lemon-ui/LemonDialog'import type { SkillFormFileValues } from './llmSkillLogic'import { isSkill, llmSkillLogic } from './llmSkillLogic'+import { SKILL_NAME_MAX_LENGTH, validateSkillName } from './skillConstants'export { LLMSkillsScene } from './LLMSkillsScene'export { LLMSkillScene } from './LLMSkillScene'@@ -27,6 +28,30 @@ export function openArchiveSkillDialog(onConfirm: () => void): void {})}+/** Collect the new name, then hand it to `onRename`. */+export function openRenameSkillDialog(skillName: string, onRename: (newName: string) => void): void {+ LemonDialog.openForm({+ title: 'Rename skill',+ description:+ "Agents call the skill by its name, and the name is also its URL and its folder in the zip export. Renaming keeps the skill's version history and owners.",+ initialValues: { newName: skillName },+ content: (+ <LemonField name="newName" label="New skill name">+ <LemonInput+ data-attr="llma-skill-rename-name"+ placeholder="my-skill-name"+ maxLength={SKILL_NAME_MAX_LENGTH}+ autoFocus+ />+ </LemonField>+ ),+ errors: {+ newName: (name: string) => validateSkillName(name),+ },+ onSubmit: ({ newName }) => onRename(newName),+ })+}+interface PublishToCommunityOptions {display_name?: stringtags?: string[]diff --git a/products/skills/mcp/tools.yaml b/products/skills/mcp/tools.yamlindex 2c4fcc602e11..f717d06ce5c3 100644--- a/products/skills/mcp/tools.yaml+++ b/products/skills/mcp/tools.yaml@@ -183,6 +183,24 @@ tools:skill-get to fetch full content). To link a user to a skill in the PostHog app, build the URL from the skill`name`, not its `id`: `/llm-analytics/skills/<name>` (e.g. `/llm-analytics/skills/pr-shepherd`). The `id`(UUID) is not a valid route segment and will 404.+ skill-rename:+ operation: llm_skills_name_rename_create+ enabled: true+ scopes:+ - llm_skill:write+ annotations:+ readOnly: false+ destructive: false+ idempotent: false+ title: Rename skill+ description: >+ Rename an agent skill, keeping its version history, bundled files, and owners. The name is the slug agents+ call and the directory in the zip export, so a rename changes every one of them at once. Fails with 404 if+ the skill does not exist, and with 400 if the new name is taken or if either name starts with+ 'signals-scout-' or 'review-hog-' (those products key their own settings on the skill name).+ param_overrides:+ skill_name:+ description: The current kebab-case name of the skill to rename.skill-resolve:operation: llm_skills_resolve_name_retrieveenabled: falsediff --git a/products/skills/skills/skills-store/SKILL.md b/products/skills/skills/skills-store/SKILL.mdindex d146c73e53ed..466ce4f6f66a 100644--- a/products/skills/skills/skills-store/SKILL.md+++ b/products/skills/skills/skills-store/SKILL.md@@ -25,6 +25,7 @@ PostHog is the primary store for team-shared skills — always use the PostHog M| `posthog:skill-file-delete` | Remove one bundled file from a skill || `posthog:skill-file-rename` | Rename one bundled file (move without rewriting content) || `posthog:skill-duplicate` | Duplicate an existing skill under a new name |+| `posthog:skill-rename` | Rename a skill, keeping its versions, files, and owners || `posthog:skill-archive` | Archive all versions of a skill by name (cannot be undone) |Skills use progressive disclosure: discover by description, fetch the body only when relevant, and pull individual files on demand. Do not fetch every file eagerly.@@ -232,7 +233,7 @@ description: >-Use when the user asks to list, run, or manage PostHog skills,or references /phs, "ph skills", or "posthog skills".user-invocable: true-allowed-tools: mcp__posthog__skill-list, mcp__posthog__skill-get, mcp__posthog__skill-create, mcp__posthog__skill-update, mcp__posthog__skill-file-get, mcp__posthog__skill-file-create, mcp__posthog__skill-file-delete, mcp__posthog__skill-file-rename, mcp__posthog__skill-duplicate+allowed-tools: mcp__posthog__skill-list, mcp__posthog__skill-get, mcp__posthog__skill-create, mcp__posthog__skill-update, mcp__posthog__skill-file-get, mcp__posthog__skill-file-create, mcp__posthog__skill-file-delete, mcp__posthog__skill-file-rename, mcp__posthog__skill-duplicate, mcp__posthog__skill-rename---# PostHog Skills Storediff --git a/products/skills/skills/working-with-skills/SKILL.md b/products/skills/skills/working-with-skills/SKILL.mdindex 5140083bc3a4..541cb2561f00 100644--- a/products/skills/skills/working-with-skills/SKILL.md+++ b/products/skills/skills/working-with-skills/SKILL.md@@ -58,6 +58,9 @@ Editing an existing skill?│ └─ Rename .......................... skill-file-rename└─ Wholesale bundle reset (rare!) ....... update(files=[...]) # replaces ALL files+Renaming the skill itself?+ └─► skill-rename (keeps versions, files, and owners)+Want a fork as the starting point?└─► skill-duplicate (then update the copy)diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex dcf13d235987..6e7fba4a7e68 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -10219,6 +10219,20 @@"readOnlyHint": true}},+ "skill-rename": {+ "description": "Rename an agent skill, keeping its version history, bundled files, and owners. The name is the slug agents call and the directory in the zip export, so a rename changes every one of them at once. Fails with 404 if the skill does not exist, and with 400 if the new name is taken or if either name starts with 'signals-scout-' or 'review-hog-' (those products key their own settings on the skill name).",+ "category": "Skills",+ "feature": "skills",+ "summary": "Rename skill",+ "title": "Rename skill",+ "required_scopes": ["llm_skill:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ }+ },"skill-store-install-command": {"description": "Get ready-to-paste commands that install this team's skill store into a coding agent as an auto-updating plugin marketplace. Returns both a Claude Code command (the `command` field) and an OpenAI Codex command (the `codex_command` field) for the same marketplace. On first use it mints a dedicated, read-only credential (scoped to skills only, scope llm_skill:read) for the calling user and returns the full commands with the token embedded. If the user is already connected it returns the existing connection masked, with no token — pass rotate=true to issue a fresh token. The credential is per-user, so rotating only ever replaces the caller's own token and never breaks a teammate's setup. Only call this when the user asks to connect or install their skills into a coding agent. Give the user the command matching their agent (Claude Code or Codex).","category": "Skills",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex cc15d7f0ec19..8758207b0583 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -10789,6 +10789,20 @@"readOnlyHint": true}},+ "skill-rename": {+ "description": "Rename an agent skill, keeping its version history, bundled files, and owners. The name is the slug agents call and the directory in the zip export, so a rename changes every one of them at once. Fails with 404 if the skill does not exist, and with 400 if the new name is taken or if either name starts with 'signals-scout-' or 'review-hog-' (those products key their own settings on the skill name).",+ "category": "Skills",+ "feature": "skills",+ "summary": "Rename skill",+ "title": "Rename skill",+ "required_scopes": ["llm_skill:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ }+ },"skill-store-install-command": {"description": "Get ready-to-paste commands that install this team's skill store into a coding agent as an auto-updating plugin marketplace. Returns both a Claude Code command (the `command` field) and an OpenAI Codex command (the `codex_command` field) for the same marketplace. On first use it mints a dedicated, read-only credential (scoped to skills only, scope llm_skill:read) for the calling user and returns the full commands with the token embedded. If the user is already connected it returns the existing connection masked, with no token — pass rotate=true to issue a fresh token. The credential is per-user, so rotating only ever replaces the caller's own token and never breaks a teammate's setup. Only call this when the user asks to connect or install their skills into a coding agent. Give the user the command matching their agent (Claude Code or Codex).","category": "Skills",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 216142e289b3..92493fbab907 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -48512,6 +48512,14 @@ export namespace Schemas {author_handle?: string;}+ export interface LLMSkillRename {+ /**+ * New name for the skill. Must be unique in the project, and must not start with 'signals-scout-' or 'review-hog-'.+ * @maxLength 64+ */+ new_name: string;+ }+export interface LLMSkillVersionSummary {readonly id: string;readonly version: number;diff --git a/services/mcp/src/generated/skills/api.ts b/services/mcp/src/generated/skills/api.tsindex 0f5710ca6e41..04a7c4ff417c 100644--- a/services/mcp/src/generated/skills/api.ts+++ b/services/mcp/src/generated/skills/api.ts@@ -3,7 +3,7 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 11 enabled ops+ * PostHog API - MCP 12 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'@@ -441,3 +441,25 @@ export const LlmSkillsNameFilesDestroyQueryParams = () => zod.object({'Latest version you are editing from. If provided, the request fails with 409 when another write has landed in the meantime.'),})++export const llmSkillsNameRenameCreatePathSkillNameRegExp = new RegExp('^[^\/]+$')++export const LlmSkillsNameRenameCreateParams = () => zod.object({+ project_id: zod+ .string()+ .describe(+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."+ ),+ skill_name: zod.string().regex(llmSkillsNameRenameCreatePathSkillNameRegExp),+})++export const llmSkillsNameRenameCreateBodyNewNameMax = 64++export const LlmSkillsNameRenameCreateBody = () => zod.object({+ new_name: zod+ .string()+ .max(llmSkillsNameRenameCreateBodyNewNameMax)+ .describe(+ "New name for the skill. Must be unique in the project, and must not start with 'signals-scout-' or 'review-hog-'."+ ),+})diff --git a/services/mcp/src/lib/instructions.ts b/services/mcp/src/lib/instructions.tsindex 18351e8c1630..e29bed41a092 100644--- a/services/mcp/src/lib/instructions.ts+++ b/services/mcp/src/lib/instructions.ts@@ -247,6 +247,7 @@ export class ToolDomainExtractor {'pause','publish','record',+ 'rename','reset','restore','resume',diff --git a/services/mcp/src/tools/generated/skills.ts b/services/mcp/src/tools/generated/skills.tsindex 311dfc4ea9b8..cf5113e0b220 100644--- a/services/mcp/src/tools/generated/skills.ts+++ b/services/mcp/src/tools/generated/skills.ts@@ -259,6 +259,36 @@ const skillList = (): ToolBase<ReturnType<typeof SkillListSchema>, Schemas.Pagin},})+const SkillRenameSchema = () => {+ const LlmSkillsNameRenameCreateBody = orvalSchemas.LlmSkillsNameRenameCreateBody()+ const LlmSkillsNameRenameCreateParams = orvalSchemas.LlmSkillsNameRenameCreateParams()+ return LlmSkillsNameRenameCreateParams.omit({ project_id: true })+ .extend(LlmSkillsNameRenameCreateBody.shape)+ .extend({+ skill_name: LlmSkillsNameRenameCreateParams.shape['skill_name'].describe(+ 'The current kebab-case name of the skill to rename.'+ ),+ })+}++const skillRename = (): ToolBase<ReturnType<typeof SkillRenameSchema>, Schemas.LLMSkill> => ({+ name: 'skill-rename',+ schema: SkillRenameSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof SkillRenameSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const body: Record<string, unknown> = {}+ if (params.new_name !== undefined) {+ body['new_name'] = params.new_name+ }+ const result = await context.api.request<Schemas.LLMSkill>({+ method: 'POST',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/llm_skills/name/${encodeURIComponent(String(params.skill_name))}/rename/`,+ body,+ })+ return result+ },+})+const SkillStoreInstallCommandSchema = () => {const LlmSkillsMarketplaceInstallCommandCreateBody = orvalSchemas.LlmSkillsMarketplaceInstallCommandCreateBody()return LlmSkillsMarketplaceInstallCommandCreateBody.extend({@@ -356,6 +386,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'skill-file-rename': skillFileRename,'skill-get': skillGet,'skill-list': skillList,+ 'skill-rename': skillRename,'skill-store-install-command': skillStoreInstallCommand,'skill-update': skillUpdate,}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/skill-rename.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/skill-rename.jsonnew file mode 100644index 000000000000..5c573e7467a2--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/skill-rename.json@@ -0,0 +1,17 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "new_name": {+ "description": "New name for the skill. Must be unique in the project, and must not start with 'signals-scout-' or 'review-hog-'.",+ "maxLength": 64,+ "type": "string"+ },+ "skill_name": {+ "description": "The current kebab-case name of the skill to rename.",+ "pattern": "^[^/]+$",+ "type": "string"+ }+ },+ "required": ["skill_name", "new_name"],+ "type": "object"+}diff --git a/services/mcp/tests/unit/instructions.test.ts b/services/mcp/tests/unit/instructions.test.tsindex 97b1c873e294..bad0c0268a32 100644--- a/services/mcp/tests/unit/instructions.test.ts+++ b/services/mcp/tests/unit/instructions.test.ts@@ -172,6 +172,7 @@ describe('buildToolDomainsBlock', () => {'pause','publish','record',+ 'rename','reset','restore','resume',