get-story-branch-name
Generate a valid Git branch name for a Shortcut story to organize development work and track changes.
Instructions
Get a valid branch name for a specific story.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| storyPublicId | Yes | The public Id of the story |
Implementation Reference
- src/tools/stories.ts:372-385 (handler)The handler function getStoryBranchName that implements the core logic: fetches current user and story, uses existing formatted_vcs_branch_name or generates a new one via createBranchName, and returns the branch name.async getStoryBranchName(storyPublicId: number) { const currentUser = await this.client.getCurrentUser(); if (!currentUser) throw new Error("Unable to find current user"); const story = await this.client.getStory(storyPublicId); if (!story) throw new Error(`Failed to retrieve Shortcut story with public ID: ${storyPublicId}`); const branchName = (story as Story & { formatted_vcs_branch_name: string | null }).formatted_vcs_branch_name || this.createBranchName(currentUser, story); return this.toResult(`Branch name for story sc-${storyPublicId}: ${branchName}`); }
- src/tools/stories.ts:13-20 (registration)Tool registration using server.tool, including name, description, input schema, and reference to the handler method.server.tool( "get-story-branch-name", "Get a valid branch name for a specific story.", { storyPublicId: z.number().positive().describe("The public Id of the story"), }, async ({ storyPublicId }) => await tools.getStoryBranchName(storyPublicId), );
- src/tools/stories.ts:16-18 (schema)Input schema definition using Zod for the storyPublicId parameter.{ storyPublicId: z.number().positive().describe("The public Id of the story"), },
- src/tools/stories.ts:365-370 (helper)Helper function to generate a branch name in the format {mention_name}/sc-{id}/{slugified-name}, truncated to 50 chars.private createBranchName(currentUser: MemberInfo, story: Story) { return `${currentUser.mention_name}/sc-${story.id}/${story.name .toLowerCase() .replace(/\s+/g, "-") .replace(/[^\w-]/g, "")}`.substring(0, 50); }