promptcoder-cli
v1.0.0
Published
AI-powered code generation CLI tool with conversation persistence, file tools, and LLM integration
Maintainers
Readme
PromptCoder CLI
🤖 AI-powered code generation CLI tool with conversation persistence, advanced file tools, and support for multiple LLM providers (OpenAI GPT & Anthropic Claude).
✨ Features
- 🎯 Interactive Mode: Chat-like interface for iterative code generation
- 📝 Conversation Persistence: Save and resume conversations across sessions
- 🔧 Advanced File Tools: Diff edits, search, checkpoints, and smart directory filtering
- 🤖 Multiple LLM Providers: OpenAI (GPT-4) and Anthropic (Claude) support
- 🚀 Retry Logic: Automatic retry with exponential backoff for API rate limits
- 🎨 Beautiful Interface: Colorized output with progress indicators
- 📁 Project-Aware: Maintains working directory context per conversation
🚀 Installation
Global Installation (Recommended)
npm install -g promptcoder-cliLocal Installation
npm install promptcoder-cli⚙️ Configuration
First Run Setup
promptcoder configEnvironment Variables
# OpenAI
export OPENAI_API_KEY="your-openai-api-key"
export OPENAI_MODEL="gpt-4o" # optional
# Anthropic
export ANTHROPIC_API_KEY="your-anthropic-api-key"
export ANTHROPIC_MODEL="claude-3-5-sonnet-20241022" # optionalManual Configuration
Configuration is stored in ~/.promptcoder/config.json
🎯 Usage
Interactive Mode
promptcoder interactive
# or
promptcoder iSingle Prompt
promptcoder prompt "Create a React component for a todo list"
# or
promptcoder p "Add error handling to my express server" --directory ./my-projectConversation Management
# In interactive mode:
save # Save current conversation
load # Load a previous conversation
list # List all saved conversations
rename # Rename current conversation
delete # Delete a conversation
clear # Clear current conversation🔧 Available Tools
The AI has access to these powerful tools:
Basic File Operations
read_file- Read file contentswrite_file- Write content to files (creates directories automatically)read_directory- Smart directory listing (filters node_modules, .git, etc.)create_directory- Create directoriesdelete_file- Delete filesfile_exists- Check if files/directories exist
Advanced Editing
edit_file_diff- Precise edits using exact text matchinginsert_lines- Insert content at specific line numbersdelete_lines- Remove specific line ranges
Search & Discovery
search_in_files- Search patterns across multiple files with regex support
Version Control
create_checkpoint- Save snapshots of file stateslist_checkpoints- View all checkpoints with metadatarestore_checkpoint- Rollback to previous statesshow_file_diff- Compare current files with checkpoint versions
📚 Examples
Creating a React App
promptcoder i
Prompt: Create a modern React TypeScript app with routing and state management
# The AI will:
# 1. Read your directory structure
# 2. Create package.json with dependencies
# 3. Set up TypeScript configuration
# 4. Create components and routing
# 5. Set up state management
# 6. Add proper file structureRefactoring Code
promptcoder i
Prompt: Refactor this codebase to use TypeScript and add proper error handling
# The AI will:
# 1. Create a checkpoint of current state
# 2. Search through existing files
# 3. Convert JavaScript to TypeScript
# 4. Add error handling patterns
# 5. Update configurations
# 6. Show diffs of changes madeConversation Persistence
# Start working on a project
promptcoder i
Prompt: Build a REST API with Express and PostgreSQL
# ... work continues ...
save
Name: "E-commerce API"
Description: "Building product catalog and user auth"
# Later, resume exactly where you left off
promptcoder i
load
# Select: "E-commerce API (15 messages, 12/5/2024)"
# Continue with full context preserved🔄 Conversation Flow
🤖 PromptCoder Interactive Mode
Commands: exit, clear, save, load, list, rename, delete
[My React Project] Prompt: Add authentication to the app
🔄 Processing (1/25)...
💬 Response:
I'll help you add authentication to your React app. Let me first examine your current project structure.
🔧 Executing 2 tool call(s):
→ read_directory({"dir_path":"."})
Contents of . (8 items):
FILE: package.json (2KB)
DIR: src
FILE: tsconfig.json (421B)
...
→ read_file({"file_path":"src/App.tsx"})
File contents of src/App.tsx:
...
🔄 Continuing conversation after tool execution...
💬 Response:
Now I'll create the authentication system. I'll add:
1. Auth context and provider
2. Login/signup components
3. Protected routes
4. JWT token management
🔧 Executing 4 tool call(s):
→ create_checkpoint({"checkpoint_name":"before_auth","description":"Before adding authentication"})
Created checkpoint "before_auth" with 12 files
→ write_file({"file_path":"src/contexts/AuthContext.tsx","content":"..."})
Successfully wrote 1240 characters to src/contexts/AuthContext.tsx
...
✅ Turn completed🛠️ Development
# Clone and install
git clone https://github.com/promptcoder/promptcoder-cli.git
cd promptcoder-cli
npm install
# Development mode
npm run dev
# Build
npm run build
# Test global installation
npm run build && npm link🔒 Privacy & Security
- API Keys: Stored locally in
~/.promptcoder/config.json - Conversations: Stored locally in
~/.promptcoder/conversations/ - No Data Sharing: All data remains on your machine
- Secure: Uses official OpenAI and Anthropic SDKs
🚨 Requirements
- Node.js: 16.0.0 or higher
- API Key: OpenAI or Anthropic API key
- Operating System: macOS, Linux, or Windows
📄 License
MIT © PromptCoder Team
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📞 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with ❤️ for developers who want to code faster with AI assistance.
