Skip to content

chore(skills): Update duplicate-epic skill to work with bugs and stories#53

Open
dlabrecq wants to merge 1 commit intopatternfly:mainfrom
dlabrecq:duplicate-epic-update
Open

chore(skills): Update duplicate-epic skill to work with bugs and stories#53
dlabrecq wants to merge 1 commit intopatternfly:mainfrom
dlabrecq:duplicate-epic-update

Conversation

@dlabrecq
Copy link
Copy Markdown
Member

@dlabrecq dlabrecq commented Apr 9, 2026

Updated duplicate-epic skill to work with different JIra bugs in addition to stories.

SKILL.md

  • Updated the description frontmatter to clarify the skill accepts any issue type (Epic, Story, Bug) and uses the /duplicate-epic slash-command format
  • Rewrote the Input Parsing section with a two-column positional arg table (position, name, description)
  • Updated examples in the Workflow section to reflect that non-epic inputs are supported
  • Expanded "What the Script Does" from 5 to 7 steps, adding "Resolve current user" and "Resolve to an epic"
  • Added the Input Issue line to the Output section (only shown when the input was not itself an epic)

scripts/duplicate_epic.sh

  • Added a while loop after fetching the input issue that walks up the hierarchy (fields.parent → fields.customfield_10014) until an Epic is found — allows passing a Story or Bug directly
  • Tracks INPUT_KEY vs ORIGINAL_KEY so the resolved epic is shown separately in output
  • Strips mediaSingle and media nodes from the description when cloning (avoids Jira API errors for embedded attachments)
  • Wrapped the issueLink POST in a subshell so a permission error produces a WARNING instead of aborting the script

Summary by CodeRabbit

  • New Features

    • The tool now accepts any Jira issue type (Story, Bug, etc.) as input and automatically resolves to the parent epic.
  • Bug Fixes

    • Link creation failures no longer abort script execution; warnings are logged instead for improved reliability.
  • Documentation

    • Updated skill documentation to reflect new input parameters, workflow steps including epic resolution, and improved example commands.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

Updated the duplicate-epic skill to accept any Jira issue type (not just epics) as input and automatically resolve it to its parent epic. Enhanced the script to walk the issue hierarchy, filter media elements from descriptions, ignore link creation failures, and conditionally report the original input issue in output.

Changes

