Skip to content

Commit 8d3ec86

Browse files
committed
Github Copilot CLIに関する記事を公開状態に変更し、内容を整理
新しい画像を追加
1 parent 58f4de4 commit 8d3ec86

File tree

2 files changed

+330
-7
lines changed

2 files changed

+330
-7
lines changed

articles/456ddf87002351.md

Lines changed: 330 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,344 @@ title: "スクラッチで始めるGithub Copilot CLI"
33
emoji: "🛠️"
44
type: "tech" # tech: 技術記事 / idea: アイデア
55
topics: [github, githubcopilot, githubcopilotcli, mcp]
6-
published: false
6+
published: true
77
---
88

9-
## はじめに
10-
[otot_dev](https://zenn.dev/otot_dev)です。
11-
Github Copilot CLI をスクラッチで始め、いくつかの方法を備忘録としてまとめました。
9+
とうとう Github Copilot CLI が使用できるようになった(いつかできるようになると信じてた)ようで、普段 Copilot を個人的に使用している私は早速試してみました。
1210

13-
## 前提条件
11+
Github Copilot CLI の公式リポジトリ。
1412

13+
https://github.com/github/copilot-cli
1514

15+
注意点として、有料プランでないと使用できないようです。
16+
https://docs.github.com/ja/copilot/concepts/agents/about-copilot-cli
1617

17-
## Github Copilot CLIで消費するPremiumリクエスト
18+
> GitHub Copilot CLI は、GitHub Copilot Pro、GitHub Copilot Pro+、GitHub Copilot Business、GitHub Copilot Enterprise プランで使用できます。
19+
20+
## 導入手順
21+
22+
23+
```sh
24+
npm install -g @github/copilot
25+
```
26+
27+
```
28+
copilot
29+
```
30+
31+
以上、導入自体は簡単ですね。
32+
33+
```
34+
copilot
35+
┌── ──┐
36+
│ ▄██████▄ │
37+
Welcome to GitHub ▄█▀▀▀▀▀██▀▀▀▀▀█▄
38+
█████┐ █████┐ █████┐ ██┐██┐ █████┐ ██████┐ ▐█ ▐▌ █▌
39+
██┌───┘██┌──██┐██┌─██┐██│██│ ██┌──██┐└─██┌─┘ ▐█▄ ▄██▄ ▄█▌
40+
██│ ██│ ██│█████┌┘██│██│ ██│ ██│ ██│ ▄▄███████▀▀███████▄▄
41+
██│ ██│ ██│██┌──┘ ██│██│ ██│ ██│ ██│ ████ ▄ ▄ ████
42+
└█████┐└█████┌┘██│ ██│██████┐└█████┌┘ ██│ ████ █ █ ████
43+
└────┘ └────┘ └─┘ └─┘└─────┘ └────┘ └─┘ ▀███▄ ▄███▀
44+
│ CLI Version 0.0.334 ▀▀████████████▀▀ │
45+
└── ──┘
46+
Version 0.0.334 · Commit 26896a6
47+
48+
Copilot can write, test and debug code right from your terminal. Describe a
49+
task to get started or enter ? for help. Copilot uses AI, check for mistakes.
50+
```
51+
52+
## どういったコマンドがあるのか。使用サンプルも
53+
54+
```sh
55+
copilot help
56+
```
57+
58+
```sh
59+
Help Topics:
60+
config Configuration Settings
61+
environment Environment Variables
62+
logging Logging
63+
permissions Tool Permissions
64+
65+
Examples:
66+
# Start interactive mode
67+
$ copilot
68+
69+
# Start with a specific model
70+
$ copilot --model gpt-5
71+
72+
# Execute a prompt directly
73+
$ copilot -p "Fix the bug in main.js" --allow-all-tools
74+
75+
# Execute a prompt with a specific model
76+
$ copilot -p "Fix the bug in main.js" --model claude-sonnet-4 --allow-all-tools
77+
78+
# Resume the latest session
79+
$ copilot --resume
80+
81+
# Resume a specific session by ID
82+
$ copilot --resume session-id
83+
84+
# Resume the most recent session
85+
$ copilot --continue
86+
87+
# Resume with auto-approval
88+
$ copilot --allow-all-tools --resume
89+
90+
# Show the animated banner
91+
$ copilot --banner
92+
93+
# Set logging to ./logs
94+
$ copilot --log-dir ./logs
95+
96+
# Enable debug level logging
97+
$ copilot --log-level debug
98+
99+
# Allow access to additional directory
100+
$ copilot --add-dir /home/user/projects
101+
102+
# Allow multiple directories
103+
$ copilot --add-dir ~/workspace --add-dir /tmp
104+
105+
# Allow all git commands except git push
106+
$ copilot --allow-tool 'shell(git:*)' --deny-tool 'shell(git push)'
107+
108+
# Allow all file editing
109+
$ copilot --allow-tool 'write'
110+
111+
# Allow all but one specific tool from MCP server with name "MyMCP"
112+
$ copilot --deny-tool 'MyMCP(denied_tool)' --allow-tool 'MyMCP'
113+
114+
Interactive Mode Commands:
115+
/add-dir <directory> Add a directory to the allowed list for file access
116+
/clear Clear the conversation history
117+
/cwd [directory] Change working directory or show current directory
118+
/exit Exit the CLI
119+
/feedback Provide feedback about the CLI
120+
/help Show help for interactive commands
121+
/list-dirs Display all allowed directories for file access
122+
/login Log in to Copilot
123+
/logout Log out of Copilot
124+
/mcp [show|add|edit|delete|disable|enable] [server-name] Manage MCP server configuration
125+
/model [model] Select AI model to use
126+
/reset-allowed-tools Reset the list of allowed tools
127+
/session Show information about the current CLI session
128+
/theme [show|set|list] [auto|dark|light] View or configure terminal theme
129+
/usage Display session usage metrics and statistics
130+
/user [show|list|switch] Manage GitHub user list
131+
```
132+
133+
## Copilotのグローバル設定ディレクトリ
134+
135+
- copilot-instructions.md
136+
- mcp-config.json
137+
は自分で空のファイルを作成しました。
138+
139+
```
140+
.
141+
├── command-history-state.json // ここにコマンドの履歴が保存される
142+
├── config.json // ここに設定が保存される
143+
├── copilot-instructions.md // ここに指示を書ける
144+
├── history-session-state // ここにセッションの状態が保存される
145+
├── logs // ログがここに保存される
146+
└── mcp-config.json // ここにMCPサーバーの設定が保存される
147+
```
148+
149+
## MCPサーバーの設定
150+
151+
ハンズオンなので CLI 上で MCP サーバーの設定をしてみます。
152+
153+
```sh
154+
/mcp add
155+
```
156+
157+
```sh
158+
Add New MCP Server
159+
160+
Server Name:
161+
Unique name for this MCP server
162+
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
163+
│ │
164+
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
165+
166+
Server Type:
167+
Press 1 for Local, 2 for HTTP, 3 for SSE
168+
[1] Local [2] HTTP [3] SSE
169+
170+
Command:
171+
Command to start the server (e.g., "python")
172+
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
173+
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
174+
175+
Arguments:
176+
Command arguments, comma-separated (e.g., -m, my_server)
177+
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
178+
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
179+
180+
Environment Variables:
181+
Path is automatically inherited. All other environment variables must be configured
182+
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
183+
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
184+
185+
Tools:
186+
Tools to include: "*" for all, or comma-separated list (no quotes needed)
187+
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
188+
*
189+
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
190+
```
191+
192+
### fetch
193+
194+
- Server Name: fetch
195+
- Server Type: 1 (LOCAL)
196+
- Command: uvx
197+
- Arguments: mcp-server-fetch
198+
- Environment Variables: (空欄)
199+
- Tools: *
200+
201+
```json
202+
// mcp-config.json
203+
"fetch": {
204+
"tools": [
205+
"*"
206+
],
207+
"type": "local",
208+
"command": "uvx",
209+
"args": [
210+
"mcp-server-fetch"
211+
]
212+
},
213+
```
214+
215+
これで登録しました。
216+
軽く動作確認してみます。
217+
218+
```
219+
> fetch を使ってhttps://zenn.dev/otot_devを参照して、基本的なサイト情報を教えてください。
220+
```
221+
222+
```
223+
これは技術記事共有プラットフォームZennにおけるotot_devさんのプロフィールページです。ユーザーは自身を「Digital
224+
Craftsman(ソフトウェアエンジニア / デザインエンジニア /
225+
デザイナー)」と紹介しており、コーヒーが大好きで、苔を眺めるのが好きという趣味も記載されています。
226+
227+
ポートフォリオサイトとしてotot.dev (https://otot.dev/)へのリンクも掲載されていることが確認できます。
228+
229+
このプロフィールから、技術的なスキルだけでなくデザイン面にも強みを持つエンジニアであることが伺えます。ZennではおそらくWeb開発、デザイン、エンジニアリング
230+
に関する技術記事を投稿されているものと思われます。
231+
```
232+
233+
ちゃんと情報を参照してくれてそうです。
234+
235+
※UVX がインストールされていない方は以下のコマンドでインストールできます(Mac の場合)
236+
```
237+
brew install uvx
238+
```
239+
240+
### serena
241+
242+
<!-- textlint-disable -->
243+
244+
- Server Name: serena
245+
- Server Type: 1 (LOCAL)
246+
- Command: uvx
247+
- Arguments: --from,git+https://github.com/oraios/serena,serena,start-mcp-server
248+
- Environment Variables: (空欄)
249+
- Tools: *
250+
251+
<!-- textlint-enable -->
252+
253+
```json
254+
// mcp-config.json
255+
"serena": {
256+
"tools": [
257+
"*"
258+
],
259+
"type": "local",
260+
"command": "uvx",
261+
"args": [
262+
"--from",
263+
"git+https://github.com/oraios/serena",
264+
"serena",
265+
"start-mcp-server"
266+
],
267+
"env": {}
268+
},
269+
```
270+
271+
![](/images/456ddf87002351/image.png)
272+
273+
こんな画面が表示できればちゃんと起動できてる。
274+
275+
### context7
276+
277+
- Server Name: context7
278+
- Server Type: 1 (LOCAL)
279+
- Command: npx
280+
- Arguments: -y,@upstash/context7-mcp,--api-key,YOUR_API_KEY
281+
- Environment Variables: (空欄)
282+
- Tools: *
283+
284+
```json
285+
// mcp-config.json
286+
"context7": {
287+
"type": "local",
288+
"command": "npx",
289+
"tools": [
290+
"*"
291+
],
292+
"args": [
293+
"-y",
294+
"@upstash/context7-mcp",
295+
"--api-key",
296+
"YOUR_API_KEY"
297+
]
298+
}
299+
```
300+
301+
```sh
302+
> context7を使ってfetch APIのファイルをアップロードする方法を教えてください。
303+
```
304+
305+
```
306+
● Fetch APIを使用したファイルアップロードの方法について、Context7を使って詳しい情報を取得します。
307+
308+
✓ Resolve Context7 Library ID
309+
↪ Available Libraries (top matches):
310+
311+
● Fetch APIは標準のWeb APIなので、MDNのドキュメントを参照しつつ、実践的なファイルアップロードの例を提供します。
312+
313+
✓ Get Library Docs
314+
〜〜省略〜〜
315+
```
316+
317+
### その他のMCPサーバーリスト
318+
319+
https://github.com/mcp
320+
321+
322+
## Github Copilot CLIで消費するPremiumリクエストについても心に留めておく
18323

19324
https://docs.github.com/ja/copilot/concepts/billing/copilot-requests#what-are-premium-requests
20325

326+
> Copilot CLI へのプロンプトごとに、1 つの Premium リクエストが使われます。
327+
21328
Copilot CLI は 2025 年 10 月現在プロンプトごとに 1 つの Premium リクエストを消費するようです。
22329

23-
> Copilot CLI へのプロンプトごとに、1 つの Premium リクエストが使われます。
330+
ちなみにプラン毎に Premium リクエストの上限が異なります。下に公式ドキュメントを貼っておきます。
331+
332+
https://docs.github.com/ja/copilot/get-started/plans#copilot-%E3%83%97%E3%83%A9%E3%83%B3%E3%81%AE%E6%AF%94%E8%BC%83
333+
334+
## 所感
335+
336+
個人では Github Copilot を中心に使っていたので、Github Copilot CLI が出たのはとても嬉しいかったです(それもあって早速試したというのもある)。
337+
Github MCP Server が標準で接続されているというのも他にはない強みにも感じました。ほとんどのリポジトリは Github にあるでしょうし、それらの情報は非常にアクセスしやすいかなと。
338+
339+
340+
## 参考にさせていただいた記事
341+
342+
https://zenn.dev/thirdlf/articles/36-zenn-github-copilot-cli
343+
344+
https://zenn.dev/hiroto_fp/articles/3ee3c508f982e6
345+
346+
https://zenn.dev/hokuto_tech/articles/97fa88f7805a23#%E3%81%8A%E3%81%99%E3%81%99%E3%82%81%E3%83%84%E3%83%BC%E3%83%AB%3A-superwhisper

images/456ddf87002351/image.png

177 KB
Loading

0 commit comments

Comments
 (0)