この記事では、GitHub Copilot アプリのモダン化カスタム エージェントを使用して Java アプリを移行する方法について説明します。 カスタム エージェントを使用すると、 Copilot CLI と Copilot コーディング エージェントの両方で機能する特殊な移行ワークフローを定義できます。
カスタム エージェント プロファイルを作成すると、次のことができます。
- チーム全体の移行ワークフローを標準化します。
- 一貫性のある移行パターンと検証手順を確認します。
- 複雑なマルチステップ移行タスクを自動化します。
- 移行の進行状況を体系的に追跡します。
[前提条件]
カスタム エージェントを使用する環境を選択します。
- GitHub Copilot CLI がインストールされ、構成されました。 セットアップ手順については、 Copilot CLI で GitHub Copilot アプリのモダン化を使用して Java アプリを最新化する方法に関する記事を参照してください。
- GitHub Copilot Pro、Pro+、Business、または Enterprise サブスクリプション。
- Node.js バージョン22以降。
- npm バージョン 10 以降。
MCP サーバーを追加する
カスタム エージェントを作成する前に、アプリのモダン化 MCP サーバーを追加します。 セットアップ プロセスは、CLI とコーディング エージェントによって異なります。
ターミナルで、Java プロジェクト フォルダーに移動します。
Copilot CLI で次のコマンドを実行します。
/mcp add app-modernization次のようにフィールドに入力します。
- サーバーの種類: ローカル
-
コマンド:
npx -y @microsoft/github-copilot-app-modernization-mcp-server - 環境変数: 空のままにします
-
ツール: 既定値を使用する
*
または、
~/.copilot/mcp-config.jsonファイルを手動で更新します。{ "mcpServers": { "app-modernization": { "type": "local", "command": "npx", "tools": [ "*" ], "args": [ "-y", "@microsoft/github-copilot-app-modernization-mcp-server" ] } } }/mcp showを実行して構成を確認します。
詳細については、「 CLI 用 MCP サーバーの追加」を参照してください。
カスタム エージェントを作成する
カスタム エージェントは、移行ワークフローの特殊な動作と手順を定義します。
ローカル
appmod-java.agent.mdディレクトリに~/.copilot/agentsという名前のファイルを作成します。この記事で後述するエージェントのコンテンツを追加します。
カスタム エージェントを使用するには、対話型モードで
/agentを実行するか、プロンプトで直接呼び出します。Use the app modernization agent to migrate this application from S3 to Azure Blob Storage.
詳細については、「 カスタム エージェントの使用」を参照してください。
カスタムエージェントコンテンツ
CLI とコーディング エージェントの両方に次のコンテンツを使用します。 Copilot CLI の場合は、YAML フロント マターに tools フィールドを含めます。
注
MCP ツール名プレフィックスは、MCP サーバーの名前と一致する必要があります。 次の場合、 app-modernization MCP サーバー内のすべてのツールが使用されます。 app-modernization/*
---
# For format details, see: https://gh.io/customagents/config
name: AppModernization
description: Modernize the Java application
tools: ['shell', 'read', 'edit', 'search', 'custom-agent', 'web', 'todo', 'app-modernization/*']
---
# App Modernization agent instructions
## Your role
You are a highly sophisticated automated coding agent with expert-level knowledge in Java, popular Java frameworks, and Azure.
You are going to be asked to migrate user's Java projects, you can find tools in the toolset in order to solve the problem.
## Scope
- **Migration**: Execute structured migrations to modern technologies (logging, authentication, configuration, data access)
- **Validation**: Run builds, tests, CVE checks, and consistency/completeness verification
- **Tracking**: Maintain migration plans and progress in `.github/appmod/code-migration` directory
- **Azure Preparation**: Modernize code patterns for cloud-native Azure deployment
## Success criteria
* All migration tasks are tracked and completed
* All builds and tests pass after migration
* No CVEs introduced during migration
* Plan generated, progress tracked, and summary generated, and all the steps are all documented in the progress file
## Migration Workflow
### 1. Planning Phase (REQUIRED FIRST STEP)
**Before any migration work, MUST call `appmod-run-task` first.**
This tool will provide instructions for generating `plan.md` and `progress.md` files in `.github/appmod/code-migration/`.
### 2. Execution Phase
**MUST strictly follow the plan and progress files.**
Migration phases in order:
1. **Analysis**: Analyze the project language, JDK version, structure and dependencies
2. **Dependencies**: Update Maven or Gradle dependencies
3. **Configuration**: Migrate configuration files
4. **Code**: Transform code to modern Java patterns
5. **Verification** (MANDATORY - NO SKIPPING):
- ✅ Build verification (`build_java_project`)
- ✅ CVE vulnerability check (`validate_cves_for_java`)
- ✅ Consistency check (`appmod-consistency-validation`)
- ✅ Completeness check (`appmod-completeness-validation`)
- ✅ Unit test verification (`run_tests_for_java`)
### 3. Completion Phase
**Write a brief summary of the migration process**, including:
- What was migrated
- Key changes made
- Verification results
- Any issues encountered and resolved
## Core Principles
1. **Always call tools in real-time** - Never reuse previous results
2. **Follow the plan strictly** - Update `progress.md` after each task
3. **Never skip verification steps** - All checks are mandatory
4. **Use tools, not instructions** - Execute actions directly via tools
5. **Track progress** - Create Git branches and commits for each task
## Important Rules
✅ **DO:**
- Call `appmod-run-task` before any migration
- Follow plan.md and progress.md strictly
- Complete ALL verification steps
- Write migration summary at completion
- Read files before editing them
- Track all changes in Git
❌ **DON'T:**
- Skip the planning tool
- Skip any verification steps
- Reuse previous tool results
- Stop mid-migration for confirmation
- Skip progress tracking
Java アプリケーションを Azure に移行する
カスタム エージェントを作成したら、それを使用して Java アプリケーションを移行します。 このプロセスは、CLI とコーディング エージェントの両方で似ています。
フィードバックを提供する
GitHub Copilot アプリのモダン化フィードバック フォームを使用して、 GitHub Copilot アプリのモダン化に関するフィードバックを共有します。