1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

claude-code-ide.el with ghostel

1
Last updated at Posted at 2026-07-30

claude-code-ide.el with ghostel

はじめに

本記事では実際に手元の init.el に導入した設定を例に、導入手順とハマったポイントを紹介します。
ghostel を使うところだけでいいのですけど、それ以外は claude code が追加しちゃったので…筆者も使い始めたばかりで何も分からんのでまぁいいやとそのままにしてます。

前提条件

  • Ubuntu Linux 24.04LTS
  • Emacs 28.1以上
  • Claude Code CLIがインストール済みでPATHが通っていること(公式ドキュメント参照)
  • Claude Pro以上のサブスクリプション(Claude Code自体の利用条件)

インストール

;; ターミナルバックエンド(後述の理由でghostelを使用)
(leaf ghostel
  :ensure t)

;; Claude Code IDE
(leaf claude-code-ide
  :vc (:url "https://github.com/manzaltu/claude-code-ide.el" :rev :newest)
  :init
  (setq claude-code-ide-terminal-backend 'ghostel)
  (setq claude-code-ide-use-side-window nil)
  :bind ("C-c C-'" . claude-code-ide-menu)
  :config
  (claude-code-ide-emacs-tools-setup))

claude-code-ide-emacs-tools-setup を呼んでおくと、xref-find-references や project-info などのMCPツールがClaude Code側から使えるようになります。これが無いとただのターミナルラッパーで終わってしまうので、基本的には設定しておくのがおすすめです。

ghostel インストール補足

ghostel はネイティブモジュール(Zig製の libghostty バインディング)を必要とするパッケージです。M-x ghostel などの最初の対話的コマンドを実行したタイミングでモジュールが見つからないと、ghostel-module-auto-install の設定(デフォルト ask)に従い、

  • ダウンロード(M-x ghostel-download-module GitHub Releasesからビルド済みバイナリを取得)
  • コンパイル(M-x ghostel-module-compile zig build でソースからビルド)

を Message windows にエラーで残します(init.elロード時)。 筆者はZigのビルド環境を用意していなかったため、ここでは M-x ghostel-download-module を選択しました。

基本的な使い方

M-x claude-code-ide-menu (上記設定では C-c C-') でtransientメニューが開き、そこから主要な操作にアクセスできます。よく使うコマンドは以下の通りです。

コマンド 説明
claude-code-ide-menu transientメニューを開く
claude-code-ide 現在のプロジェクトでClaude Codeを起動
claude-code-ide-send-prompt ミニバッファからプロンプトを送信
claude-code-ide-continue 直近の会話を継続
claude-code-ide-resume 過去の会話を選んで再開
claude-code-ide-toggle Claudeウィンドウの表示/非表示を切り替え
claude-code-ide-insert-at-mentioned 選択範囲をプロンプトへ送信(メンション付き)
claude-code-ide-show-debug WebSocket通信のデバッグバッファを表示

プロジェクトは project.el により自動判定され、プロジェクトごとに *claude-code[project-name]* という専用バッファが作られます。複数プロジェクトを同時に開いていても、それぞれ独立したセッションとして扱われます。

ウィンドウ表示: サイドウィンドウ vs 通常ウィンドウ

デフォルトでは claude-code-ide-use-side-window が t になっており、画面右側にサイドウィンドウとしてClaudeのバッファが表示されます。筆者の環境では通常のウィンドウとして開きたかったため、nil に変更しました。

(setq claude-code-ide-use-side-window nil)

ターミナルバックエンド選びでハマった話

claude-code-ide-terminal-backend は vterm / eat / ghostel の3つから選べますが、筆者の環境では次のような問題に当たりました。

  1. vterm(デフォルト): そもそもバックスクロールができない
  2. eat: バックスクロールすると描画がおかしくなり、最終的にEmacsごとフリーズしてkillするしかなくなる
  3. ghostel: Ghostty のターミナルエンジン(libghostty-vt)をNative moduleとして使うEmacs用ターミナルパッケージ。今のところバックスクロールも問題なく動作している

というわけで、最終的に ghostel に落ち着きました。README上でも「利用可能であれば ghostel が最もちらつきや描画崩れが少なくおすすめ」と明記されています。

(setq claude-code-ide-terminal-backend 'ghostel)

Emacs MCP Toolsで何が嬉しいか

claude-code-ide-emacs-tools-setup を呼んでおくと、Claude Codeが以下のようなEmacsの機能を「ツール」として呼び出せるようになります。

  • xref-find-references / xref-find-apropos — LSP(eglot/lsp-mode等)経由のシンボル参照・検索
  • treesit-info — Tree-sitterによる構文解析
  • imenu-list-symbols — ファイル内のシンボル一覧
  • project-info — プロジェクト情報の取得

これにより、「この関数の定義を探して」「この変数がどこで使われているか教えて」のような質問に対して、Claudeが実際にEmacs側のLSP・Tree-sitterの情報を使って正確に答えられるようになります。任意のElisp関数を claude-code-ide-make-tool で独自ツールとして公開することも可能です。

diff確認は ediff で

claude-code-ide-use-ide-diff が有効(デフォルト)な場合、Claudeがコード変更を提案するとediffが自動的に開きます。Buffer Aが現在のコード、Buffer Bが提案されたコードで、Buffer Bを自分で修正してから適用することもできます。ターミナル上でdiffを読むよりも視認性が高く、修正の手戻りも少なくなるのでおすすめです。

まとめ

  • ターミナルバックエンドは筆者環境では ghostel が一番安定

普段使っているEmacsのワークフローをそのままに、Claude Codeをコードベースの文脈を理解したペアプログラマーとして活用できるので、Emacsユーザーにはかなりおすすめのパッケージです。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?