⚠ ネタバレ注意: 本サイトはSFアニメ「SOLAR LINE」の内容を詳細に分析しています。未視聴の方はご注意ください。
📝 AI生成コンテンツ: 本考証の大部分は AI(Claude Code 等)によって生成されています。内容の正確性については原作および引用元をご確認ください。

← アイデア一覧

Cost Efficiency Analysis — SOLAR LINE Project

Status: RESOLVED

Key recommendations incorporated into CLAUDE.md and project practices:

Overview

Analysis of Claude Code token usage patterns across the SOLAR LINE project, based on

ccusage session data from the autonomous agent loop VM.

Key Metrics (Sample: 1 day, 58 sessions, 120 subagents)

MetricValue
Total tokens~360M
Total cost (Haiku subagents)~$6.57
Main session cost (Opus)$0 (Max subscription)
Cache read ratio97.3%
Tool calls4,675
Subagent invocations120

Token Distribution

Cost Drivers

1. Subagent spawning (100% of measured cost)

All $6.57 comes from Haiku subagent calls. Each subagent:

2. TodoWrite frequency (9.8% of tool calls)

459 TodoWrite calls across 58 sessions (7.9 per session average). Each call includes

the full todo list in both the request and response, consuming context on every turn.

3. Long-running Bash streams

The largest session was 16x the average size due to bash_progress streaming from

Whisper/yt-dlp. These progress lines are stored in the JSONL and inflate context.

4. Subagent model selection

Efficiency Recommendations

High Impact

  1. Reduce TodoWrite frequency: Update only on state transitions (start/complete), not

between every tool call. Could save ~200 context turns per day.

  1. Background long Bash commands: Use run_in_background for yt-dlp, Whisper, and

other long-running processes. Check output later with TaskOutput.

Medium Impact

  1. Prefer Haiku for exploration subagents: Most subagent tasks are simple file reading.

Haiku is sufficient and cheaper.

  1. Prefer Read/Grep over Bash in subagents: 43% of subagent tool calls are Bash

(often doing cat/grep/find). The dedicated tools are more structured and efficient.

  1. Limit subagent scope: Some subagents run 95+ tool calls (9+ minutes). Set

max_turns on Task calls to cap exploration.

Low Impact, High Value

  1. Skill-ize repeated workflows: Create Claude Code Skills for:

- Episode analysis pipeline

- Report review checklist

- Subtitle processing (download + transcribe + extract)

  1. Trim MEMORY.md: Keep under 200 lines. Move detailed content to topic files.

Currently truncated at 200 lines, wasting some cache creation tokens.

Cost Estimation Framework

For the full project (~65 tasks, ~94 commits), assuming similar patterns:

The project's cost efficiency is generally excellent (97.3% cache hit rate).

The main optimization opportunities are in reducing unnecessary context churn

(TodoWrite) and avoiding inflated sessions from streaming output.

Running the Analysis


# In ts/ directory:
# Option 1: Pipe from ccusage
bunx ccusage@17 session --offline --json | npm run analyze-costs -- --mode session

# Option 2: Save and analyze
bunx ccusage@17 session --offline --json > costs.json
npm run analyze-costs -- --mode session --input costs.json

# Option 3: Daily summary
bunx ccusage@17 daily --offline --json | npm run analyze-costs -- --mode daily