Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/danielbodnar/claude-cli

๐Ÿค– Claude CLI: An elegant interactive CLI for Anthropic's Claude API, built with TypeScript and Bun.js. By claude for claude.
https://github.com/danielbodnar/claude-cli

ai anthropic anthropic-claude bun claude claude-3-5-sonnet claude-ai cli llms

Last synced: 15 days ago
JSON representation

๐Ÿค– Claude CLI: An elegant interactive CLI for Anthropic's Claude API, built with TypeScript and Bun.js. By claude for claude.

Awesome Lists containing this project

README

        

# ๐Ÿค– Claude CLI

> An elegant interactive CLI for Anthropic's Claude API, built with TypeScript and Bun.js

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## ๐Ÿ“š Table of Contents

Click to expand

- [Features](#-features)
- [Installation](#-installation)
- [Usage](#-usage)
- [Basic Commands](#basic-commands)
- [Templates](#templates)
- [Session Management](#session-management)
- [Configuration](#-configuration)
- [Examples](#-examples)
- [Development](#-development)
- [Contributing](#-contributing)
- [License](#-license)

## โœจ Features

- ๐ŸŽฏ 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

## ๐Ÿš€ Installation

```bash
# Using bun
bun install -g claude-cli

# Using npm
npm install -g claude-cli
```

## ๐ŸŽฎ Usage

### Basic Commands

```bash
# Start a new chat session
claude-cli chat

# Use a specific template
claude-cli chat --template rust

# Replay a previous session
claude-cli replay

# Show help
claude-cli --help
```

### Templates

Available Templates

```typescript twoslash
// @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...`
}
}
```

### Session Management

Sessions are automatically saved in `.claude-sessions` directory as YAML files:

```yaml
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!");
}
```

## โš™๏ธ Configuration

Create a `.claude-cli.config.ts` file in your project root:

```typescript twoslash
// @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',
}
}
```

## ๐Ÿ“ Examples

Basic Chat Session

```bash
$ 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

```bash
$ claude-cli chat --template rust
๐Ÿค– Rust Expert Mode Activated!
๐Ÿ’ญ Your message: How do I read a large JSON file efficiently?
...
```

## ๐Ÿ› ๏ธ Development

```bash
# 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
```

## ๐Ÿค Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## ๐Ÿ“„ License

MIT License - see the [LICENSE](LICENSE) file for details

---


Made with โค๏ธ using Bun.js and TypeScript