Stash JIRA Skill
Purpose
Preserve current workflow artifacts by moving them from project directory to Claude home directory, enabling context switching between JIRA issues.
Usage
/stash-jira
What This Skill Does
- Detect Current JIRA: Identifies JIRA number from
workflow/jira-to-github/directory - Check Conflicts: Warns if artifacts already exist in Claude home and offers options
- Handle Artifacts: Based on user choice:
- Move to Claude home (overwrite or merge with backup)
- Delete project artifacts (keep Claude home version)
- Cancel operation
- Cleanup: Removes project workflow directory after successful operation
- Confirmation: Reports successful operation with JIRA number
Prerequisites
- Active workflow artifacts must exist in
workflow/jira-to-github/<JIRA-NUMBER>/ - Write access to
~/.claude/artifacts/jira-to-github/
Instructions
You are coordinating the stashing of JIRA workflow artifacts to Claude home directory.
Step 1: Detect Current JIRA
Find the JIRA number from the workflow directory:
# Find most recent workflow directory
WORKFLOW_DIR=$(ls -td workflow/jira-to-github/*/ 2>/dev/null | head -1)
if [ -z "$WORKFLOW_DIR" ]; then
echo "❌ No workflow artifacts found in project directory"
echo ""
echo "Nothing to stash. Workflow directory is empty."
exit 1
fi
# Extract JIRA number from path
JIRA_NUMBER=$(basename "$WORKFLOW_DIR")
Step 2: Check for Conflicts in Claude Home
Check if artifacts already exist in destination:
CLAUDE_HOME="${HOME}/.claude/artifacts/jira-to-github"
DEST_DIR="${CLAUDE_HOME}/${JIRA_NUMBER}"
if [ -d "$DEST_DIR" ]; then
# Use AskUserQuestion to ask user what to do
exit 2 # Signal to ask user confirmation
fi
If exit code 2 (destination exists):
- Use AskUserQuestion to ask: "Artifacts for JIRA-${JIRA_NUMBER} already exist in Claude home. What should I do?"
- Options:
- "Overwrite existing artifacts (Recommended)" - Delete existing, move current
- "Merge (keep both)" - Rename with timestamp suffix (e.g.,
17270-backup-2026-07-01) - "Delete artifacts from project (keep Claude home version)" - Remove project artifacts, keep existing Claude home version intact
- "Cancel stash" - Exit without making changes
- Options:
Step 3: Move Artifacts
Move all artifacts to Claude home:
# Handle user's choice from Step 2
if [ "$USER_CHOICE" = "delete" ]; then
# Just delete project artifacts, keep Claude home version
rm -rf "workflow/jira-to-github/${JIRA_NUMBER}"
# Verify deletion succeeded
if [ ! -d "workflow/jira-to-github/${JIRA_NUMBER}" ]; then
echo "✅ Deleted project artifacts for JIRA-${JIRA_NUMBER}"
echo ""
echo "Claude home version preserved at: ${DEST_DIR}"
echo ""
echo "Project directory cleared. Use /checkout-jira to restore when needed."
# Clean up empty parent directory if this was the last workflow
if [ -z "$(ls -A workflow/jira-to-github 2>/dev/null)" ]; then
rmdir workflow/jira-to-github 2>/dev/null
fi
else
echo "❌ Failed to delete project artifacts"
exit 1
fi
else
# Create Claude home directory if needed
mkdir -p "$CLAUDE_HOME"
# Handle overwrite or merge choice
if [ "$USER_CHOICE" = "overwrite" ]; then
# Remove existing artifacts
rm -rf "$DEST_DIR"
elif [ "$USER_CHOICE" = "merge" ]; then
# Rename existing with timestamp
TIMESTAMP=$(date +%Y-%m-%d-%H%M%S)
mv "$DEST_DIR" "${DEST_DIR}-backup-${TIMESTAMP}"
fi
# Move current artifacts to Claude home
mv "workflow/jira-to-github/${JIRA_NUMBER}" "$DEST_DIR"
# Verify move succeeded
if [ $? -eq 0 ] && [ ! -d "workflow/jira-to-github/${JIRA_NUMBER}" ]; then
echo "✅ Stashed JIRA-${JIRA_NUMBER}"
echo ""
echo "Artifacts moved to: ${DEST_DIR}"
echo ""
echo "You can restore these artifacts later with:"
echo "/checkout-jira ${JIRA_NUMBER}"
# Clean up empty parent directory if this was the last workflow
if [ -z "$(ls -A workflow/jira-to-github 2>/dev/null)" ]; then
rmdir workflow/jira-to-github 2>/dev/null
fi
else
echo "❌ Failed to move artifacts"
exit 1
fi
fi
Step 4: Report Success
Confirmation messages are displayed inline in Step 3 based on user's choice:
For overwrite/merge (move to Claude home):
✅ Stashed JIRA-${JIRA_NUMBER}
Artifacts moved to: ~/.claude/artifacts/jira-to-github/${JIRA_NUMBER}
You can restore these artifacts later with:
/checkout-jira ${JIRA_NUMBER}
For delete (keep Claude home version):
✅ Deleted project artifacts for JIRA-${JIRA_NUMBER}
Claude home version preserved at: ~/.claude/artifacts/jira-to-github/${JIRA_NUMBER}
Project directory cleared. Use /checkout-jira to restore when needed.
Error Handling
- No workflows found: Show message that nothing needs to be stashed
- Destination conflict: Ask user to choose overwrite, merge with timestamp, delete project version, or cancel
- Move failure: Report error, keep original artifacts intact
- Delete failure: Report error if project artifacts cannot be removed
- Permission issues: Check write access to Claude home directory
Examples
Stash current workflow before switching to a different JIRA:
/stash-jira
Integration with /checkout-jira
This skill works in tandem with /checkout-jira:
/stash-jira- Preserves current work by moving to Claude home/checkout-jira <JIRA-NUMBER>- Restores different JIRA context
Typical workflow when switching between JIRAs:
# Save current work on JIRA-17270
/stash-jira
# Switch to work on JIRA-17345
/checkout-jira 17345
# Later, switch back to JIRA-17270
/stash-jira
/checkout-jira 17270
Notes
- Move vs Copy: This skill MOVES (not copies) to avoid duplicating large artifact sets
- Recovery: All stashed artifacts remain in
~/.claude/artifacts/jira-to-github/until explicitly deleted - Multiple workflows: If multiple JIRA directories exist in project, only the most recent one is stashed