Upgrade to Pro — share decks privately, control downloads, hide ads and more …

gopls使うとClaude Codeは賢くなるのか試してみた

Avatar for Rei Sugiura Rei Sugiura
September 01, 2025
32

gopls使うとClaude Codeは賢くなるのか試してみた

2025/9/1 golang.tokyo#40で発表した内容です。

Avatar for Rei Sugiura

Rei Sugiura

September 01, 2025
Tweet

Transcript

  1. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた 1. goplsとは 2. gopls

    mcpについて 3. goplsが提供するtool 4. goplsを使ってみる 5. 今回できなかったこと アジェンダ
  2. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた goplsとは Goの公式Language Server Protocol(LSP)を実装したライブラリ、具体的には、コード補完、定義へのジャンプ、リファクタリング、エラーチェック

    など、開発効率を向上させる様々な機能を提供している。 VS CodeやNeovimなどのエディタで広く使われています。 画像出典: https://code.visualstudio.com/api/language-extensions/language-server-extension-guide
  3. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた gopls mcpについて Claude CodeやCursorなどのAI

    Agentを利⽤するクライアントがgoplsの機能を利⽤できるようにするための機能 Claude Codeが、mcpを通じて関数の定義、packageの情報を効率的に取得できることが期待できる goplsのv0.20.0から利⽤可能 👉document: https://go.dev/gopls/features/mcp 画像出典: https://code.visualstudio.com/api/language-extensions/language-server-extension-guide https://tip.golang.org/gopls/release/v0.20.0 Jul 29
  4. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた gopls mcpを使ってみる サンプルのタスク管理ツールの処理を探索してまとめさせてみる。 >

    @internal/presentation/cli/cmd/search.go で実装されているsearchコマンドの処理についてシーケンスでまとめてmdファイルで出⼒してください
  5. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた gopls mcpを使ってみる Opus 最初にSearchTaskUseCaseでgoファイルをgrepし、hitしたファイルをreadしていそう

    ⏺ Search(pattern: "SearchTaskUseCase", glob: "**/*.go") ⎿ Found 5 files (ctrl+r to expand) ⏺ Read(internal/usecase/task/search_task.go) ⎿ Read 78 lines (ctrl+r to expand) ⏺ Read(internal/presentation/cli/container/container.go) ⎿ Read 50 lines (ctrl+r to expand) ⏺ Write(search_command_sequence.md) ⎿ Wrote 102 lines to search_command_sequence.md > /context ⎿ ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Context Usage ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ claude-opus-4-1-20250805 • 19k/200k tokens (10%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 3.2k tokens (1.6%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 11.4k tokens (5.7%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 4.9k tokens (2.4%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 180.5k (90.3%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
  6. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた gopls mcpを使ってみる Opus +

    gopls mcp 最初に、go_file_contextを利⽤して、search.go ファイル内のpackageの依存関係をリストしてから、readするファイルを選択していそう ⏺ gopls - go_file_context (MCP)(file: "/Users/sugiura/gopls-mcp-playground/internal/presentation/cli/cmd/search.go") ⏺ Read(internal/presentation/cli/container/container.go) ⎿ Read 85 lines (ctrl+r to expand) ⏺ Read(internal/usecase/task/search_task.go) ⎿ Read 78 lines (ctrl+r to expand) ⏺ Read(internal/adapter/repository/task_repository.go) ⎿ Read 37 lines (ctrl+r to expand) ⏺ Write(search_command_sequence.md) ⎿ Wrote 113 lines to search_command_sequence.md > /context ⎿ ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ Context Usage ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ claude-opus-4-1-20250805 • 30k/200k tokens (15%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 3.2k tokens (1.6%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 11.8k tokens (5.9%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: 2.8k tokens (1.4%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 12.0k tokens (6.0%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 170.4k (85.2%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
  7. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた gopls mcpを使ってみる Opus +

    gopls mcp 最初に、go_file_contextを利⽤して、search.go ファイル内のpackageの依存関係をリストしてから、readするファイルを選択していそう ⏺ gopls - go_file_context (MCP)(file: "/Users/sugiura/gopls-mcp-playground/internal/presentation/cli/cmd/search.go") ⎿ File `/Users/sugiura/gopls-mcp-playground/internal/presentation/cli/cmd/search.go` is in package "github.com/sugiura/todo-app/internal/presentation/cli/cmd". Below is a summary of the APIs it uses from other files. To read the full API of any package, use go_package_api. Referenced declarations from /Users/sugiura/gopls-mcp-playground/internal/usecase/dto/task_input_dto.go (package "github.com/sugiura/todo-app/internal/usecase/dto"): ```go // SearchTaskInput represents the input data for searching tasks type SearchTaskInput struct { Keyword string Status *string // "completed", "pending", or nil for all DueDateFrom *time.Time DueDateTo *time.Time Tags []string IncludeDeleted bool OnlyDeleted bool IncludeCompleted bool OnlyCompleted bool } ```
  8. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた gopls mcpを使ってみる Opus +

    gopls mcp 最初に、go_file_contextを利⽤して、search.go ファイル内のpackageの依存関係をリストしてから、readするファイルを選択していそう ⏺ gopls - go_file_context (MCP)(file: "/Users/sugiura/gopls-mcp-playground/internal/presentation/cli/cmd/search.go") ⏺ Read(internal/presentation/cli/container/container.go) ⎿ Read 85 lines (ctrl+r to expand) ⏺ Read(internal/usecase/task/search_task.go) ⎿ Read 78 lines (ctrl+r to expand) ⏺ Read(internal/adapter/repository/task_repository.go) ⎿ Read 37 lines (ctrl+r to expand) ⏺ Write(search_command_sequence.md) ⎿ Wrote 113 lines to search_command_sequence.md > /context ⎿ ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ Context Usage ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ claude-opus-4-1-20250805 • 30k/200k tokens (15%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 3.2k tokens (1.6%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 11.8k tokens (5.9%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: 2.8k tokens (1.4%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 12.0k tokens (6.0%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 170.4k (85.2%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
  9. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた gopls mcpを使ってみる goplsを使った⽅が使⽤token数が多くなった。 👉go_file_context

    のoutputのテキスト量がとても多 いため > /context ⎿ ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Context Usage ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ claude-opus-4-1-20250805 • 19k/200k tokens (10%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 3.2k tokens (1.6%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 11.4k tokens (5.7%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 4.9k tokens (2.4%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 180.5k (90.3%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ > /context ⎿ ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ Context Usage ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ claude-opus-4-1-20250805 • 30k/200k tokens (15%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 3.2k tokens (1.6%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 11.8k tokens (5.9%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: 2.8k tokens (1.4%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 12.0k tokens (6.0%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 170.4k (85.2%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Opus Opus + gopls mcp
  10. ©GROWTH VERSE Co., Ltd. gopls使うとClaude Codeは賢くなるのか試してみた 今回できなかったこと lspをmcp経由で利⽤できるツール同⼠の⽐較 - https://github.com/mizchi/lsmcp

    - https://github.com/oraios/serena > LSP という視点でみたときに、これらはプロジェクト、ファイル、カーソル位置におけるアクションという命令セットになっているのだが、 実際 AI 向けには⾮効率なのではという直感を得ている。 👉goplsがlspのインターフェースを利⽤せずに、提供するmcpのユニークさを深掘りたい