Dx devops promote

From forcedotcom/sf-skills · View interactive version

Dx devops promote is an AI agent skill from the GitHub repository forcedotcom/sf-skills. Use this skill to drive the full DevOps Center promotion workflow for work items and pipeline stages — validate preconditions, prepare work items, optionally combine work items that share metadata, promote one or more work items or an entire stage to a target pipeline stage, and complete the promoti

How to use this skill

Skill file

DevOps Center Promotion

Drives the full promotion workflow in DevOps Center — validate, prepare, optionally combine, promote, and complete — moving work items through the release pipeline. Provides headless, --json-driven, idempotent operations for autonomous release workflows in CI. Every promotion begins with a mandatory validate step.

Scope


Required Inputs

Gather or infer before proceeding:

Defaults unless specified:

If the user gives a clear request ("promote work item 1fkxx… to stage 1QVxx…", "promote the QA stage to UAT", "combine these work items and promote"), proceed once you have the required IDs.


Workflow

All operations use sf devops CLI commands with --json output. Validate ALWAYS runs first. All promotion commands are keyed on record IDs, not work item names — resolve names to IDs first if needed.

Phase 1 — Authenticate and Validate

  1. Verify org authentication before any operation:

```bash

sf org display --json

```

  1. Run the mandatory validate step — this is non-negotiable and always runs before prepare/combine/promote. sf devops promotion validate requires the target stage (-t/--target-stage-id) and one or more -i/--work-item-id:

```bash

# Capture the output — Phase 2 derives the combine decision from it deterministically.

VALIDATE_JSON=$(sf devops promotion validate --work-item-id <id> --target-stage-id <target-stage-id> --target-org <alias> --json)

```

Phase 2 — Prepare (and optionally Combine)

  1. Prepare the work item for promotion:

```bash

sf devops work-item prepare --work-item-id <id> --target-stage-id <target-stage-id> --target-org <alias> --json

```

  1. Combine work items — ONLY when the Phase 1 validate step reported shared components (.result.combineDetails non-null) or the work items otherwise have dependencies and must promote as one unit. Do not eyeball the JSON — derive the decision and the parent/child IDs deterministically from the saved validate output (VALIDATE_JSON):

```bash

# COMBINE == "true" only when validate returned a combineDetails block.

COMBINE=$(printf '%s' "$VALIDATE_JSON" | jq -r '(.result.combineDetails != null)')

if [ "$COMBINE" = "true" ]; then

PARENT_ID=$(printf '%s' "$VALIDATE_JSON" | jq -r '.result.combineDetails.parentWorkitemId')

# one --child-work-item-id arg per child, safe for use as a flag array

CHILD_ARGS=()

while IFS= read -r cid; do CHILD_ARGS+=(--child-work-item-id "$cid"); done < <(

printf '%s' "$VALIDATE_JSON" | jq -r '.result.combineDetails.childWorkitemsId[]')

fi

```

Then combine using those derived values (skip this command entirely when COMBINE is not "true"):

```bash

sf devops work-item combine \

--parent-work-item-id "$PARENT_ID" \

"${CHILD_ARGS[@]}" \

--target-stage-id <stage-id> \

--target-org <alias> \

--json

```

Phase 3 — Promote

  1. Promote to the target stage — exactly one of --work-item-id or --stage-id must be provided; --target-stage-id is always required. Pass --skip-validation ONLY when the Phase 1 validate step completed successfully in the current session for every work item being promoted. Otherwise, OMIT the flag and let the CLI run its built-in validation:

```bash

sf devops promote \

--work-item-id <id> \

--target-stage-id <target-stage-id> \

--skip-validation \

--target-org <alias> \

--json

```

```bash

sf devops promote \

--stage-id <source-stage-id> \

--target-stage-id <target-stage-id> \

--skip-validation \

--target-org <alias> \

--json

```

Phase 4 — Complete and Report

  1. Complete the promotion to finalize — advances the work items in the target stage:

```bash

sf devops promotion complete --target-stage-id <target-stage-id> --target-org <alias> --json

```

  1. Report the outcome:

Rules / Constraints

| Constraint | Rationale |

|-----------|-----------|

| Validate ALWAYS runs first | Guarantees preconditions are met before any mutation; skipping it can corrupt pipeline state |

| All sf devops commands must use --json | Structured output is required for headless consumption; human-readable output is unreliable to parse |

| Commands are keyed on record IDs, not names | --work-item-id, --stage-id, --target-stage-id, --parent/--child-work-item-id all take IDs; resolve names to IDs first |

| --target-stage-id required for every promotion command (validate, prepare, combine, promote, complete) | The target stage is mandatory; the promotion has no destination without it |

| Exactly one of --work-item-id or --stage-id on promote | These flags are mutually exclusive; promote either specific items or a whole source stage |

| Pass --skip-validation on promote ONLY if Phase 1 validate passed this session | The CLI's built-in pre-promote validation runs the same checks (including the associated-PR requirement) as the Phase 1 promotion validate step. Skipping is safe only when that validation already ran successfully this session; if the agent resumed mid-workflow or promotion was invoked without a preceding validate, OMIT the flag so the CLI validates |

| Deploy runs async — capture and report the identifier | The promote deploy does not complete synchronously; completion is tracked separately |

| Do NOT busy-wait for deploy completion in this skill | Polling is a separate concern; blocking here wastes turns and risks timeouts |

| Combine only when work items share metadata/dependencies | Combining is for conflict-prone or dependent items, not a default for every multi-item promotion |

| Prepare is idempotent | Retry-safe for CI; re-running a completed prepare is a no-op |

| Never use interactive prompts | Skills run headless; all inputs must be CLI flags |

| Pass IDs as CLI flags, never interpolate into shell strings | Prevents prompt/command injection via crafted identifiers |


Gotchas

| Issue | Resolution |

|-------|------------|

| Validation fails | STOP — do not prepare/combine/promote. Report the non-zero status / error message; if metadata overlap, resolve the conflict before retrying |

| No default org set | Run sf org display --json; if it fails, instruct user to run sf org login web --set-default |

| Passing a work item name instead of an ID | Promotion commands need record IDs; resolve names via sf devops work-item list --project-id <id> --json \| jq -r '.result.workItems[] \| select(.subject == "<WI-subject>") \| .id' |

| Both --work-item-id and --stage-id supplied | They are mutually exclusive; pick specific work items OR a source stage, not both |

| Missing --target-stage-id | Required on every promotion command (validate, prepare, combine, promote, complete); obtain the target stage ID from the pipeline configuration |

| Combined promotion promotes the wrong item | After work-item combine, promote the parent work item ID — children merge into the parent's branch |

| Treating the deploy as synchronous | The promote deploy is async; capture the identifier and confirm completion before running promotion complete |

| Production deploy fails on Apex coverage | Set --test-level RunLocalTests (or RunSpecifiedTests --tests <names>) for production-stage promotions with Apex |

| Deploy fails with conflict | A conflict slipped past validate; resolve the metadata conflict, then re-validate and retry |


Output Expectations

Deliverables vary by operation:

Outputs are derived from sf devops work-item, sf devops promote, and sf devops promotion complete CLI commands. Async deploy completion is NOT produced by the promote call — poll the returned identifier separately before completing.


Cross-Skill Integration

| When | Action |

|------|--------|

| Work item must be created or moved to a promotable status first | Delegate to dx-devops-work-item-manage |

| Validation reports metadata overlap / conflict | Resolve the metadata conflict before retrying |

| The promote deploy identifier must be polled to confirm completion | Poll the returned identifier separately, then run sf devops promotion complete |


Reference File Index

| File | When to read |

|------|-------------|

| references/cli-commands.md | When you need detailed CLI flag documentation, JSON output schemas, or error-handling patterns for validate/prepare/combine/promote/complete |

| examples/promotion-workflows.md | When the user's request matches a common pattern (single work item promotion, combined promotion, whole-stage promotion, validate-first gate) |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.