Cohort / File(s) Summary
Documentation Update
plugins/issue-management/skills/duplicate-epic/SKILL.md
Updated skill contract to accept any issue type or URL as first argument ($1), with resolution to parent epic handled automatically by script. Revised examples, workflow steps, and output descriptions to reflect new resolution logic and conditional "Input Issue" reporting.
Script Implementation
plugins/issue-management/skills/duplicate-epic/scripts/duplicate_epic.sh
Implemented issue hierarchy walk-up to resolve input to parent epic via .fields.parent.key or custom field .fields.customfield_10014. Added description field filtering to remove media elements. Wrapped link creation in error-tolerant subshell to continue on failure. Updated output logic and logging to reflect new resolution flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Suggested reviewers

  • jpuzz0
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: extending the duplicate-epic skill to accept non-epic issue types (bugs and stories) instead of only epics.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/issue-management/skills/duplicate-epic/SKILL.md`:
- Around line 81-82: Update the "Clone" step in the SKILL.md "What the Script
Does" section to state that the epic description is not copied verbatim: the
script sanitizes the description by stripping mediaSingle and media nodes
(attachments/embedded media) before creating the PF clone, and note that
embedded attachments will be removed in the PF copy; keep the existing "Ensure
'is duplicated by' link" text unchanged but ensure the doc reflects this
behavior and its failure mode (attachments lost) so users aren't surprised.
- Line 3: The frontmatter "description" in SKILL.md is too long and will be
truncated in listings; shorten it to under 250 characters, front-load key use
cases and include the trigger context "/duplicate-epic <issue> <feature>"
(mentioning that it duplicates a Jira epic into the PatternFly project and links
back to the original), and remove excess detail so the core purpose and trigger
are visible in the skill listing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 07d7fca9-c7eb-49f1-ad64-1889ef5ecea5

📥 Commits

Reviewing files that changed from the base of the PR and between ae99e2e and 6085b81.

📒 Files selected for processing (2)
  • plugins/issue-management/skills/duplicate-epic/SKILL.md
  • plugins/issue-management/skills/duplicate-epic/scripts/duplicate_epic.sh

Comment on lines +189 to +194
# Run in a subshell so a permission error here does not abort the rest of the script
if (api_request POST "issueLink" "$LINK_PAYLOAD" >/dev/null 2>&1); then
echo "Link added"
else
echo "WARNING: Could not add 'is duplicated by' link (likely missing link-issue permission in the source project). Continuing..." >&2
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don't continue after a failed link on a newly created clone.

Step 4 only discovers existing PF copies via the Duplicate link on the source epic. If this POST fails after creating NEW_KEY, the script still exits successfully, and the next run will miss that clone and create another one.

At minimum, keep this non-fatal only when NEW_KEY already existed; if the clone was just created, fail here or persist some other dedupe marker before continuing.

Possible fix
+CREATED_NEW_CLONE=0
 if [[ -n "$NEW_KEY" ]]; then
   echo "Found existing clone: $NEW_KEY"
 else
   echo "Cloning $ORIGINAL_KEY into $PF_PROJECT project..."
@@
   NEW_KEY=$(api_request POST "issue" "$PAYLOAD" | jq -r '.key')
   echo "Created: $NEW_KEY"
+  CREATED_NEW_CLONE=1
 fi
@@
-  if (api_request POST "issueLink" "$LINK_PAYLOAD" >/dev/null 2>&1); then
+  if api_request POST "issueLink" "$LINK_PAYLOAD" >/dev/null 2>&1; then
     echo "Link added"
+  elif [[ "$CREATED_NEW_CLONE" -eq 0 ]]; then
+    echo "WARNING: Could not add 'is duplicated by' link (likely missing link-issue permission in the source project). Continuing..." >&2
   else
-    echo "WARNING: Could not add 'is duplicated by' link (likely missing link-issue permission in the source project). Continuing..." >&2
+    echo "ERROR: Created $NEW_KEY but could not add the duplicate link; aborting to avoid future duplicate clones." >&2
+    exit 1
   fi
 fi

---
name: duplicate-epic
description: Duplicates an Atlassian Jira epic into the PatternFly (PF) project space, adds an "is duplicated by" link referencing the original, and assigns it as a child of a given feature. This allows the PatternFly team to trace Jira work items up a hierarchy in the product Jira project. Use when asked to "duplicate epic X for feature Y", clone a COST epic to PatternFly, or replicate a Jira epic under a PF feature.
description: Duplicates an Atlassian Jira epic into the PatternFly (PF) project space, adds an "is duplicated by" link referencing the original, and assigns it as a child of a given feature. This allows the PatternFly team to trace Jira work items up a hierarchy in the product Jira project. Use when the command is "/duplicate-epic <issue> <feature>" where the first argument is any Jira issue key (Epic, Story, or Bug — the script resolves the parent epic automatically) and the second argument is the PF feature to assign the new epic to.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Shorten the frontmatter description.

This now exceeds the skill-listing limit, so the /duplicate-epic <issue> <feature> trigger text is likely to be truncated where users discover the skill.

Possible fix
-description: Duplicates an Atlassian Jira epic into the PatternFly (PF) project space, adds an "is duplicated by" link referencing the original, and assigns it as a child of a given feature. This allows the PatternFly team to trace Jira work items up a hierarchy in the product Jira project. Use when the command is "/duplicate-epic <issue> <feature>" where the first argument is any Jira issue key (Epic, Story, or Bug — the script resolves the parent epic automatically) and the second argument is the PF feature to assign the new epic to.
+description: Use when `/duplicate-epic <issue> <feature>` should clone a Jira Epic, Story, or Bug into the PF project, resolve non-epic inputs to their parent epic, link back to the source, and attach the new epic to a PF feature.

As per coding guidelines, "The description should include trigger contexts (e.g., 'Use when...') and be front-loaded with key use cases — descriptions longer than 250 characters are truncated in the skill listing."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: Duplicates an Atlassian Jira epic into the PatternFly (PF) project space, adds an "is duplicated by" link referencing the original, and assigns it as a child of a given feature. This allows the PatternFly team to trace Jira work items up a hierarchy in the product Jira project. Use when the command is "/duplicate-epic <issue> <feature>" where the first argument is any Jira issue key (Epic, Story, or Bug the script resolves the parent epic automatically) and the second argument is the PF feature to assign the new epic to.
description: Use when `/duplicate-epic <issue> <feature>` should clone a Jira Epic, Story, or Bug into the PF project, resolve non-epic inputs to their parent epic, link back to the source, and attach the new epic to a PF feature.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/issue-management/skills/duplicate-epic/SKILL.md` at line 3, The
frontmatter "description" in SKILL.md is too long and will be truncated in
listings; shorten it to under 250 characters, front-load key use cases and
include the trigger context "/duplicate-epic <issue> <feature>" (mentioning that
it duplicates a Jira epic into the PatternFly project and links back to the
original), and remove excess detail so the core purpose and trigger are visible
in the skill listing.

Comment on lines +81 to +82
4. **Clone** — if no clone exists, creates a new Epic in the `PF` project copying the summary, description, and labels.
5. **Ensure "is duplicated by" link** — adds a `Duplicate` link so the new epic displays "is duplicated by {ORIGINAL EPIC}" in its linked work items; skips if already present.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Document the description sanitization here.

The script no longer copies the description verbatim; it strips mediaSingle/media nodes before create. Calling it a straight copy will surprise users when embedded attachments disappear in the PF clone.

As per coding guidelines, "In “What the Script Does,” keep the workflow aligned with the script’s behavior and failure modes."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/issue-management/skills/duplicate-epic/SKILL.md` around lines 81 -
82, Update the "Clone" step in the SKILL.md "What the Script Does" section to
state that the epic description is not copied verbatim: the script sanitizes the
description by stripping mediaSingle and media nodes (attachments/embedded
media) before creating the PF clone, and note that embedded attachments will be
removed in the PF copy; keep the existing "Ensure 'is duplicated by' link" text
unchanged but ensure the doc reflects this behavior and its failure mode
(attachments lost) so users aren't surprised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant