Agent Skills by ALSEL
Anthropic ClaudeLLM・AI開発⭐ リポ 0品質スコア 50/100

github-workflow-automation

AIを活用してGitHubワークフローを自動化します。PRレビュー、Issue管理、CI/CDインテグレーション、Git操作などをサポートします。PRレビューの自動化やGitHub Actionsの作成、Issueのトリアージを行いたい場合に使用してください。

description の原文を見る

Automate GitHub workflows with AI assistance. Includes PR reviews, issue triage, CI/CD integration, and Git operations. Use when automating GitHub workflows, setting up PR review automation, creating GitHub Actions, or triaging issues.

SKILL.md 本文

🔧 GitHub ワークフロー自動化

Gemini CLI と最新の DevOps プラクティスにインスピレーションを受けた、AI を活用した GitHub ワークフロー自動化のパターン。

このスキルを使用する場合

このスキルは以下の場合に使用してください:

  • AI を用いた PR レビューの自動化
  • Issue トリアージ自動化の設定
  • GitHub Actions ワークフローの作成
  • CI/CD パイプラインへの AI 統合
  • Git 操作の自動化(rebase、cherry-pick)

1. 自動化された PR レビュー

1.1 PR レビュー アクション

# .github/workflows/ai-review.yml
name: AI Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed
        run: |
          files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
          echo "files<<EOF" >> $GITHUB_OUTPUT
          echo "$files" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Get diff
        id: diff
        run: |
          diff=$(git diff origin/${{ github.base_ref }}...HEAD)
          echo "diff<<EOF" >> $GITHUB_OUTPUT
          echo "$diff" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: AI Review
        uses: actions/github-script@v7
        with:
          script: |
            const { Anthropic } = require('@anthropic-ai/sdk');
            const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });

            const response = await client.messages.create({
              model: "claude-3-sonnet-20240229",
              max_tokens: 4096,
              messages: [{
                role: "user",
                content: `Review this PR diff and provide feedback:
                
                Changed files: ${{ steps.changed.outputs.files }}
                
                Diff:
                ${{ steps.diff.outputs.diff }}
                
                Provide:
                1. Summary of changes
                2. Potential issues or bugs
                3. Suggestions for improvement
                4. Security concerns if any
                
                Format as GitHub markdown.`
              }]
            });

            await github.rest.pulls.createReview({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: context.issue.number,
              body: response.content[0].text,
              event: 'COMMENT'
            });
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

1.2 レビュー コメント パターン

# AI レビュー構造

## 📋 概要

この PR が行っている処理についての簡潔な説明。

## ✅ 良い点

- よく構造化されたコード
- 適切なテストカバレッジ
- 明確な命名規則

## ⚠️ 潜在的な問題

1. **Line 42**: null ポインタ例外の可能性
   ```javascript
   // 現在
   user.profile.name;
   // 提案
   user?.profile?.name ?? "Unknown";
   ```

2. **Line 78**: エラーハンドリングの検討を
   ```javascript
   // try-catch または .catch() を追加
   ```

## 💡 提案

- バリデーションロジックを別の関数に抽出することを検討してください
- パブリックメソッドに JSDoc コメントを追加してください

## 🔒 セキュリティに関する注記

- 機密データの漏洩は検出されていません
- API キー処理は正しく見えます

1.3 フォーカスされたレビュー

# 特定のファイルタイプのみレビュー
- name: Filter code files
  run: |
    files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | \
            grep -E '\.(ts|tsx|js|jsx|py|go)$' || true)
    echo "code_files=$files" >> $GITHUB_OUTPUT

# コンテキスト付きレビュー
- name: AI Review with context
  run: |
    # 関連するコンテキストファイルを含める
    context=""
    for file in ${{ steps.changed.outputs.files }}; do
      if [[ -f "$file" ]]; then
        context+="=== $file ===\n$(cat $file)\n\n"
      fi
    done

    # 完全なファイルコンテキスト付きで AI に送信

2. Issue トリアージ自動化

2.1 自動ラベル付け

# .github/workflows/issue-triage.yml
name: Issue Triage

on:
  issues:
    types: [opened]

jobs:
  triage:
    runs-on: ubuntu-latest
    permissions:
      issues: write

    steps:
      - name: Analyze issue
        uses: actions/github-script@v7
        with:
          script: |
            const issue = context.payload.issue;

            // AI で分析を実行
            const analysis = await analyzeIssue(issue.title, issue.body);

            // ラベルを適用
            const labels = [];

            if (analysis.type === 'bug') {
              labels.push('bug');
              if (analysis.severity === 'high') labels.push('priority: high');
            } else if (analysis.type === 'feature') {
              labels.push('enhancement');
            } else if (analysis.type === 'question') {
              labels.push('question');
            }

            if (analysis.area) {
              labels.push(`area: ${analysis.area}`);
            }

            await github.rest.issues.addLabels({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: issue.number,
              labels: labels
            });

            // 初期応答を追加
            if (analysis.type === 'bug' && !analysis.hasReproSteps) {
              await github.rest.issues.createComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: issue.number,
                body: `このページでの報告をありがとうございます!

調査をお手伝いするため、以下をご提供いただけますようお願いします:
- 問題を再現するための手順
- 期待される動作
- 実際の動作
- 環境情報(OS、バージョンなど)

これにより、より早く問題を解決することができます。🙏`
              });
            }

2.2 Issue 分析プロンプト

const TRIAGE_PROMPT = `
GitHub の issue を分析して分類してください:

タイトル: {title}
本文: {body}

以下の情報を JSON で返してください:
{
  "type": "bug" | "feature" | "question" | "docs" | "other",
  "severity": "low" | "medium" | "high" | "critical",
  "area": "frontend" | "backend" | "api" | "docs" | "ci" | "other",
  "summary": "一行の要約",
  "hasReproSteps": boolean,
  "isFirstContribution": boolean,
  "suggestedLabels": ["label1", "label2"],
  "suggestedAssignees": ["username"]
}
`;

2.3 古い Issue の管理

# .github/workflows/stale.yml
name: Manage Stale Issues

on:
  schedule:
    - cron: "0 0 * * *" # 毎日

jobs:
  stale:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/stale@v9
        with:
          stale-issue-message: |
            この issue は最近のアクティビティがないため、自動的に古い状態とマークされました。
            さらなるアクティビティがない場合は、14 日後にクローズされます。

            この issue がまだ関連がある場合:
            - コメントで更新を追加してください
            - `stale` ラベルを削除してください

            ご協力ありがとうございました!🙏

          stale-pr-message: |
            この PR は自動的に古い状態とマークされました。
            更新するか、14 日後にクローズされます。

          days-before-stale: 60
          days-before-close: 14
          stale-issue-label: "stale"
          stale-pr-label: "stale"
          exempt-issue-labels: "pinned,security,in-progress"
          exempt-pr-labels: "pinned,security"

3. CI/CD 統合

3.1 スマートテスト選択

# .github/workflows/smart-tests.yml
name: Smart Test Selection

on:
  pull_request:

jobs:
  analyze:
    runs-on: ubuntu-latest
    outputs:
      test_suites: ${{ steps.analyze.outputs.suites }}

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Analyze changes
        id: analyze
        run: |
          # 変更されたファイルを取得
          changed=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)

          # 実行するテストスイートを決定
          suites="[]"

          if echo "$changed" | grep -q "^src/api/"; then
            suites=$(echo $suites | jq '. + ["api"]')
          fi

          if echo "$changed" | grep -q "^src/frontend/"; then
            suites=$(echo $suites | jq '. + ["frontend"]')
          fi

          if echo "$changed" | grep -q "^src/database/"; then
            suites=$(echo $suites | jq '. + ["database", "api"]')
          fi

          # 特に何も変わっていない場合はすべて実行
          if [ "$suites" = "[]" ]; then
            suites='["all"]'
          fi

          echo "suites=$suites" >> $GITHUB_OUTPUT

  test:
    needs: analyze
    runs-on: ubuntu-latest
    strategy:
      matrix:
        suite: ${{ fromJson(needs.analyze.outputs.test_suites) }}

    steps:
      - uses: actions/checkout@v4

      - name: Run tests
        run: |
          if [ "${{ matrix.suite }}" = "all" ]; then
            npm test
          else
            npm test -- --suite ${{ matrix.suite }}
          fi

3.2 AI 検証によるデプロイ

# .github/workflows/deploy.yml
name: Deploy with AI Validation

on:
  push:
    branches: [main]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Get deployment changes
        id: changes
        run: |
          # 最後のデプロイ以降のコミットを取得
          last_deploy=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
          if [ -n "$last_deploy" ]; then
            changes=$(git log --oneline $last_deploy..HEAD)
          else
            changes=$(git log --oneline -10)
          fi
          echo "changes<<EOF" >> $GITHUB_OUTPUT
          echo "$changes" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: AI Risk Assessment
        id: assess
        uses: actions/github-script@v7
        with:
          script: |
            // デプロイリスク分析
            const prompt = `
            これらの変更をデプロイリスクについて分析してください:

            ${process.env.CHANGES}

            JSON で以下を返してください:
            {
              "riskLevel": "low" | "medium" | "high",
              "concerns": ["concern1", "concern2"],
              "recommendations": ["rec1", "rec2"],
              "requiresManualApproval": boolean
            }
            `;

            // AI を呼び出して応答を解析
            const analysis = await callAI(prompt);

            if (analysis.riskLevel === 'high') {
              core.setFailed('High-risk deployment detected. Manual review required.');
            }

            return analysis;
        env:
          CHANGES: ${{ steps.changes.outputs.changes }}

  deploy:
    needs: validate
    runs-on: ubuntu-latest
    environment: production
    steps:
      - name: Deploy
        run: |
          echo "本番環境にデプロイ中..."
          # デプロイコマンドはここに

3.3 ロールバック自動化

# .github/workflows/rollback.yml
name: Automated Rollback

on:
  workflow_dispatch:
    inputs:
      reason:
        description: "ロールバック理由"
        required: true

jobs:
  rollback:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Find last stable version
        id: stable
        run: |
          # 最後に成功したデプロイを検索
          stable=$(git tag -l 'v*' --sort=-version:refname | head -1)
          echo "version=$stable" >> $GITHUB_OUTPUT

      - name: Rollback
        run: |
          git checkout ${{ steps.stable.outputs.version }}
          # 安定版をデプロイ
          npm run deploy

      - name: Notify team
        uses: slackapi/slack-github-action@v1
        with:
          payload: |
            {
              "text": "🔄 本番環境が ${{ steps.stable.outputs.version }} にロールバックされました",
              "blocks": [
                {
                  "type": "section",
                  "text": {
                    "type": "mrkdwn",
                    "text": "*ロールバック実行*\n• バージョン: `${{ steps.stable.outputs.version }}`\n• 理由: ${{ inputs.reason }}\n• トリガー実行者: ${{ github.actor }}"
                  }
                }
              ]
            }

4. Git 操作

4.1 自動 Rebase

# .github/workflows/auto-rebase.yml
name: Auto Rebase

on:
  issue_comment:
    types: [created]

jobs:
  rebase:
    if: github.event.issue.pull_request && contains(github.event.comment.body, '/rebase')
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Setup Git
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"

      - name: Rebase PR
        run: |
          # PR ブランチを取得
          gh pr checkout ${{ github.event.issue.number }}

          # main に rebase
          git fetch origin main
          git rebase origin/main

          # Force push
          git push --force-with-lease
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Comment result
        uses: actions/github-script@v7
        with:
          script: |
            github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: '✅ main への rebase に成功しました!'
            })

4.2 スマート Cherry-Pick

// コンフリクト処理を行う AI 支援 cherry-pick
async function smartCherryPick(commitHash: string, targetBranch: string) {
  // コミット情報を取得
  const commitInfo = await exec(`git show ${commitHash} --stat`);

  // 潜在的なコンフリクトを確認
  const targetDiff = await exec(
    `git diff ${targetBranch}...HEAD -- ${affectedFiles}`
  );

  // AI 分析
  const analysis = await ai.analyze(`
    このコミットを ${targetBranch} に cherry-pick したいのですが:
    
    ${commitInfo}
    
    ${targetBranch} 上の影響を受けるファイルの現在の状態:
    ${targetDiff}
    
    コンフリクトが発生しますか? 発生する場合は、解決戦略を提案してください。
  `);

  if (analysis.willConflict) {
    // 手動解決用のブランチを作成
    await exec(
      `git checkout -b cherry-pick-${commitHash.slice(0, 7)} ${targetBranch}`
    );
    const result = await exec(`git cherry-pick ${commitHash}`, {
      allowFail: true,
    });

    if (result.failed) {
      // AI 支援コンフリクト解決
      const conflicts = await getConflicts();
      for (const conflict of conflicts) {
        const resolution = await ai.resolveConflict(conflict);
        await applyResolution(conflict.file, resolution);
      }
    }
  } else {
    await exec(`git checkout ${targetBranch}`);
    await exec(`git cherry-pick ${commitHash}`);
  }
}

4.3 ブランチクリーンアップ

# .github/workflows/branch-cleanup.yml
name: Branch Cleanup

on:
  schedule:
    - cron: '0 0 * * 0'  # 週 1 回
  workflow_dispatch:

