Dx devops work item manage

From forcedotcom/sf-skills · View interactive version

Dx devops work item manage is an AI agent skill from the GitHub repository forcedotcom/sf-skills. Use this skill to manage the full lifecycle of DevOps Center work items — list, create, update, commit changes, perform status transitions, and create pull requests. Update fields like subject, description, and status. Commit changes to work item branches, through the DevOps Center commit API or git

How to use this skill

Skill file

DevOps Center Work Item Management

Manages the complete work item lifecycle in DevOps Center — from creation through status transitions to promotion readiness. Provides headless CLI-driven operations for autonomous release workflows.

Scope


Required Inputs

Gather or infer before proceeding:

Defaults unless specified:

If the user provides a clear request ("list work items for Project Alpha", "create work item to fix login bug", "move WI-12345 to In Progress", "create PR for WI-12345"), proceed immediately without unnecessary questions.


Workflow

Operations use sf devops work-item CLI commands with --json output; the API commit path also uses sf api request rest and sf data query.

Phase 1 — Identify Operation

  1. Determine the operation type from user intent:

Phase 2 — Execute Operation

  1. Verify org authentication before any operation:

```bash

sf org display --json

```

```bash

sf org login web --set-default --alias <alias>

```

  1. List work items — when the user wants to see existing work items:

```bash

sf devops work-item list --project-id <project-id> --json

```

```bash

sf devops work-item list --project-id <id> --json | jq '.result[] | select(.status == "<requested-status>")'

```

Then present the matching work items

  1. Create a work item — when the user wants to create a new work item:

```bash

sf devops work-item create \

--project-id <project-id> \

--subject "<subject>" \

--description "<description>" \

--json

```

  1. Execute commit operation — when operation type is commit. Choose the path first:

API path (commands, body, error codes and polling in references/commit-api.md):

1. Preflight GET /connect/devops/doceConnectionType on the dev org; a failed call (non-zero exit or error body) or isCore not true means use the git path.

2. sf devops project list → project id, then sf devops work-item list --project-id <id> --target-org <hub> → work item id and name. Status must be New, In Progress, In Review or Ready to Promote.

3. POST /connect/devops/commitChanges on the dev org; the body is the inner object (no commitChanges wrapper).

4. A failed call, or status: "ERROR" with reqId = CODE:message: surface it and stop.

5. If the POST status is SUCCESS (accepted only), poll DevopsRequestInfo WHERE RequestToken = '<reqId>' on the dev org every 10 seconds until Status is SUCCESS or ERROR (report Message/ErrorDetails), 12-minute deadline. Past it the request is stuck; report it and do not retry automatically.

6. Confirm a new WorkItemComponentList exists on the hub before creating a review.

Git path:

```bash

git checkout <branch-name>

git add <files>

git commit -m "<commit-message>"

git push origin <branch-name>

```

  1. Update work item — when the user wants to change subject, description, or status:

```bash

sf devops work-item update \

--work-item-name <WI-name> \

--subject "<new-subject>" \

--description "<new-description>" \

--status "<In Progress|Ready to Promote>" \

--json

```

```bash

sf devops work-item list --project-id <id> --json | jq -r '.result[] | select(.subject == "<user-provided-subject>") | .name'

```

Then pass the returned name (e.g., WI-000001) to the update command

  1. Create pull request — when the user wants to create a PR for code review. Choose the path first:

API path (body, errors and idempotency in references/review-api.md):

1. Resolve the work item id and name on the hub (sf devops work-item list --project-id <id> --target-org <hub>). The work item must have a committed component list and must not be Nevered.

2. POST /connect/devops/createReview on the dev org with {workItemId, workItemName, workItemLink}; the body is the inner object (no createReview wrapper).

3. The call is synchronous. Errors return HTTP 200 with status: "Error" and errorMessage = CODE:detail. Surface it using the error table in the reference and stop.

4. On Success, reviewUrl is the PR URL. Calling again for the same work item returns the same URL, so a repeat call is safe.

5. Confirm on the hub that the work item is IN_REVIEW and ReviewRemoteReference holds the PR number.

