はじめに
Claude Code を使用して, Serena の有無でトークン使用量の違いを見てみます.
使用モデル: claude-sonnet-4-5-20250929
設定
まず, Claude Code と Serena を MCP 経由で接続します.
接続できたら次に, Claude Code 上で Serena のプロジェクトを作成します.
> project create use serena
⏺ I'll help you set up Serena for this project. Let me first check the current configuration and onboarding status.
...
⏺ Perfect! The Serena project has been successfully set up and onboarded. Here's what I've documented:
Project Created: <ProjectName>
少し待つと, プロジェクトルートに以下の通り各種ファイルが作成されました.
$HOME/.../<ProjectName>/.serena
├── cache
│ └── typescript
│ ├── document_symbols.pkl
│ └── raw_document_symbols.pkl
├── memories
│ ├── code_style_conventions.md
│ ├── codebase_structure.md
│ ├── project_overview.md
│ ├── suggested_commands.md
│ ├── task_completion_checklist.md
│ └── tech_stack.md
└── project.yml
かいつまんで中身を見ると以下の情報が書き込まれていました.
.serena/memories/project_overview.md
# Project Overview
## Purpose
...
## Architecture
...
比較してみる
Serena: 無効化
Serena 含めて MCP サーバは登録していません.
> /cost
⎿ Total cost: $0.0000
Total duration (API): 0s
Total duration (wall): 2s
Total code changes: 0 lines added, 0 lines removed
Usage: 0 input, 0 output, 0 cache read, 0 cache write
> このリポジトリのプロジェクト名は?
⏺ プロジェクト名を確認するために、設定ファイルを見てみます。
⏺ Read(package.json)
⎿ Read 25 lines
⏺ Read(README.md)
⎿ Read 168 lines
⏺ このリポジトリのプロジェクト名は <ProjectName> です。
package.jsonでは "name": "<ProjectName>" と定義されており、README.mdにも「<ProjectName>」と記載されています。
> /cost
⎿ Total cost: $0.0413
Total duration (API): 32s
Total duration (wall): 24s
Total code changes: 0 lines added, 0 lines removed
Usage by model:
claude-haiku: 3.4k input, 189 output, 0 cache read, 0 cache write ($0.0044)
claude-sonnet: 21 input, 892 output, 39.8k cache read, 3.1k cache write ($0.0370)
Serena: 有効化
> /mcp
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Manage MCP servers │
│ │
│ ❯ 1. serena ✔ connected · Enter to view details │
│ │
│ MCP Config locations (by scope): │
│ ...
> /cost
⎿ Total cost: $0.0000
Total duration (API): 0s
Total duration (wall): 2s
Total code changes: 0 lines added, 0 lines removed
Usage: 0 input, 0 output, 0 cache read, 0 cache write
> このリポジトリのプロジェクト名は?
∴ Thinking…
The user is asking "このリポジトリのプロジェクト名は?" which means "What is the project name of this repository?" in Japanese.
Looking at the environment information provided, I can see:
- Working directory: $HOME/.../<ProjectName>
- The project name is mentioned as '<ProjectName>' in the serena configuration
I should simply answer the user's question directly. This is a straightforward informational query that doesn't require any tool calls.
⏺ このリポジトリのプロジェクト名は <ProjectName> です。
作業ディレクトリは $HOME/.../<ProjectName> で、現在のブランチは ... です。
> /cost
⎿ Total cost: $0.0196
Total duration (API): 22s
Total duration (wall): 14s
Total code changes: 0 lines added, 0 lines removed
Usage by model:
claude-haiku: 2.3k input, 206 output, 0 cache read, 0 cache write ($0.0034)
claude-sonnet: 13 input, 511 output, 28.4k cache read, 0 cache write ($0.0162)
Serena 未使用時と比較:
- output が 892 → 511 (約43%減)
- cache read が 39.8k → 28.4k (約30%減)
- cache write が 3.1k → 0 (100%減)
- コストが
$0.0370→$0.0162(約56%減)
まとめ
Serena を使うことで
- プロジェクトの構造や知識を再利用できる
- そのため不要なファイルの読み込みや書き込みが減る
- 特にコストの高い sonnet 4.5 のトークン量が大幅に削減される
という理由から, (非常にシンプルな検証でしたが) Serena は優位性があると感じました.