forcedotcom/sf-skills / plugins/builder/dx-devops/skills/dx-devops-conflict-resolve
dx-devops-conflict-resolve
VerifiedUse this skill to diagnose and resolve what blocks a DevOps Center promotion of a work item's feature branch: Git merge conflicts and deployment failures. DevOps Center is Git-backed, so overlapping metadata changes surface as merge conflicts against the target stage branch, resolved with git (detect, resolve markers, commit, push). Deploy failures often cite a missing dependency a full promotion can fix when the component already exists on the branch. TRIGGER when the user wants to check a work item for conflicts before promoting, resolve merge conflicts or leftover conflict markers in metadata files (.xml, .object-meta.xml, .cls), reconcile a feature branch with its target stage branch, or diagnose why a DevOps Center promotion or deployment failed and whether a full promotion or a missing-dependency fix will resolve it. DO NOT TRIGGER for running the promotion itself (use dx-devops-promote), creating or updating work items (use dx-devops-work-item-manage), or deploying metadata directly to an org.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 16.5 KB |
| examples/conflict-workflows.md | markdown | 7.2 KB |
| references/deploy-failure-resolution.md | markdown | 5.0 KB |
| references/git-conflict-resolution.md | markdown | 6.4 KB |
| scripts/detect-conflicts.shexecutable | script | 3.5 KB |
| scripts/diagnose-deploy-failure.shexecutable | script | 7.1 KB |
scripts/diagnose-deploy-failure.sh
View on GitHub#!/usr/bin/env bash
# diagnose-deploy-failure.sh — Classify a DevOps Center promotion/deploy failure
# and decide whether a FULL PROMOTION can fix it.
#
# DevOps Center promotes by deploying a work item's feature branch into the target
# stage branch. A promotion can fail for two broad reasons:
# 1. Merge conflict — the branches conflict; re-promoting will not help. Resolve
# the conflict first (scripts/detect-conflicts.sh + the resolve workflow).
# 2. Deploy error — frequently a MISSING DEPENDENCY: the deployed set
# references a component it does not include. A FULL promotion (promote ALL
# pending changes for the work item, not a partial/selective set) can fix this
# ONLY if the missing component actually exists on the feature branch.
#
# This script parses the error text; when it finds a missing dependency it checks,
# with `git show`, whether that component's source file is present on the branch.
#
# Usage: diagnose-deploy-failure.sh <error-file|-> <feature-branch> [target-branch] [remote]
# Pass '-' as the first argument to read the error text from stdin.
# Example: sf project deploy start ... 2>&1 \
# | scripts/diagnose-deploy-failure.sh - feature/WI-101 uat origin
#
# Output: key=value lines the agent parses —
# REASON, CAN_FULL_PROMOTION_FIX, RECOMMENDATION, and when a dependency is parsed
# MISSING_DEPENDENCY_TYPE / MISSING_DEPENDENCY_NAME / IN_FEATURE_BRANCH
# (+ IN_TARGET_BRANCH when a target branch is given).
#
# Exit codes:
# 0 full promotion CAN fix — missing component exists on the feature branch
# 2 merge conflict — resolve the conflict, do not just re-promote
# 3 dependency not on branch — component must be added before promoting
# 4 no dependency parsed — inspect the error; a full promotion likely won't help
# 1 usage / environment error
set -euo pipefail
ERR_SRC="${1:?usage: diagnose-deploy-failure.sh <error-file|-> <feature-branch> [target-branch] [remote]}"
FEATURE="${2:?usage: diagnose-deploy-failure.sh <error-file|-> <feature-branch> [target-branch] [remote]}"
TARGET="${3:-}"
REMOTE="${4:-origin}"
# Read the error text from a file or stdin.
if [ "$ERR_SRC" = "-" ]; then
ERR="$(cat)"
elif [ -f "$ERR_SRC" ]; then
ERR="$(cat "$ERR_SRC")"
else
echo "ERROR: error source '$ERR_SRC' is not a readable file (use '-' to read stdin)." >&2
exit 1
fi
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "ERROR: not inside a git repository." >&2
exit 1
fi
shopt -s nocasematch
# 1. Merge conflict? A full promotion cannot fix it — resolve the conflict instead.
if [[ "$ERR" =~ (MERGE_CONFLICT|CONFLICTS:) ]]; then
echo "REASON=merge_conflict"
echo "CAN_FULL_PROMOTION_FIX=false"
echo "RECOMMENDATION=This is a merge conflict, not a missing dependency. Resolve it with the conflict workflow (scripts/detect-conflicts.sh, then merge/resolve/commit/push the feature branch), then re-promote."
exit 2
fi
# 2. Try to parse a missing dependency (type + name) from the error text.
# Order mirrors the DevOps Center provider: "Variable does not exist" first.
DEP_TYPE=""
DEP_NAME=""
if [[ "$ERR" =~ Variable[[:space:]]+does[[:space:]]+not[[:space:]]+exist:[[:space:]]*([A-Za-z0-9_]+) ]]; then
DEP_TYPE="ApexClass"; DEP_NAME="${BASH_REMATCH[1]}"
elif [[ "$ERR" =~ no[[:space:]]+(ApexClass|ApexTrigger|ApexPage|CustomObject|Flow)[[:space:]]+named[[:space:]]+([A-Za-z0-9_]+)[[:space:]]+found ]]; then
DEP_TYPE="${BASH_REMATCH[1]}"; DEP_NAME="${BASH_REMATCH[2]}"
elif ! [[ "$ERR" =~ (Variable[[:space:]]does[[:space:]]not[[:space:]]exist|Problem:) ]] \
&& [[ "$ERR" =~ Type:[[:space:]]*(ApexClass|ApexTrigger|ApexPage|Profile|CustomObject|Flow) ]]; then
DEP_TYPE="${BASH_REMATCH[1]}"
if [[ "$ERR" =~ Component:[[:space:]]*([A-Za-z0-9_]+) ]]; then
DEP_NAME="${BASH_REMATCH[1]}"
else
DEP_TYPE="" # need both type and name to act
fi
fi
# Canonicalize the metadata type (nocasematch may capture any casing from the error).
canon_type() {
case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in
apexclass) echo "ApexClass" ;;
apextrigger) echo "ApexTrigger" ;;
apexpage) echo "ApexPage" ;;
profile) echo "Profile" ;;
customobject) echo "CustomObject" ;;
flow) echo "Flow" ;;
*) echo "" ;;
esac
}
CANON=""
[ -n "$DEP_TYPE" ] && CANON="$(canon_type "$DEP_TYPE")"
if [ -z "$CANON" ] || [ -z "$DEP_NAME" ]; then
echo "REASON=no_dependency_parsed"
echo "CAN_FULL_PROMOTION_FIX=false"
echo "RECOMMENDATION=Could not identify a missing component from the error. Inspect the full deploy error and fix the underlying metadata/test issue, then re-promote. A full promotion is unlikely to help unless the failure is a missing dependency."
exit 4
fi
# Candidate source paths for the component (standard SFDX layouts).
paths_for() {
local t="$1" n="$2"
case "$t" in
ApexClass) printf '%s\n' "force-app/main/default/classes/$n.cls" "main/default/classes/$n.cls" "classes/$n.cls" ;;
ApexTrigger) printf '%s\n' "force-app/main/default/triggers/$n.trigger" "main/default/triggers/$n.trigger" ;;
ApexPage) printf '%s\n' "force-app/main/default/pages/$n.page" "main/default/pages/$n.page" ;;
Profile) printf '%s\n' "force-app/main/default/profiles/$n.profile-meta.xml" "main/default/profiles/$n.profile-meta.xml" ;;
CustomObject) printf '%s\n' "force-app/main/default/objects/$n/$n.object-meta.xml" "main/default/objects/$n/$n.object-meta.xml" ;;
Flow) printf '%s\n' "force-app/main/default/flows/$n.flow-meta.xml" "main/default/flows/$n.flow-meta.xml" ;;
esac
}
# Is at least one candidate path present in the branch? Try the local ref, then the remote ref.
present_in_branch() {
local branch="$1" t="$2" n="$3" p
while IFS= read -r p; do
[ -z "$p" ] && continue
if git show "$branch:$p" >/dev/null 2>&1 || git show "$REMOTE/$branch:$p" >/dev/null 2>&1; then
return 0
fi
done <<EOF
$(paths_for "$t" "$n")
EOF
return 1
}
IN_FEATURE=false
if present_in_branch "$FEATURE" "$CANON" "$DEP_NAME"; then IN_FEATURE=true; fi
IN_TARGET=""
if [ -n "$TARGET" ]; then
if present_in_branch "$TARGET" "$CANON" "$DEP_NAME"; then IN_TARGET=true; else IN_TARGET=false; fi
fi
echo "MISSING_DEPENDENCY_TYPE=$CANON"
echo "MISSING_DEPENDENCY_NAME=$DEP_NAME"
echo "IN_FEATURE_BRANCH=$IN_FEATURE"
[ -n "$IN_TARGET" ] && echo "IN_TARGET_BRANCH=$IN_TARGET"
if [ "$IN_FEATURE" = true ]; then
echo "REASON=dependency_in_feature_branch"
echo "CAN_FULL_PROMOTION_FIX=true"
echo "RECOMMENDATION=The missing component $CANON '$DEP_NAME' exists on the feature branch but was not in the deployed set. A FULL promotion (promote all pending changes for this work item, not a partial set) should include it and fix the failure. Confirm with the user, then re-promote as a full promotion via dx-devops-promote."
exit 0
fi
echo "REASON=dependency_not_in_feature_branch"
echo "CAN_FULL_PROMOTION_FIX=false"
echo "RECOMMENDATION=The missing component $CANON '$DEP_NAME' is NOT on the feature branch, so promoting the branch cannot supply it. Add and commit the missing $CANON to the work item's feature branch (or include the work item that owns it), then re-promote."
exit 3
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |