Skip to content

Refactor PR creation: extract shared partial for create_pr and work_issue prompts #38

@Helmi

Description

@Helmi

Description

We have duplicate PR creation logic in both work_issue and create_pr prompts. This creates a maintenance burden and violates DRY principles. We should extract the common PR creation logic into a Handlebars partial that both prompts can use.

Context

Technical Details

  • Affected files:
    • mcp-server/src/templates/prompts/create_pr.yaml - Refactor to use new partial
    • mcp-server/src/templates/prompts/work_issue.yaml - Refactor to use new partial
    • mcp-server/src/templates/prompts/partials/_pr_creation.hbs - New partial to create
  • Key functions/classes: Handlebars partial system, prompt templates

Requirements

Current Problems

  1. Duplicate PR creation logic in two places (maintenance burden)
  2. create_pr prompt has prescriptive git commands (against new standards from Improve work_issue command: add git sync check and remove redundancies #30)
  3. No single source of truth for PR creation

Proposed Solution

  • Extract PR creation logic into a shared Handlebars partial (e.g., _pr_creation.hbs)
  • create_pr.yaml keeps its context gathering (fetch issue, analyze changes) then uses partial
  • work_issue.yaml skips context gathering (already has it) and uses the partial
  • Update create_pr to follow new prompt standards (no prescriptive commands)

Benefits

  • Single source of truth for PR creation
  • Context-aware usage (create_pr gathers context, work_issue already has it)
  • Follows DRY principles
  • Uses existing Handlebars infrastructure

Implementation Steps

  • Step 1: Create new partial file _pr_creation.hbs in partials directory
  • Step 2: Extract common PR creation logic from work_issue.yaml step 6
  • Step 3: Define partial interface (expected variables: title, body, issue number, etc.)
  • Step 4: Update work_issue.yaml to use {{> pr_creation}} instead of inline logic
  • Step 5: Remove prescriptive git commands from create_pr.yaml
  • Step 6: Update create_pr.yaml to use {{> pr_creation}} for PR creation
  • Step 7: Test both prompts to ensure they still work correctly

Acceptance Criteria

  • Single _pr_creation.hbs partial contains all PR creation logic
  • Both create_pr and work_issue prompts use the shared partial
  • No duplicate PR creation code exists
  • create_pr prompt follows new standards (no prescriptive commands)
  • Both prompts successfully create PRs when tested
  • Partial gracefully handles missing optional parameters

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions