An AI-powered development assistant built in Rust that provides interactive code editing, debugging, and project analysis through Anthropic's Claude 4 API.
- Interactive Terminal Interface - Chat-based interaction with AI assistant
- Real-time Code Analysis - Directory scanning and file examination
- AI-Powered Code Editing - Direct file modifications through natural language
- Multi-Tool Integration - Custom and built-in tool support
- Session Management - Continuous conversation with context retention
view- Read and examine file contentsstr_replace- Find and replace text with precision matchingcreate- Generate new files with automatic directory creationinsert- Add content at specific line numbers- Automatic Backup System - Safe undo functionality with in-memory storage
- Directory Scanning - Complete project structure analysis
- File Reading - Content extraction and display
- Code Context - Understanding project architecture and dependencies
- Rust (1.70+) - Install Rust
- Anthropic API Key - Get API Key
-
Clone the repository:
git clone <repository-url> cd simple-coder
-
Install dependencies:
cargo build
-
Configure environment:
cp .env.example .env # Edit .env and add your Anthropic API key: # ANTHROPIC_API_KEY=your_api_key_here
-
Run the application:
cargo run
$ cargo run
What do you want to talk about:
> Please read the main.rs file and add error handling to the file operations
# AI will automatically:
# 1. Scan project structure
# 2. Read relevant files
# 3. Make necessary edits
# 4. Show you the changes- "Fix the syntax error in src/main.rs"
- "Add logging to the database functions"
- "Create a new module for user authentication"
- "Review the code in utils/ and suggest improvements"
- "Add unit tests for the parser functions"
Enable detailed logging:
RUST_LOG=debug cargo run| Variable | Description | Required |
|---|---|---|
ANTHROPIC_API_KEY |
Your Anthropic API key | β Yes |
RUST_LOG |
Log level (error/warn/info/debug/trace) | β No (default: info) |
The application uses Claude 4 Sonnet by default. Model settings are configured in src/main.rs:
ModelConfig {
model_name: "claude-sonnet-4-20250514".to_string(),
max_tokens: 2000, // Accommodates tool usage + response
temperature: 0.5, // Balanced creativity/consistency
// ...
}simple-coder/
βββ src/
β βββ main.rs # Main application & API integration
β βββ scan_directory.rs # Project structure analysis
β βββ patch_apply.rs # Code patching utilities
β βββ tools/
β βββ text_editor.rs # Advanced file editing system
β βββ read_file.rs # File content extraction
β βββ scan_directory.rs # Directory tree operations
βββ specs/ # Comprehensive documentation
βββ README.md # This file
- Language: Rust 2021 Edition
- AI Integration: Anthropic Claude 4 API
- HTTP Client: reqwest with async/await
- Serialization: serde with JSON support
- Logging: log + env_logger
- Environment: dotenv for configuration
Detailed technical documentation is available in the specs/ directory:
| Document | Purpose |
|---|---|
SPECS.md |
Master documentation index |
01-application-overview.md |
System architecture |
02-ai-integration.md |
Claude API integration |
03-file-operations.md |
File system operations |
06-security-considerations.md |
Security analysis |
08-text-editor-tool.md |
Text editor implementation |
- β Environment Variable Configuration - API keys stored securely
- β Input Validation - Basic parameter checking
- β Error Handling - Comprehensive error management
- β Thread Safety - Mutex-protected shared state
- Path traversal vulnerabilities
- File access restrictions
- Recommended sandboxing approaches
# Debug build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Check code quality
cargo clippy- Read the specifications in
specs/directory - Follow Rust best practices - use clippy and rustfmt
- Update documentation - keep specs synchronized with code
- Test thoroughly - ensure compilation and functionality
See specs/02-ai-integration.md for guide on extending the tool system.
- Memory Usage: Linear with file size and backup count
- Concurrency: Single-threaded with async I/O
- File Size Limits: Memory-bound (entire files loaded)
- Session Persistence: In-memory only
- Streaming file operations for large files
- Persistent backup storage
- Multi-threading for concurrent operations
- File size limits and validation
- Enhanced security with path sandboxing
- Configuration file support
- Better error messages and recovery
- File size limits and validation
- Persistent backup storage
- Multi-file operation support
- Plugin architecture for custom tools
- Web interface option
- Git integration for version control
- Collaborative editing support
- Advanced code analysis features
- Integration with popular IDEs
"ANTHROPIC_API_KEY environment variable must be set"
- Ensure
.envfile exists with valid API key - Check
.env.examplefor format reference
"Tool execution failed: Failed to read file"
- Verify file paths are correct and accessible
- Check file permissions
- Ensure files exist in the project directory
High memory usage
- Large files are loaded entirely into memory
- Consider breaking down large operations
- Monitor backup storage accumulation
Enable detailed logging to diagnose issues:
RUST_LOG=debug cargo runThis project is licensed under the MIT License - see the LICENSE file for details.
- Anthropic for providing the Claude API
- Rust Community for excellent tooling and libraries
- Contributors to the open-source dependencies used in this project
- Documentation: Check the
specs/directory for detailed information - Issues: Report bugs and feature requests via GitHub issues
- Discussions: Use GitHub discussions for questions and ideas
Built with β€οΈ in Rust | Powered by Claude 4 | Made for Developers