Claude Engineer is an advanced interactive command-line interface (CLI) that harnesses the power of Anthropic's Claude 3 and Claude 3.5 models to assist with a wide range of software development tasks. This tool seamlessly combines the capabilities of state-of-the-art large language models with practical file system operations, web search functionality, intelligent code analysis, and execution capabilities.
- 💬 Interactive chat interface with Claude 3 and Claude 3.5 models
- 📁 Comprehensive file system operations (create folders, files, read/write files)
- 🔍 Web search capabilities using Tavily API for up-to-date information
- 🌈 Enhanced syntax highlighting for code snippets
- 🏗️ Intelligent project structure creation and management
- 🧐 Advanced code analysis and improvement suggestions
- 🖼️ Image analysis capabilities with support for drag and drop in the terminal
- 🚀 Improved automode for efficient autonomous task completion
- 🔄 Robust iteration tracking and management in automode
- 📊 Precise diff-based file editing for controlled code modifications
- 🛡️ Enhanced error handling and detailed output for tool usage
- 🎨 Color-coded terminal output using Rich library for improved readability
- 🔧 Detailed logging of tool usage and results
- 🔁 Improved file editing workflow with separate read and apply steps
- 🧠 Dynamic system prompt updates based on automode status
- 🔍 TOOLCHECKERMODEL for validating tool usage and outputs
- 📝 CODEEDITORMODEL for specialized code editing tasks
- 🖥️ CODEEXECUTIONMODEL for analyzing code execution results
- 📊 Token usage tracking (input, output, and total) for each model
- 🪟 Remaining context window display
- 💾 Chat log saving capability
- 🔒 Enhanced code execution capabilities with isolated virtual environment
- 🔄 Process management for long-running code executions
-
Clone this repository:
git clone https://github.com/doriandarko/claude-engineer.git cd claude-engineer
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up your environment variables:
- Create a
.env
file in the project root directory - Add the following environment variables:
ANTHROPIC_API_KEY=your_anthropic_api_key TAVILY_API_KEY=your_tavily_api_key
- Create a
-
Set up the virtual environment for code execution: Engineer will create a virtual environment to run code the first time it executes a piece of code. This is just for you if you want to run the main script in a virtual environment rather than in your default one.
python -m venv code_execution_env source code_execution_env/bin/activate # On Windows, use: code_execution_env\Scripts\activate pip install -r requirements.txt deactivate
Run the main script to start the Claude Engineer interface:
python main.py
Once started, you can interact with Claude Engineer by typing your queries or commands. Some example interactions:
- "Create a new Python project structure for a web application"
- "Explain the code in file.py and suggest improvements"
- "Search for the latest best practices in React development"
- "Help me debug this error: [paste your error message]"
- "Analyze this image and describe its contents"
- "Execute this Python code and analyze the results"
Special commands:
- Type 'exit' to end the conversation and close the application.
- Type 'image' to include an image in your message for analysis.
- Type 'reset' to reset the entire conversation without restarting the script.
- Type 'automode number' to enter Autonomous mode with a specific number of iterations.
- Type 'save' to save the current chat log.
- Press Ctrl+C at any time to exit the automode and return to regular chat.
After each interaction, Claude Engineer will display:
- Token usage (input, output, and total) for the current model
- Remaining context window size
Claude Engineer now supports executing code in an isolated virtual environment:
- Use the
execute_code
tool to run Python code safely. - Long-running processes can be managed using the
stop_process
tool. - The CODEEXECUTIONMODEL analyzes execution results and provides insights.
Claude Engineer utilizes multiple specialized AI models:
- MAINMODEL: Claude 3 or Claude 3.5 for general interactions
- TOOLCHECKERMODEL: Validates tool usage and outputs
- CODEEDITORMODEL: Performs specialized code editing tasks
- CODEEXECUTIONMODEL: Analyzes code execution results
The script automatically selects the appropriate model based on the task.
The enhanced automode allows Claude to work autonomously on complex tasks with greater efficiency and control. When in automode:
- Claude sets clear, achievable goals based on your request.
- It works through these goals one by one, using available tools as needed.
- Claude provides regular updates on its progress, including the current iteration count.
- Automode continues until goals are completed or the maximum number of iterations is reached.
- You can specify the maximum number of iterations when entering automode (default is 25).
- Claude dynamically adjusts its approach based on progress and obstacles encountered.
- The TOOLCHECKERMODEL validates tool usage and outputs for increased reliability.
To use automode:
- Type 'automode number' when prompted for input, where number is the maximum number of iterations.
- Provide your request when prompted.
- Claude will work autonomously, providing updates after each iteration.
- Automode exits when the task is completed, after reaching the maximum number of iterations, or when you press Ctrl+C.
Claude Engineer now supports an improved diff-based file editing system, allowing for more precise and controlled modifications to existing files. The new workflow includes:
- Reading the entire content of a file using the
edit_and_apply
function without providing new content. - Applying changes to the file using the
edit_and_apply
function with new content, which shows a detailed diff of the proposed changes. - Utilizing the CODEEDITORMODEL for specialized code editing tasks, ensuring high-quality modifications.
When editing files, Claude will:
- Show a detailed diff of the proposed changes, highlighting additions, removals, and unchanged lines with color coding using the Rich library.
- Focus on adding new code or modifying existing code without unnecessarily removing functionality.
- Provide a summary of lines added and removed.
- Apply changes carefully to avoid duplicates and unwanted replacements.
- Support various editing scenarios, including targeted changes, appending content, inserting at the beginning, and replacing entire file contents.
- Use the CODEEDITORMODEL to ensure code changes adhere to best practices and maintain consistency.
This feature enhances Claude's ability to make targeted improvements to your codebase while maintaining the integrity of existing functionality.
The system prompt is now dynamically updated based on whether the script is in automode or not. This allows for more tailored instructions and behavior depending on the current operating mode:
- In regular mode, Claude focuses on providing helpful responses and using tools as needed.
- In automode, Claude is instructed to work autonomously, set goals, and provide regular updates on progress.
- The system prompt adapts to the specific task at hand, optimizing Claude's performance for each scenario.
The dynamic system prompt enhances Claude's ability to adapt to different scenarios and provide more relevant assistance.
Claude Engineer comes with a set of powerful tools to assist with various tasks:
- create_folder: Create a new folder at a specified path.
- create_file: Create a new file at a specified path with content.
- edit_and_apply: Read the contents of a file, and optionally apply changes.
- read_file: Read the contents of a file at the specified path.
- list_files: List all files and directories in the specified folder.
- tavily_search: Perform a web search using Tavily API to get up-to-date information.
- execute_code: Run Python code in an isolated virtual environment.
- stop_process: Manage and stop long-running code executions.
- TOOLCHECKERMODEL: Validate tool usage and outputs for increased reliability.
- CODEEDITORMODEL: Perform specialized code editing tasks with high precision.
- CODEEXECUTIONMODEL: Analyze code execution results and provide insights.
These tools allow Claude to interact with the file system, manage project structures, gather information from the web, perform advanced code editing, and execute code safely.
Claude Engineer now supports image analysis capabilities. To use this feature:
- Type 'image' when prompted for input.
- Drag and drop your image file into the terminal or provide the file path.
- Provide a prompt or question about the image.
- Claude will analyze the image and respond to your query.
This feature enables Claude to assist with tasks involving visual data, such as analyzing diagrams, screenshots, or any other images relevant to your development work.
Claude Engineer implements robust error handling and recovery mechanisms:
- Graceful handling of API errors and network issues.
- Automatic retries for transient failures.
- Clear error messages and suggestions for user action when needed.
- Logging of errors for debugging and improvement purposes.
- Ability to recover and continue operation after non-critical errors.
- Safe termination of long-running processes when needed.
These features ensure a smooth and reliable user experience, even in the face of unexpected issues or complex code executions.
You can save the current chat log at any time during your interaction with Claude Engineer:
- Type 'save' when prompted for input.
- The chat log will be saved to a file in the current directory with a timestamp in the filename.
- You can review these logs later for reference or to continue previous conversations.
Claude Engineer utilizes multiple AI models to provide specialized functionality:
- MAINMODEL (Claude 3 or Claude 3.5): Handles general interactions and task processing.
- TOOLCHECKERMODEL: Validates the usage and outputs of various tools to ensure reliability.
- CODEEDITORMODEL: Specializes in code editing tasks, ensuring high-quality modifications.
- CODEEXECUTIONMODEL: Analyzes the results of code executions and provides insights.
These models work together to provide a comprehensive and intelligent development assistance experience.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.