Claude Code Azure DevOps Integration
Integrating Claude Code with Azure DevOps connects your AI assistant to pipelines, repositories, boards, and artifacts. This guide shows how to set up the connection so Claude Code can create work items, trigger builds, review pull requests, and manage your Azure DevOps workflow from the terminal.
The Problem
Azure DevOps teams split their attention between the web portal for boards and pipelines, the IDE for code, and the terminal for CLI operations. Claude Code has no native awareness of your Azure DevOps project. Without integration, you manually describe pipeline failures, copy build logs, and switch contexts constantly between tools.
Quick Solution
- Install the Azure DevOps CLI extension:
az extension add --name azure-devops
az devops configure --defaults organization=https://dev.azure.com/your-org project=your-project
-
Create a Personal Access Token (PAT) in Azure DevOps with the scopes you need (Code, Build, Work Items).
-
Set the token for CLI authentication:
export AZURE_DEVOPS_EXT_PAT="your-pat-token"
- Add Azure DevOps context to your
.claude/settings.json:
{
"mcpServers": {
"azure-devops": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-server-azure-devops"],
"env": {
"AZURE_DEVOPS_ORG": "https://dev.azure.com/your-org",
"AZURE_DEVOPS_PAT": "your-pat-token",
"AZURE_DEVOPS_PROJECT": "your-project"
}
}
}
}
- Restart Claude Code and test:
Show me the last 5 failed pipeline runs
How It Works
Claude Code interacts with Azure DevOps through the REST API via an MCP server or by executing az devops CLI commands. The MCP server wraps the Azure DevOps REST API, exposing operations like creating work items, querying build status, listing pull requests, and reading pipeline logs.
When you ask Claude Code about a failed build, it calls the MCP tool to fetch the pipeline run details, reads the logs, and identifies the failure point. For work item management, Claude Code can create, update, and query items using WIQL (Work Item Query Language) through the API.
The PAT token controls access scope. Claude Code can only perform operations that the token allows. This gives you fine-grained control over what the AI assistant can do in your Azure DevOps environment.
Common Issues
PAT token scope too narrow: If Claude Code cannot list pipelines or create work items, verify your PAT has the required scopes. Common scopes needed: vso.build_execute, vso.code_write, vso.work_write.
Organization URL format: The organization URL must be https://dev.azure.com/your-org (new format), not https://your-org.visualstudio.com (legacy format). Using the wrong format causes authentication failures.
Pipeline YAML not found: When Claude Code tries to read pipeline definitions, ensure the azure-pipelines.yml file is at the repository root or the path is specified in your CLAUDE.md context.
Example CLAUDE.md Section
# Azure DevOps Integration
## Project Details
- Organization: https://dev.azure.com/our-company
- Project: mobile-app
- Default branch: main
- Pipeline: mobile-app-ci (ID: 42)
## Workflow Rules
- Work items follow format: Feature > User Story > Task
- PRs require 2 approvers minimum
- Pipeline must pass before merge
- Use area path: mobile-app\backend for API work
- Sprint cadence: 2 weeks, starting Monday
## Common Commands
- Check build status: `az pipelines runs list --top 5`
- Create bug: `az boards work-item create --type Bug`
- List active PRs: `az repos pr list --status active`
Best Practices
- Use least-privilege PAT tokens. Create separate tokens for read-only querying and write operations. Use the read-only token by default.
- Store PAT in environment variables, not in config files. Never commit tokens to
.claude/settings.jsonthat gets checked into source control. Use environment variable references instead. - Document sprint context in CLAUDE.md. Include current sprint name, iteration path, and active work item IDs so Claude Code can reference them accurately.
- Automate pipeline monitoring with hooks. Set up Claude Code hooks to run
az pipelines runs showafter git push operations to monitor build status. - Keep pipeline YAML in CLAUDE.md context. Reference your
azure-pipelines.ymlpath so Claude Code can read and suggest improvements to your CI/CD configuration.
Related Reading
- Claude Code MCP Server Setup
- Best Way to Integrate Claude Code into Team Workflow
- Claude Code Docker Compose Development Workflow
Built by theluckystrike. More at zovo.one