Web Analytics

claude-sh

⭐ 111 stars English by jdcodes1

claude.sh

Claude Code rewritten as a bash script. ~1,500 lines. Zero npm packages.

Why

The original Claude Code is ~380,000 lines of TypeScript with 266 npm dependencies. This does the same core job in bash with just curl and jq.

Features

Install

git clone https://github.com/jdcodes1/claude.sh.git
cd claude.sh
chmod +x claude.sh

Dependencies

Runtime versions are pinned in .tool-versions. Install them with mise:

mise install

Usage

export ANTHROPIC_API_KEY="sk-ant-..."
./claude.sh

Environment Variables

| Variable | Default | Description | | --- | --- | --- | | ANTHROPIC_API_KEY | (required) | Your Anthropic API key | | CLAUDE_MODEL | claude-sonnet-4-6 | Model to use | | CLAUDE_MAX_TOKENS | 8192 | Max output tokens | | ANTHROPIC_API_URL | https://api.anthropic.com | API base URL | | CLAUDE_SH_PERMISSIONS | ask | Permission mode: ask, allow, or deny |

Commands

/help      — Show help
/cost      — Show session cost
/model     — Show/change model
/clear     — Clear conversation
/save      — Save current session
/resume    — List/resume saved sessions
/commit    — Auto-generate a git commit
/diff      — Show git diff
/quit      — Exit

Resume a Session

# List saved sessions
./claude.sh
/resume

Resume by number

/resume 1

Resume from CLI

./claude.sh --resume 20240101-120000-12345

Architecture

claude.sh          # Main REPL loop, slash commands, process_turn()
lib/
  api.sh           # Anthropic API client, SSE streaming via FIFO, retry
  json.sh          # Message construction, session persistence, CLAUDE.md, git context
  tools.sh         # 6 tool implementations + permission system
  tui.sh           # ANSI colors, spinner, display helpers

How It Works

Comparison

| | claude.sh | Claude Code (TypeScript) | | --- | --- | --- | | Lines of code | ~1,500 | ~380,000 | | Dependencies | curl, jq | 266 npm packages | | Binary size | 0 (script) | ~200MB node_modules | | Startup time | Instant | ~500ms |

Testing

Tests use bats (Bash Automated Testing System):

bats test/

License

MIT

--- Tranlated By Open Ai Tx | Last indexed: 2026-07-04 ---