claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[PROPOSAL] Golang Rewrite to Address Critical Memory Usage (1.5-2GB per session)

Open kuzmeech opened this issue 2 months ago • 3 comments

Problem: Excessive Memory Usage Makes Claude Code Unusable on Standard Hardware

Current State on macOS (2.0.17):

Each Claude Code session consumes 1.5-2GB of active memory:

Process             Active  Compressed
claude heap-keeper  2.16GB  371MB
claude iterm2-fork  1.76GB  295MB  
claude gw-audit     1.66GB  271MB
claude iterm2-fork  1.46GB  251MB
claude hubspot      1.02GB  173MB

Real-World Impact:

  • 16GB Mac: Cannot run more than 3-4 concurrent Claude sessions
  • Had to upgrade to Mac Studio 64GB just to work with multiple projects
  • Memory pressure forces constant session restarts
  • Swap usage degrades performance significantly

Related Issues:

  • #4953: Process grows to 120GB+ RAM and gets OOM killed (Linux)
  • #8706: Resource exhaustion with Sonnet 4.5 (WSL2)
  • #9579: Autocompacting loop causing massive token usage
  • Multiple other perf:memory tagged issues

Proposal: Golang Rewrite

I'm offering to rewrite the Claude Code client in Go (under NDA if required) to address these fundamental performance issues:

Why Golang?

Memory Efficiency:

  • Go binaries typically use 10-50MB vs Node.js 500MB-2GB
  • Efficient garbage collection with lower overhead
  • No V8 engine overhead (100-200MB baseline)
  • Static compilation eliminates runtime dependencies

Performance:

  • 5-10x faster startup time (no JIT warmup)
  • Lower CPU usage (compiled vs interpreted)
  • Better concurrency primitives (goroutines vs async/promises)

Production Examples:

  • Docker CLI: ~30MB memory footprint
  • kubectl: ~50MB memory footprint
  • GitHub CLI (gh): ~40MB memory footprint
  • All handle complex terminal UIs, API interactions, and concurrent operations

Estimated Improvements

  • Memory: 1.5-2GB → 30-100MB per session (15-50x reduction)
  • Startup: 2-3s → 100-300ms (10x faster)
  • CPU: Significantly lower idle and active usage
  • Disk: Single ~20MB binary vs 200MB+ node_modules

Implementation Approach

Phase 1: Core Rewrite (3-4 months)

  • API client (using official anthropic-sdk-go)
  • Terminal UI (using bubbletea or tview)
  • File operations and git integration
  • MCP server protocol

Phase 2: Feature Parity (2-3 months)

  • Hooks system
  • All current features and flags
  • Migration tooling for existing configs

Phase 3: Testing & Migration (1-2 months)

  • Beta testing with community
  • Performance benchmarking
  • Gradual rollout

About Me

  • Experienced Go developer (can provide references)
  • Willing to work under NDA
  • Can commit 20-30 hours/week
  • No compensation required (contribution to open source)

Questions for Anthropic Team

  1. Would you be open to a Golang rewrite?
  2. What are the technical constraints/requirements?
  3. How can we structure this collaboration?
  4. Is there existing internal work in this direction?

The current Node.js implementation is a major barrier to adoption. Multiple users have reported needing to upgrade hardware just to use Claude Code effectively. A memory-efficient rewrite would make this tool accessible on standard development machines.

I'm ready to start immediately if there's interest.

kuzmeech avatar Oct 15 '25 19:10 kuzmeech

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/8968
  2. https://github.com/anthropics/claude-code/issues/8737
  3. https://github.com/anthropics/claude-code/issues/8542

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Oct 15 '25 19:10 github-actions[bot]

lol. Bro they are writing it into Rust to be hipster.

haltingstate avatar Oct 30 '25 21:10 haltingstate

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 08 '25 10:12 github-actions[bot]