jobs:
  cleanup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Find stale branches
        id: stale
        run: |
          # 30 日以上更新されていないブランチ
          stale=$(git for-each-ref --sort=-committerdate refs/remotes/origin \
            --format='%(refname:short) %(committerdate:relative)' | \
            grep -E '[3-9][0-9]+ days|[0-9]+ months|[0-9]+ years' | \
            grep -v 'origin/main\|origin/develop' | \
            cut -d' ' -f1 | sed 's|origin/||')

          echo "branches<<EOF" >> $GITHUB_OUTPUT
          echo "$stale" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Create cleanup PR
        if: steps.stale.outputs.branches != ''
        uses: actions/github-script@v7
        with:
          script: |
            const branches = `${{ steps.stale.outputs.branches }}`.split('\n').filter(Boolean);

            const body = `## 🧹 古いブランチのクリーンアップ

以下のブランチは 30 日以上更新されていません:

${branches.map(b => `- \`${b}\``).join('\n')}

### アクション:
- [ ] 各ブランチをレビュー
- [ ] 不要になったブランチを削除
- 特定のブランチを保持する場合は \`/keep branch-name\` とコメント
`;

            await github.rest.issues.create({
              owner: context.repo.owner,
              repo: context.repo.repo,
              title: 'Stale Branch Cleanup',
              body: body,
              labels: ['housekeeping']
            });

5. オンデマンド支援

5.1 @mention ボット

# .github/workflows/mention-bot.yml
name: AI Mention Bot

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

jobs:
  respond:
    if: contains(github.event.comment.body, '@ai-helper')
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Extract question
        id: question
        run: |
          # @ai-helper の後のテキストを抽出
          question=$(echo "${{ github.event.comment.body }}" | sed 's/.*@ai-helper//')
          echo "question=$question" >> $GITHUB_OUTPUT

      - name: Get context
        id: context
        run: |
          if [ "${{ github.event.issue.pull_request }}" != "" ]; then
            # PR の場合 - diff を取得
            gh pr diff ${{ github.event.issue.number }} > context.txt
          else
            # issue の場合 - 説明を取得
            gh issue view ${{ github.event.issue.number }} --json body -q .body > context.txt
          fi
          echo "context=$(cat context.txt)" >> $GITHUB_OUTPUT
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: AI Response
        uses: actions/github-script@v7
        with:
          script: |
            const response = await ai.chat(`
              コンテキスト: ${process.env.CONTEXT}
              
              質問: ${process.env.QUESTION}
              
              有用で具体的な回答を提供してください。関連する場合はコード例を含めてください。
            `);

            await github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: response
            });
        env:
          CONTEXT: ${{ steps.context.outputs.context }}
          QUESTION: ${{ steps.question.outputs.question }}

5.2 コマンド パターン

## 利用可能なコマンド

| コマンド              | 説明                     |
| :------------------- | :----------------------- |
| `@ai-helper explain` | この PR のコードを説明    |
| `@ai-helper review`  | AI コードレビューを要求  |
| `@ai-helper fix`     | 問題の修正を提案         |
| `@ai-helper test`    | テストケースを生成       |
| `@ai-helper docs`    | ドキュメントを生成       |
| `/rebase`            | main に rebase          |
| `/update`            | main から PR ブランチを更新 |
| `/approve`           | ボットで承認とマーク     |
| `/label bug`         | 'bug' ラベルを追加       |
| `/assign @user`      | ユーザーにアサイン       |

6. リポジトリ設定

6.1 CODEOWNERS

# .github/CODEOWNERS

# グローバルオーナー
* @org/core-team

# フロントエンド
/src/frontend/ @org/frontend-team
*.tsx @org/frontend-team
*.css @org/frontend-team

# バックエンド
/src/api/ @org/backend-team
/src/database/ @org/backend-team

# インフラストラクチャ
/.github/ @org/devops-team
/terraform/ @org/devops-team
Dockerfile @org/devops-team

# ドキュメント
/docs/ @org/docs-team
*.md @org/docs-team

# セキュリティ関連
/src/auth/ @org/security-team
/src/crypto/ @org/security-team

6.2 ブランチ保護

# GitHub API 経由で設定
- name: Configure branch protection
  uses: actions/github-script@v7
  with:
    script: |
      await github.rest.repos.updateBranchProtection({
        owner: context.repo.owner,
        repo: context.repo.repo,
        branch: 'main',
        required_status_checks: {
          strict: true,
          contexts: ['test', 'lint', 'ai-review']
        },
        enforce_admins: true,
        required_pull_request_reviews: {
          required_approving_review_count: 1,
          require_code_owner_reviews: true,
          dismiss_stale_reviews: true
        },
        restrictions: null,
        required_linear_history: true,
        allow_force_pushes: false,
        allow_deletions: false
      });

