home / skills / ntaksh42 / agents / azure-devops-cli

azure-devops-cli skill

/dotfiles/claude/skills/azure-devops-cli

This skill helps you manage Azure DevOps tasks, pipelines, repos, and artifacts efficiently using the az devops CLI across projects.

npx playbooks add skill ntaksh42/agents --skill azure-devops-cli

Review the files below or copy the command above to add this skill to your agents.

Files (7)
SKILL.md
4.1 KB
---
name: azure-devops-cli
description: |
  Azure DevOps CLI (az devops) を使用した包括的な操作スキル。
  リポジトリ、パイプライン、ボード(ワークアイテム)、アーティファクト、Wiki、サービス接続の管理を行う。
  使用場面: (1) ワークアイテム(タスク、バグ、ユーザーストーリー)の作成・更新・検索、
  (2) パイプラインの実行・監視・管理、(3) プルリクエストの作成・レビュー・マージ、
  (4) リポジトリのブランチ・ポリシー管理、(5) アーティファクトフィードの管理、
  (6) Wikiページの作成・更新、(7) Azure DevOpsプロジェクトの設定変更
---

# Azure DevOps CLI

## Prerequisites

```bash
# Azure CLI と DevOps 拡張機能のインストール確認
az --version
az extension show --name azure-devops

# 拡張機能がない場合はインストール
az extension add --name azure-devops

# ログインと組織設定
az login
az devops configure --defaults organization=https://dev.azure.com/{org} project={project}
```

## Quick Reference

| 操作 | コマンド |
|------|----------|
| ワークアイテム一覧 | `az boards work-item query --wiql "SELECT [Id] FROM WorkItems WHERE [State] = 'Active'"` |
| パイプライン実行 | `az pipelines run --name {pipeline-name}` |
| PR作成 | `az repos pr create --source-branch {branch} --target-branch main` |
| ビルド状態確認 | `az pipelines build show --build-id {id}` |

## Command Groups

### Repositories (az repos)
Git リポジトリ、ブランチ、プルリクエストの管理。
詳細: [references/repos.md](references/repos.md)

### Pipelines (az pipelines)
ビルド・リリースパイプラインの実行と管理。
詳細: [references/pipelines.md](references/pipelines.md)

### Boards (az boards)
ワークアイテム、スプリント、クエリの管理。
詳細: [references/boards.md](references/boards.md)

### Artifacts (az artifacts)
パッケージフィードとアーティファクトの管理。
詳細: [references/artifacts.md](references/artifacts.md)

### Wiki (az devops wiki)
プロジェクトWikiの管理。
詳細: [references/wiki.md](references/wiki.md)

### Service Connections
デプロイメント用のサービス接続設定。
詳細: [references/service-connections.md](references/service-connections.md)

## Common Workflows

### ワークアイテムの日常管理
```bash
# アクティブなタスクを確認
az boards work-item query --wiql "SELECT [Id],[Title],[State] FROM WorkItems WHERE [Assigned To] = @Me AND [State] <> 'Closed'"

# タスクの状態を更新
az boards work-item update --id {id} --state "In Progress"
```

### PR ワークフロー
```bash
# PR作成
az repos pr create --source-branch feature/xxx --target-branch main --title "Add feature" --auto-complete

# PRにレビュアーを追加
az repos pr reviewer add --id {pr-id} --reviewers [email protected]

# PRをマージ
az repos pr update --id {pr-id} --status completed
```

### パイプライン操作
```bash
# パイプラインを実行
az pipelines run --name "Build-Pipeline" --branch main

# 実行中のビルドを確認
az pipelines build list --status inProgress

# ビルドログを取得
az pipelines build logs --build-id {id}
```

## Tips

- `--output table` で見やすい表形式出力
- `--output json | jq` で JSON 加工
- `--query` で JMESPath フィルタリング
- 環境変数 `AZURE_DEVOPS_EXT_PAT` で PAT 認証

## Windows環境での実行(重要)

**Claude Codeから実行する場合、必ず `cmd.exe /c` 経由で実行すること。**

Bash シェルから直接 `az` コマンドを実行すると、出力が正しくキャプチャされない問題があります。

```bash
# 正しい実行方法
cmd.exe /c "az devops project list --output table"
cmd.exe /c "az boards work-item show --id 123"
cmd.exe /c "az pipelines run --name Build-Pipeline"

# 誤った実行方法(出力が取得できない)
az devops project list --output table
```

すべての `az` コマンドは以下の形式で実行してください:
```bash
cmd.exe /c "az <command> <arguments>"
```

Overview

This skill provides comprehensive, command-line control of Azure DevOps using the Azure DevOps CLI (az devops). It covers repositories, pipelines, boards (work items), artifacts, wiki, and service connections to automate and manage common DevOps tasks. The skill is built around practical workflows for creating and updating work items, running and monitoring pipelines, managing pull requests and branch policies, and maintaining artifact feeds and wiki content.

How this skill works

The skill issues az devops and related az CLI commands to perform operations against an Azure DevOps organization and project. It authenticates using az login (or a PAT via AZURE_DEVOPS_EXT_PAT) and sends commands such as az boards, az repos, az pipelines, az artifacts, and az devops wiki. For Windows-based automation, it wraps CLI calls with cmd.exe /c to ensure reliable output capture.

When to use it

  • Create, update, search, or bulk-manage work items (tasks, bugs, user stories).
  • Trigger, monitor, and troubleshoot build and release pipelines from scripts or automation.
  • Create, review, and merge pull requests and manage branch policies for repositories.
  • Manage package feeds and artifact lifecycle for CI/CD consumption.
  • Create or update project wiki pages and keep documentation versioned with automation.
  • Configure or update service connections and project-level settings as part of setup or onboarding.

Best practices

  • Configure az devops defaults (organization and project) to avoid repeating arguments.
  • Use AZURE_DEVOPS_EXT_PAT for non-interactive automation and store secrets securely.
  • Prefer --output table for human-readable checks and --output json with --query or jq for automation.
  • Wrap commands with cmd.exe /c on Windows automation hosts to reliably capture output.
  • Use WIQL queries and saved queries for performant, repeatable work-item selections.

Example use cases

  • Daily standup script that queries active work items assigned to the current user and updates states.
  • CI script that triggers a pipeline, polls build status, and fetches logs when a run fails.
  • Automated PR workflow that creates a PR, assigns reviewers, sets auto-complete, and merges on approval.
  • Onboarding automation that creates service connections, sets branch policies, and seeds a project wiki.
  • Release process that publishes packages to an artifacts feed and bumps feed permissions via CLI.

FAQ

How do I authenticate non-interactively?

Use a Personal Access Token and set it in the AZURE_DEVOPS_EXT_PAT environment variable, or run az login with a service principal for scripted scenarios.

Why must I use cmd.exe /c on Windows?

On some Windows hosts the az CLI output is not reliably captured by automation tools unless executed through cmd.exe /c, so wrapping commands ensures consistent results.