LoginSignup
0
1

[Vscode] Continue拡張機能でカスタムコマンドを使って作業効率アップ!

Last updated at Posted at 2024-05-01

はじめに

  • この記事では、VSCodeの拡張機能「Continue」のカスタムコマンドを紹介します。
  • カスタムコマンドでは、プロンプトに指示するショートカットを定義できます。
  • カスタムコマンドを利用すると、LLMへ短く効率的にプロンプトを指定することができます。
    image.png

/でショートカットを指定できる。
testはハイライトしたコードに対して、ユニットテストを書いてのプロンプトになっている。

Continueとは

-「Continue」は、ソフトウェア開発のためのオープンソースのオートパイロット(コーディング支援AIツール)です。

  • VS CodeやJetBrainsにChatGPTの力をもたらすIDE拡張機能であり、深くカスタマイズ可能に構築され、開発データから継続的に学習します。
  • 詳細は https://continue.dev で確認できます。

カスタムコマンド定義方法

  • Continueの画面の右下の歯車アイコンをクリックすると、設定ファイル(conofig.json)が開く。
    image.png

  • 次のcustomCommandsに追加したいコマンドを定義して保存する。
    image.png

  • 例えば、日本語翻訳を、英語に翻訳、絵文字を追加を定義してみる。

"customCommands": [
    {
      "name": "test",
      "prompt": "Write a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
      "description": "Write unit tests for highlighted code"
    },
    {
      "name": "toJ",
      "prompt": "Translate the selected sentence to Japanes. Give the sentence as chat output, don't edit any file.",
      "description": "日本語"
    },
    {
      "name": "toE",
      "prompt": "Translate the selected sentence to English. Give the sentence just as chat output, don't edit any file.",
      "description": "英語"
    },
    {
      "name": "addEmoji",
      "prompt": "Use emojis to decorate. Give the tests just as chat output, don't edit any file.",
      "description": "絵文字"
    }
  ],

image.png

デモ

  • 文章を英語に翻訳してみる。

image.png

  • ファイルを指定して文章に絵文字を追加してみる。

image.png

  • 前の文脈が影響してうまく指示がいかないケースもあった。
    image.png

  • その場合には、セッションをクリア(Ctrl +L)して命令しなすとうまくいくことがあった。

代替案

  • あらかじめプロンプトとしてショートカットを入力する方法のほうがスムーズに指示できた。
    image.png

image.png

  • その時によってショートカットを切り替えたくなるかもしれないから、あらかじめファイルで用意しておいて、作業する最初に入力するのもいいかも。

image.png

  • ChatGPTでも試してみた。こんな曖昧なプロンプトにもちゃんと答えてくれる・・・。
    image.png

image.png

参考

  • Contineのカスタムコマンドを試してみるところ、この方のXの投稿をみて感銘をうける。ChatGPTのメモリ機能は、備忘録くらいに考えてたんだが、こんな使い方あるんだなとびっくりする。思い浮かばなかったよ・・・。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1