CLI path:

```bash

sf devops review create \

--work-item-name <WI-name> \

--json

```

```bash

sf devops work-item list --project-id <id> --json | jq -r '.result[] | select(.subject == "<user-provided-subject>") | .name'

```

Then pass the returned name (e.g., WI-000001) to the review create command

Phase 3 — Verify and Report

  1. Verify operation success:
  1. Report results:

Rules / Constraints

| Constraint | Rationale |

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

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

| Work item identifier required for commit, update, and create-review | Use --work-item-name (preferred) or --work-item-id; obtain from list or prior create |

| Project ID required for list and create | All work items belong to a project; use sf devops project list --json if not provided |

| At least one update field required | Update command fails if no --subject, --description, or --status flag is provided |

| Status values must be exact strings | "In Progress" and "Ready to Promote" (with spaces, proper capitalization); other values fail |

| Idempotent create operations | Check for existing work item with same subject + project before creating duplicates |

| Commit before creating a PR | Commit first and confirm a component list exists on the hub before review create |

| API commit only sends components already in the dev org | The API retrieves from the dev org, not from local disk; deploy local-only edits first (sf project deploy start) or use the git path |

| Check status in the commit API response | Errors are returned as HTTP 200 with status: "ERROR" |

| Check status in the review API response | Errors are returned as HTTP 200 with status: "Error" and errorMessage as CODE:detail |

| PR creation requires VCS credentials in org | DevOps Center API uses stored VCS credentials; no local git auth needed |

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


Gotchas

| Issue | Resolution |

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

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

| User provides work item by subject, not name | Resolve via: sf devops work-item list --project-id <id> --json \| jq -r '.result[] \| select(.subject == "<subject>") \| .name'; then pass the returned name to the update/create-review command |

| User provides project by name, not ID | First run sf devops project list --json and filter .result[] by .name field to find the project ID, then use that ID in the list/create command |

| Status update response missing status field | The CLI doesn't always return the status field in the update response; re-run sf devops work-item list filtered to this work item and check .result[0].status to verify the transition persisted |

| Work item not found | User provided invalid work item name/ID; run list command to show available work items |

| Invalid status value | Only "In Progress" and "Ready to Promote" are valid (exact strings with spaces); check spelling and capitalization |

| Project not found | User provided invalid project ID; run sf devops project list --json to show available projects |

| Duplicate work item subject | Idempotent create check should catch this; return existing work item name instead of creating duplicate |

| Commit pushed while work item is New | The hub ignores external pushes for New work items; set In Progress first and, if already pushed, re-check after the status change |

| API commit still in progress past the deadline | Report it as stuck; do not retry automatically (a new request could race it) |

| Git push fails - no commits or branch not found | Verify files are staged with git status and branch name retrieved from work item via list command |

| Review API returns REVIEW_VCS_AUTHENTICATION_FAILED | Core maps any "not found" to this code, so a missing branch looks like an auth failure; check the work item and target branches exist as well as the credential |

| PR creation fails - VCS credentials | VCS credentials not configured in DevOps Center UI; instruct user to configure in Setup → DevOps Center → VCS Credentials |


Output Expectations

Deliverables vary by operation:

Outputs are derived from sf devops work-item CLI, sf devops review create CLI, the DevOps Center commit and review APIs, and standard git commands.


Verification Checklist

Before reporting results to the user:

Universal Checks

List Operation Checks

Create Operation Checks

Commit Operation Checks

Update Operation Checks

Create-Review Operation Checks


Reference File Index

| File | When to read |

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

| references/commit-api.md | When committing through the DevOps Center API: request body, response and error codes, polling, preflight |

| references/review-api.md | When creating a review through the DevOps Center API: request body, response and error codes, idempotency, hub confirmation |

| references/cli-commands.md | When you need detailed CLI flag documentation, JSON output schemas, or error handling patterns |

| examples/common-workflows.md | When the user's request matches a common pattern (bulk updates, reassignment, idempotent creation, sequential transitions) |

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.