An elegant interactive CLI for Anthropic's Claude API, built with TypeScript and Bun.js
Click to expand
- 🎯 Interactive chat sessions with Claude
- 📝 Smart code detection and file saving
- 🎨 Beautiful console interface with syntax highlighting
- 💾 Auto-save and session replay
- 🔄 Rate limiting and error handling
- 📦 Template support for common use cases
- 🧪 Dry-run mode for testing
- 🔍 Type-safe configuration with Zod
# Using bun
bun install -g claude-cli
# Using npm
npm install -g claude-cli
# Start a new chat session
claude-cli chat
# Use a specific template
claude-cli chat --template rust
# Replay a previous session
claude-cli replay <session-id>
# Show help
claude-cli --help
Available Templates
// @filename: templates.ts
const templates = {
rust: {
name: 'Rust Expert',
description: 'Expert Rust development assistance',
systemPrompt: `You are an expert Rust developer...`
},
typescript: {
name: 'TypeScript Expert',
description: 'Expert TypeScript development assistance',
systemPrompt: `You are an expert TypeScript developer...`
}
}
Sessions are automatically saved in .claude-sessions
directory as YAML files:
id: abc123
startTime: 1234567890
messages:
- role: user
content: Hello
timestamp: 1234567890
- role: assistant
content: Hi! How can I help you today?
timestamp: 1234567891
codeBlocks:
- filename: example.rs
language: rust
content: |
fn main() {
println!("Hello, world!");
}
Create a .claude-cli.config.ts
file in your project root:
// @filename: config.ts
export default {
templates: {
// Custom templates
myTemplate: {
name: 'My Template',
description: 'Custom template',
systemPrompt: 'Your system prompt here',
}
},
defaults: {
outputDir: './output',
model: 'claude-2',
autoSave: true,
sessionDir: './.claude-sessions',
}
}
Basic Chat Session
$ claude-cli chat
🤖 Welcome to Claude CLI!
💭 Your message: Help me write a Rust function to calculate Fibonacci numbers
┌─────────────────────────────────────────────────────
│ Claude:
│ I'll help you create an efficient Rust function for calculating Fibonacci numbers.
│ Here's an implementation using dynamic programming:
│
│ 📄 fib.rs
│ fn fibonacci(n: u64) -> u64 {
│ if n <= 1 {
│ return n;
│ }
│
│ let mut a = 0;
│ let mut b = 1;
│
│ for _ in 2..=n {
│ let temp = a + b;
│ a = b;
│ b = temp;
│ }
│
│ b
│ }
│
│ Would you like me to save this file?
└─────────────────────────────────────────────────────
Using Templates
$ claude-cli chat --template rust
🤖 Rust Expert Mode Activated!
💭 Your message: How do I read a large JSON file efficiently?
...
# Clone the repository
git clone https://github.com/danielbodnar/claude-cli.git
# Install dependencies
bun install
# Build
bun run build
# Run tests
bun test
# Run locally
bun run dev
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT License - see the LICENSE file for details
Made with ❤️ using Bun.js and TypeScript