Project selection
-
If the user has provided a project name (for example "Contoso project"), use it directly and do not call the project list API.
-
If not provided, ask the user to provide it once.
-
If still not provided, list the projects for the user to choose from:
curl -sS -u ":$AZURE_DEVOPS_PAT" \ "https://dev.azure.com/$AZURE_DEVOPS_ORG/_apis/projects?%24top=500&api-version=7.1"Display
value[].name. The response header (curl -D -is visible) hasx-ms-continuationtokenwhen there are more projects; add&continuationToken={token}to fetch the next page. -
Do not continue until the user provides or selects a project.
Connection and authentication
Always use curl to call the Azure DevOps REST API directly; each command carries its own authentication parameters.
- Organization: Read the environment variable
AZURE_DEVOPS_ORG(organization name, for examplecontoso). If not set, ask the user once; if the user gives a URL, extract the organization name fromhttps://dev.azure.com/{org}orhttps://{org}.visualstudio.com. - Token: Send the PAT with Basic authentication:
-u ":$AZURE_DEVOPS_PAT"; if onlyAZURE_DEVOPS_EXT_PATis set (the variable used by the Azure CLI azure-devops extension), use that instead. When switching to a Microsoft Entra ID token, use-H "Authorization: Bearer $AZURE_DEVOPS_TOKEN"instead. If neither is set, ask the user to setAZURE_DEVOPS_PATin their own terminal and retry, then stop. Read the token only from environment variables: do not ask the user to paste the token into the conversation, and do not print it or write it to a file. - PAT permission scopes:Work Items (Read)、Project and Team (Read)。
- Encoding: URL-encode project names in paths (write spaces as
%20); in query strings, write$as%24(for example%24top) to avoid shell expansion. - Errors: HTTP 401, 403, 203, or an HTML login page in the response means the token is invalid, expired, or lacks permissions; report it and stop. HTTP 404 means the organization or project name is incorrect.
- Windows PowerShell: Call
curl.exe(not thecurlalias), and write the environment variable as$env:AZURE_DEVOPS_PAT; PowerShell does not support<<'EOF', so write the JSON body to a temporary file first, then send it with--data-binary "@body.json".
Steps
-
Determine the project according to the rules above.
-
Use WIQL to find work items assigned to the current user that are not yet completed.
@Meresolves to the user the token belongs to, and@projectresolves to the project in the URL:curl -sS -u ":$AZURE_DEVOPS_PAT" -X POST -H "Content-Type: application/json" \ "https://dev.azure.com/$AZURE_DEVOPS_ORG/{project}/_apis/wit/wiql?%24top=200&api-version=7.1" \ --data-binary @- <<'EOF' {"query": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @project AND [System.AssignedTo] = @Me AND [System.State] NOT IN ('Closed', 'Done', 'Removed') ORDER BY [System.ChangedDate] DESC"} EOFThe excluded states cover the completed and removed states of the Agile, Scrum, CMMI, and Basic built-in processes. When the user asks to include completed items, remove the
[System.State]condition; if the project uses a custom process with other completed states, add them toNOT IN。 -
Fetch the response
workItems[].id. If there are no items, explain that there are no in-progress work items assigned to the user in this project, then stop. -
Fetch details with batch calls (up to 200 IDs each time; split into batches if more). If the user has not specified fields, use the default fields below:
curl -sS -u ":$AZURE_DEVOPS_PAT" -X POST -H "Content-Type: application/json" \ "https://dev.azure.com/$AZURE_DEVOPS_ORG/{project}/_apis/wit/workitemsbatch?api-version=7.1" \ -d '{"ids":[101,102],"fields":["System.Id","System.Title","System.State","System.AssignedTo","System.WorkItemType","System.CreatedDate","System.ChangedDate","System.Tags","Microsoft.VSTS.Common.Priority"],"errorPolicy":"Omit"}' -
Group by work item type (
System.WorkItemType), and within each group sort bySystem.ChangedDatefrom newest to oldest. -
Present in the format below.
Presentation result
One heading and one table per type, with columns:
- ID: a clickable hyperlink, in the format
[{ID}](https://dev.azure.com/{organization}/{project}/_workitems/edit/{ID})({project}requires URL encoding) - Title
- Status
- Priority
Groups follow this order; groups with no items are skipped:
- Epic
- Feature
- Requirements category (User Story, Product Backlog Item, Requirement, Issue)
- Bug
- Task
- Test Case
- Other work item types