ベストプラクティス

セキュリティ

  • API キーは GitHub Secrets に保存
  • ワークフローで最小限のパーミッションを使用
  • すべての入力を検証
  • ログに機密データを公開しない

パフォーマンス

  • 依存関係をキャッシュ
  • マトリックスビルドで並列テストを実行
  • パスフィルターで不要なジョブをスキップ
  • 重い作業には自己ホストランナーを使用

信頼性

  • ジョブにタイムアウトを追加
  • レート制限を適切に処理
  • リトライロジックを実装
  • ロールバック手順を用意

リソース

ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ

詳細情報

作者
davila7
リポジトリ
davila7/claude-code-templates
ライセンス
MIT
最終更新
不明

Source: https://github.com/davila7/claude-code-templates / ライセンス: MIT

関連スキル

OpenAILLM・AI開発⭐ リポ 6,054

agent-browser

AI エージェント向けのブラウザ自動化 CLI です。ウェブサイトとの対話が必要な場合に使用します。ページ遷移、フォーム入力、ボタンクリック、スクリーンショット取得、データ抽出、ウェブアプリのテスト、ブラウザ操作の自動化など、あらゆるブラウザタスクに対応できます。「ウェブサイトを開く」「フォームに記入する」「ボタンをクリックする」「スクリーンショットを取得する」「ページからデータを抽出する」「このウェブアプリをテストする」「サイトにログインする」「ブラウザ操作を自動化する」といった要求や、プログラマティックなウェブ操作が必要なタスクで起動します。

by JimmyLv
汎用LLM・AI開発⭐ リポ 1,982

anyskill

AnySkill — あなたのプライベート・スキルクラウド。GitHubを基盤としたリポジトリからエージェントスキルを管理、同期、動的にロードできます。自然言語でクラウドスキルを検索し、オンデマンドでプロンプトを自動ロード、カスタムスキルのアップロードと共有、スキルバンドルの一括インストールが可能です。OpenClaw、Antigravity、Claude Code、Cursorに対応しています。

by LeoYeAI
汎用LLM・AI開発⭐ リポ 1,982

engram

AIエージェント向けの永続的なメモリシステムです。バグ修正、意思決定、発見、設定変更の後はmem_saveを使用してください。ユーザーが「覚えている」「記憶している」と言及した場合、または以前のセッションと重複する作業を開始する際はmem_searchを使用します。セッション終了前にmem_session_summaryを使用して、コンテキストを保持してください。

by LeoYeAI
汎用LLM・AI開発⭐ リポ 21,584

skyvern

AI駆動のブラウザ自動化により、任意のウェブサイトを自動化できます。フォーム入力、データ抽出、ファイルダウンロード、ログイン、複数ステップのワークフロー実行など、ユーザーがウェブサイトと連携する必要があるときに使用します。Skyvernは、LLMとコンピュータビジョンを活用して、未知のサイトも自動操作可能です。Python SDK、TypeScript SDK、REST API、MCPサーバー、またはCLIを通じて統合できます。

by Skyvern-AI
汎用LLM・AI開発⭐ リポ 1,149

pinchbench

PinchBenchベンチマークを実行して、OpenClawエージェントの実世界タスクにおけるパフォーマンスを評価できます。モデルの機能テスト、モデル間の比較、ベンチマーク結果のリーダーボード提出、またはOpenClawのセットアップがカレンダー、メール、リサーチ、コーディング、複数ステップのワークフローにどの程度対応しているかを確認する際に使用します。

by pinchbench
汎用LLM・AI開発⭐ リポ 4,693

openui

OpenUIとOpenUI Langを使用してジェネレーティブUIアプリを構築できます。これらはLLM生成インターフェースのためのトークン効率的なオープン標準です。OpenUI、@openuidev、ジェネレーティブUI、LLMからのストリーミングUI、AI向けコンポーネントライブラリ、またはjson-render/A2UIの置き換えについて述べる際に使用します。スキャフォルディング、defineComponent、システムプロンプト、Renderer、およびOpenUI Lang出力のデバッグに対応しています。

by thesysdev
本サイトは GitHub 上で公開されているオープンソースの SKILL.md ファイルをクロール・インデックス化したものです。 各スキルの著作権は原作者に帰属します。掲載に問題がある場合は info@alsel.co.jp または /takedown フォームよりご連絡ください。
原作者: davila7 · davila7/claude-code-templates · ライセンス: MIT