WIQL Guide
WIQL (Work Item Query Language) is SQL-like query language used by Azure DevOps to search and filter work items. adtk supports WIQL through both the CLI and MCP.
Basic Syntax
Section titled “Basic Syntax”SELECT [Field1], [Field2]FROM WorkItemsWHERE [Condition]ORDER BY [Field] ASC|DESCRunning WIQL Queries
Section titled “Running WIQL Queries”adtk search wiql "SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.State] = 'Active'"Tool: manage_searchInput: { "action": "wiql", "query": "SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.State] = 'Active'", "project_key": "MyProject"}Common Fields
Section titled “Common Fields”| WIQL Field | Flattened Name | Description |
|---|---|---|
[System.Id] | id | Work item ID |
[System.Title] | title | Title |
[System.State] | state | State (New, Active, Closed, etc.) |
[System.WorkItemType] | work_item_type | Type (Bug, Task, User Story, etc.) |
[System.AssignedTo] | assigned_to | Assigned user |
[System.CreatedDate] | created_date | Creation timestamp |
[System.ChangedDate] | changed_date | Last modified timestamp |
[System.CreatedBy] | created_by | Creator |
[System.AreaPath] | area_path | Area path |
[System.IterationPath] | iteration_path | Iteration/sprint path |
[System.Tags] | tags | Tags |
[Microsoft.VSTS.Common.Priority] | priority | Priority (1-4) |
[Microsoft.VSTS.Scheduling.StoryPoints] | story_points | Story points estimate |
[Microsoft.VSTS.Common.StateChangeDate] | state_change_date | When state last changed |
Query Examples
Section titled “Query Examples”Active items assigned to me
Section titled “Active items assigned to me”SELECT [System.Id], [System.Title], [System.State]FROM WorkItemsWHERE [System.State] = 'Active' AND [System.AssignedTo] = @MeORDER BY [System.ChangedDate] DESCAll bugs by priority
Section titled “All bugs by priority”SELECT [System.Id], [System.Title], [Microsoft.VSTS.Common.Priority]FROM WorkItemsWHERE [System.WorkItemType] = 'Bug' AND [System.State] <> 'Closed'ORDER BY [Microsoft.VSTS.Common.Priority] ASCItems changed in the last 7 days
Section titled “Items changed in the last 7 days”SELECT [System.Id], [System.Title], [System.ChangedDate]FROM WorkItemsWHERE [System.ChangedDate] >= @Today - 7ORDER BY [System.ChangedDate] DESCItems in the current iteration
Section titled “Items in the current iteration”SELECT [System.Id], [System.Title], [System.State]FROM WorkItemsWHERE [System.IterationPath] = @CurrentIteration AND [System.WorkItemType] <> 'Task'ORDER BY [Microsoft.VSTS.Common.Priority] ASCUnassigned high-priority items
Section titled “Unassigned high-priority items”SELECT [System.Id], [System.Title], [System.WorkItemType]FROM WorkItemsWHERE [System.AssignedTo] = '' AND [Microsoft.VSTS.Common.Priority] <= 2 AND [System.State] = 'New'Items by tag
Section titled “Items by tag”SELECT [System.Id], [System.Title]FROM WorkItemsWHERE [System.Tags] CONTAINS 'frontend' AND [System.State] <> 'Closed'Parent-child hierarchy (tree query)
Section titled “Parent-child hierarchy (tree query)”SELECT [System.Id], [System.Title], [System.WorkItemType]FROM WorkItemLinksWHERE [Source].[System.WorkItemType] = 'User Story' AND [Target].[System.WorkItemType] = 'Task' AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'MODE (Recursive)Items created by a specific user
Section titled “Items created by a specific user”SELECT [System.Id], [System.Title], [System.CreatedDate]FROM WorkItemsWHERE [System.CreatedBy] = 'Jane Doe' AND [System.CreatedDate] >= @Today - 30ORDER BY [System.CreatedDate] DESCItems in a specific area path
Section titled “Items in a specific area path”SELECT [System.Id], [System.Title], [System.State]FROM WorkItemsWHERE [System.AreaPath] UNDER 'MyProject\Backend'ORDER BY [System.Id] ASCOperators
Section titled “Operators”| Operator | Description | Example |
|---|---|---|
= | Equals | [System.State] = 'Active' |
<> | Not equals | [System.State] <> 'Closed' |
>, <, >=, <= | Comparison | [Microsoft.VSTS.Common.Priority] <= 2 |
CONTAINS | Contains substring | [System.Tags] CONTAINS 'api' |
NOT CONTAINS | Does not contain | [System.Title] NOT CONTAINS 'test' |
IN | In a set | [System.State] IN ('Active', 'New') |
NOT IN | Not in a set | [System.WorkItemType] NOT IN ('Task', 'Test Case') |
UNDER | Under a path (hierarchical) | [System.AreaPath] UNDER 'Project\Team' |
='' | Is empty | [System.AssignedTo] = '' |
<>'' | Is not empty | [System.AssignedTo] <> '' |
Macros
Section titled “Macros”| Macro | Description |
|---|---|
@Me | Current authenticated user |
@Today | Today’s date (can do arithmetic: @Today - 7) |
@CurrentIteration | The current sprint/iteration |
@Project | Current project context |
How adtk Processes WIQL
Section titled “How adtk Processes WIQL”adtk uses the WIQL 2-step pattern:
- Execute the query — POST the WIQL to the ADO API, which returns a list of work item IDs
- Batch fetch — GET the full work items by ID in batches of up to 200
This is more efficient than fetching full work items inline, especially for large result sets.
# Limit results with the --top flagadtk search wiql "SELECT [System.Id] FROM WorkItems WHERE [System.State] = 'Active'" --top 10