Giter VIP home page Giter VIP logo

doriandarko / claude-engineer Goto Github PK

View Code? Open in Web Editor NEW
7.1K 113.0 780.0 143 KB

Claude Engineer is an interactive command-line interface (CLI) that leverages the power of Anthropic's Claude-3.5-Sonnet model to assist with software development tasks. This tool combines the capabilities of a large language model with practical file system operations and web search functionality.

Python 100.00%

claude-engineer's Issues

Unable to view images

Typed image and dragged the file into terminal. Tried again by copying and pasting the file path:

"I apologize, but I'm unable to directly access or view images stored on your local machine. As an AI language model, I don't have the capability to access external files or images unless they are explicitly provided in the conversation."

Question about claude-engineer

Hello! ๐Ÿ˜Š I discovered your claude-engineer project while exploring trending python repositories. Awesome job! ๐ŸŽ‰ Could you send me more details on Telegram? Also, please review my work and follow me on GitHub @nectariferous. Thanks!

`create_file` should default to create parent dirs if missing

I've been getting this issue alot:

I apologize for the error. It seems the '<folder_name>' folder doesn't exist yet. Let's create it first and then add the <file_name> file.  

I think it would save on tokens and time if the create_file command created missing parent dirs by default.

Getting auth error running it

Just saw the youtube video. So I downloaded it. I got both APIs keys and added it. I tried a CURL sample from anthropic and using the key IT generated, it did work.

What am I missing?

Claude API: Error code: 401 - {'type': 'error', 'error': {'type': 'authentication_error', 'message': 'invalid x-api-key'}}

Double responses?

I am receiving double responses from the claude-engineer. What would be causing this?

Claude: I apologize, but I don't have any prior context or memory of what we were doing before. Each conversation with me starts fresh, and I don't retain information from previous interactions. Could you please provide more details about what you're referring to or what you'd like assistance with? I'd be happy to help if you can give me some more information about your current task or question.
I apologize, but I don't have any prior context or memory of what we were doing before. Each conversation with me starts fresh, and I don't retain information from previous interactions. Could you please provide more details about what you're referring to or what you'd like assistance with? I'd be happy to help if you can give me some more information about your current task or question.

Reset conversation history

Hi. Thanks for this project!

I've noticed that when using the tool for some time

  • it can accumulate context that is no longer useful, or decreases performance for later tasks
  • becomes increasingly expensive as the context window is lengthened

Suggestion: have a "reset" history command to clear the conversation history so far.

As a work around, I am currently exiting and restarting the tool.

pdf reading

When parsing a pdf document, It came up with this codec error.

Tool Input: {'path': '/economics/economics.pdf'} Tool Result: Error reading file: 'charmap' codec can't decode byte 0x81 in position 169: character maps to <undefined>

Is there any workaround? in the desktop app can easilly access pdfs.

Another similar error generating a markdown file with formulas:
Tool Result: Error creating file: 'charmap' codec can't encode character '\u03C0' in position 1706: character maps to <undefined>

[Feature Request] Use ollama or other APIs

Hi, thanks a lot for your work.

Do you think it could be possible to use ollama, deepseek, chatgpt or other APIs ?
It could be a great feature!

Thank you very much :)

RouteLLM

Dude RouteLLM! Decrease token usage. If you could integrate this, claude engineer would be much more powerful. <3

Chat Resume

Is there a way you could implement a chat resume feature in case the console closes or pc has a restart. This would be helpful for long sessions.

Modest & powerful

What you are refining here is quite amazing. I just used it to build an entire terraform Kubernetes stack with scaling systems and external interfacing with documentation. I found that incrementally adding and refining/refactoring is where I saw the potential but the cost definitely started increasing quickly as the context grew.

I'm sure sizing the memory window and strategy is something you're thinking about and looking forward to future iterations. It does get costly although relatively speaking $100 of API versus $10,000 for a consultant is still way better! In the meantime I find the differential logic is quite effective and better than I what I see with other tools, I wanted to let you know I ran into something a few times to consider for additional guardrailing. This is with the main branch about 3 hours prior to submitting this.

It did that thing where internally you expected the output to be a complete file but instead it returned the infamous: '# ... [rest of the XYZ remains unchanged] ...' blowing away the full content. I had to intervene with some prompt reinforcement and it did register:

You: I have manually repaired the variables.tf file you updated because with the fix you wiped out the unchanged content replacing it with a line that read  '# ... [rest of the variables file remains unchanged] ...' so please be careful to ensure any content being replace is complete when you are expecting to replace an entire file.
I sincerely apologize for that mistake. You're absolutely right, and I thank you for manually repairing the file. I will be much more careful in the future when updating files to ensure that all content is preserved when only partial changes are intended.

Given that you've manually repaired the `variables.tf` file, let's proceed with updating the `outputs.tf` file as we discussed earlier. I'll be extra cautious to ensure we're only adding or modifying the necessary parts without accidentally removing any existing content.

. . .

... a little later after a few more rounds ...

```sh
Certainly. I'll proceed with updating the `outputs.tf` file. First, let's read the current content of the file:Thank you for providing the current content of the `outputs.tf` file. I'll now update it with the changes we discussed, being careful to preserve existing content and only add or modify the necessary parts. Here's the updated `outputs.tf` file:

Add Continues Option

Right now you need to write something after every file creation but it should make the toole without user intervention.

roles must alternate between "user" and "assistant" error and rate limit

Hey I have experienced #18 too and I can reproduce it using the latest anthropic-sdk-python v0.30.0.

I have a suspicion that hitting the rate limit may cause 'found multiple "user" roles' error.

Reproducing the issue involves hitting the rate limit so it can be "resolved" magically. It also make it hard to debug and reproduce as we may hit the limit at arbitrary time.

Here is my closest attempt. I have hit the rate limit already, so the first message is rate_limit_error.

You: Create a new Python project structure for a web application
Error calling Claude API: Error code: 429 - {'type': 'error', 'error': {'type': 'rate_limit_error', 'message': 'Number of request tokens has exceeded your daily rate limit (https://docs.anthropic.com/en/api/rate-limits); see the response headers for current usage. Please reduce the prompt length or the maximum tokens requested, or try again later. You may also contact sales at https://www.anthropic.com/contact-sales to discuss your options for a rate limit increase.'}}
I'm sorry, there was an error communicating with the AI. Please try again.
Continuation iteration 1 completed.
Press Ctrl+C to exit automode.
Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'}}
I'm sorry, there was an error communicating with the AI. Please try again.
Continuation iteration 2 completed.
Press Ctrl+C to exit automode.
Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'}}
I'm sorry, there was an error communicating with the AI. Please try again.
Continuation iteration 3 completed.
Press Ctrl+C to exit automode. 

Replaced Sonnet with Haiku to work around the rate limit and tried again - everything worked fine:

python3 main.py
Welcome to the claude-3-haiku-20240307 Engineer Chat with Image Support!
Type 'exit' to end the conversation.
Type 'image' to include an image in your message.
Type 'automode [number]' to enter Autonomous mode with a specific number of iterations.
While in automode, press Ctrl+C at any time to exit the automode to return to regular chat.

You: automode 3
Entering automode with 3 iterations. Press Ctrl+C to exit automode at any time.
Press Ctrl+C at any time to exit the automode loop.

You: Create a new Python project structure for a web application

Claude: Okay, let's create a new Python project structure for a web application. Here's what I'll do:

<thinking>
To create a new Python project structure for a web application, I will use the create_folder and create_file tools. The required parameters are:
- path (string): The path where the folder/file should be created
The optional parameter is:
- content (string): The initial content of the file (only for create_file)

I have all the required information to complete this request, so I can proceed with the tool calls.
</thinking>

Tool Used: create_folder
Tool Input: {'path': 'my-web-app'}
Tool Result: Folder created: my-web-app

Claude: <thinking>
To create a Python project structure for a web application, I will need to create the following folders and files:

1. Root folder: 'my-web-app'
2. Subfolders:
   - 'app': Contains the main application code
   - 'templates': Contains HTML templates for the web pages
   - 'static': Contains static files like CSS, JavaScript, and images
   - 'tests': Contains unit tests for the application
3. Files:
   - 'app/__init__.py': This makes the 'app' folder a Python module
   - 'app/main.py': The main entry point of the application
   - 'requirements.txt': Lists the required Python packages for the project
   - 'README.md': Provides information about the project
</thinking>
Okay, let's create a new Python project structure for a web application. Here's what I'll do:

<thinking>
To create a new Python project structure for a web application, I will use the create_folder and create_file tools. The required parameters are:
- path (string): The path where the folder/file should be created
The optional parameter is:
- content (string): The initial content of the file (only for create_file)

I have all the required information to complete this request, so I can proceed with the tool calls.
</thinking><thinking>
To create a Python project structure for a web application, I will need to create the following folders and files:

1. Root folder: 'my-web-app'
2. Subfolders:
   - 'app': Contains the main application code
   - 'templates': Contains HTML templates for the web pages
   - 'static': Contains static files like CSS, JavaScript, and images
   - 'tests': Contains unit tests for the application
3. Files:
   - 'app/__init__.py': This makes the 'app' folder a Python module
   - 'app/main.py': The main entry point of the application
   - 'requirements.txt': Lists the required Python packages for the project
   - 'README.md': Provides information about the project
</thinking>
Continuation iteration 1 completed.
Press Ctrl+C to exit automode.

Claude: Okay, let's continue building the Python web application project structure.

Tool Used: create_folder
Tool Input: {'path': 'my-web-app/app'}
Tool Result: Folder created: my-web-app/app
Okay, let's continue building the Python web application project structure.
Continuation iteration 2 completed.
Press Ctrl+C to exit automode.

Tool Used: create_folder
Tool Input: {'path': 'my-web-app/templates'}
Tool Result: Folder created: my-web-app/templates

Claude: I've created the 'templates' folder within the 'my-web-app' root directory.
I've created the 'templates' folder within the 'my-web-app' root directory.
Continuation iteration 3 completed.
Press Ctrl+C to exit automode.
Max iterations reached. Exiting automode.
Exited automode. Returning to regular chat.

switching back to the rate limited Sonnet:

python3 main.py
Welcome to the Claude-3.5-Sonnet Engineer Chat with Image Support!
Type 'exit' to end the conversation.
Type 'image' to include an image in your message.
Type 'automode [number]' to enter Autonomous mode with a specific number of iterations.
While in automode, press Ctrl+C at any time to exit the automode to return to regular chat.

You: automode
Entering automode with 25 iterations. Press Ctrl+C to exit automode at any time.
Press Ctrl+C at any time to exit the automode loop.

You: create python web app for reporting on how many weeks Engineers were on-call this year in PagerDuty
Error calling Claude API: Error code: 429 - {'type': 'error', 'error': {'type': 'rate_limit_error', 'message': 'Number of request tokens has exceeded your daily rate limit (https://docs.anthropic.com/en/api/rate-limits); see the response headers for current usage. Please reduce the prompt length or the maximum tokens requested, or try again later. You may also contact sales at https://www.anthropic.com/contact-sales to discuss your options for a rate limit increase.'}}
I'm sorry, there was an error communicating with the AI. Please try again.
Continuation iteration 1 completed.
Press Ctrl+C to exit automode.
Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'}}
I'm sorry, there was an error communicating with the AI. Please try again.
Continuation iteration 2 completed.
Press Ctrl+C to exit automode.
Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'}}
I'm sorry, there was an error communicating with the AI. Please try again.

unexpected keyword argument 'tools'

I got this error:

Error calling Claude API: Messages.create() got an unexpected keyword argument 'tools'
I'm sorry, there was an error communicating with the AI. Please try again.

Tried using **kwargs and *args to solve. Not working.

Rate Limiting - Feature Request - use other models for basic questions?

Any change you can build in better handleing for rate limiting example below.
Error in tool response: Error code: 429 - {'type': 'error', 'error': {'type': 'rate_limit_error', 'message': 'Number of request tokens has exceeded your per-minute rate limit (https://docs.anthropic.com/en/api/rate-limits); see the response headers for current usage. Please reduce the prompt length or the maximum tokens requested, or try again later. You may also โ”‚
โ”‚ contact sales at https://www.anthropic.com/contact-sales to discuss your options for a rate limit increase.'}}

The tool can surely figure out the token parsed each time and then keep a running total of that and then slow its repsonses down.
I used Claude to modify the script to do this and it worked well.

In addition, i prompted a question up front to get the daily usage and establish if it ran alraedy that way it can stop when it knows the limit has been reached.

One other idea, im not sure if the rate limits are model specific but maybe the script can use different models for differnt functions, like basic checks can go to Haiku, document updates can go to Opus etc.. That way we can get better usage out of Sonnet 3.5 with the daily limit?

Missing Module?

python main.py
Traceback (most recent call last):
File "claude-engineer/main.py", line 12, in
from PIL import Image
ModuleNotFoundError: No module named 'PIL'

I'm getting this error when trying to run the file

Thanks

# ... (keep the existing code)

The Claude response of "keep code" is presented and this will remove (working) existing code and delete any previously generated code. I've seen this with manual programming also.

Fix proposed: https://x.com/spatialweeb/status/1809835604131344859

First, please analyze the current flow and identify any incorrect or incomplete code. Make sure that everything is correct and makes sense.
Then, suggest the changes and requirements.
Finally, write out the complete code (complete classes and functions) for the parts that need to be updated. Do NOT use "..." as it is not helpful. You need to be complete and write out the entire response.

Error in tool response: Error code: 429 - {'type': 'error', 'error': {'type': 'rate_limit_error', 'message': 'Number of request tokens has exceeded your per-minute rate limit                            
(https://docs.anthropic.com/en/api/rate-limits); see the response headers for current usage. Please reduce the prompt length or the maximum tokens requested, or try again later. You may also contact    
sales at https://www.anthropic.com/contact-sales to discuss your options for a rate limit increase.'}}                                                                                                    

You: 
API Error 
Rate limit exceeded. Retrying after a short delay...
API Error 
Rate limit exceeded. Retrying after a short delay...    

Tool Used: edit_and_apply           
Tool Input:      <i've removed the code for visibility>
# ... (keep the existing code for generating the report)
# ... (keep the existing imports and setup code)
# ... (keep the existing code)
# ... (keep the rest of the file unchanged)

Then this happened:

Tool Result
โ”‚ Changes applied to telegram_bot/main.py:                                                                                                                                                                  โ”‚
โ”‚ Changes applied to telegram_bot/main.py:                                                                                                                                                                  โ”‚
โ”‚   Lines added: 52                                                                                                                                                                                         โ”‚
โ”‚   Lines removed: 236    

Here some details right after the Tool Result:

Error 
โ”‚ Error in tool response: Error code: 429 - {'type': 'error', 'error': {'type': 'rate_limit_error', 'message': 'Number of request tokens has exceeded your per-minute rate limit                            โ”‚
โ”‚ (https://docs.anthropic.com/en/api/rate-limits); see the response headers for current usage. Please reduce the prompt length or the maximum tokens requested, or try again later. You may also contact    โ”‚
โ”‚ sales at https://www.anthropic.com/contact-sales to discuss your options for a rate limit increase.'}}     
                                                                                              
You: 
API Error 
โ”‚ API Error: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.62: all messages must have non-empty content except for the optional final assistant       โ”‚
โ”‚ message'}}                                                                                                                                                                                                โ”‚

You: 
API Error
โ”‚ Rate limit exceeded. Retrying after a short delay...
API Error 
โ”‚ Rate limit exceeded. Retrying after a short delay...
API Error 
โ”‚ Rate limit exceeded. Retrying after a short delay...
API Error 
โ”‚ Rate limit exceeded. Retrying after a short delay...
API Error 
โ”‚ Rate limit exceeded. Retrying after a short delay... 

litellm integration to use deepseek-coder-v2?

Do you have any plans to use litellm like in maestro so that we can use different more cost effective llms? im wondering because id like to try this out with deepseek's new deepseek-coder-v2 llm.

Rate limiter

Hi,

thanks for great work. I'm not yet sure if to be scared or amazed of this software! Litte bit of both I guess.

I've had issue that I've put iteration to 100 and at 28 I hit rate limiter. On the https://console.anthropic.com/ rate limits page it's says 50 for all models. From the docs I see it's actually depending on something called tier https://docs.anthropic.com/en/api/rate-limits

So I think one solution would be pause when 429 error code is hit and wait for 1 minute. Then measure how many requests were done in last minute and figure what's the rate limit for user. On next round when it's hitting the limit, wait with last request so that minute is over.

Optionally user could set their limit in config (.env file?)

image

Save Chat Logs

It would be nice to add a feature that saves the chat log at the end of a session.

Unable to Read Certain HTML Files

UPDATE

I was able to fix the issue by modifying the function to read the file, tool definition, and tool execution on my end. Claude-engineer can now specify encoding. Sorry, I don't know git and i don't know how to do a pull request. Changes are described in the code block below. Thanks to claude-engineer for helping me find this solution.

# Function to read a file with optional encoding
def read_file(path, encoding=None):
    try:
        with open(path, 'r', encoding=encoding) as f:
            content = f.read()
        return content
    except Exception as e:
        return f"Error reading file: {str(e)}"


# Define the tools
tools = [
    {
        "name": "read_file",
        "description": "Read the contents of a file at the specified path with optional encoding. Use this when you need to examine the contents of an existing file.",
        "input_schema": {
            "type": "object",
            "properties": {
                "path": {
                    "type": "string",
                    "description": "The path of the file to read"
                },
                "encoding": {
                    "type": "string",
                    "description": "The encoding to use when reading the file (e.g., 'utf-8', 'ascii', 'latin-1'). If not specified, the default system encoding will be used.",
                },
            },
            "required": ["path"]
        }
    },
]

# Function to execute tools (updated read_file only)
def execute_tool(tool_name, tool_input):
    elif tool_name == "read_file":
        return read_file(tool_input["path"], tool_input.get("encoding"))

Description

The AI assistant is unable to read certain HTML files, specifically one named "turing-test-interactive-html.zip". This prevents the assistant from viewing and modifying the contents of the file as requested. The HTML file in question was produced as an artifact at Claude.ai, and opening such files is likely a common use case for the assistant.

Steps to Reproduce

  1. Place turing-test-interactive-html.zip in the root directory where the AI assistant has access.
  2. Instruct the AI assistant to read and modify the contents of this file.
  3. Observe that the assistant encounters an error when attempting to read the file.

Expected Behavior

The AI assistant should be able to read the contents of the HTML file without any errors, allowing it to analyze and modify the code as needed. This is particularly important for artifact files generated by Claude.ai, as working with these files is a common and expected use case for the assistant.

Actual Behavior

When attempting to read the file, the assistant encounters the following error:

Error reading file: 'charmap' codec can't decode byte 0x8d in position 3517: character maps to <undefined>

Additional Information

  • The error suggests an encoding issue with the file.
  • The assistant attempted to read the file using its default encoding method.
  • A second attempt to read the file with explicit encoding specification was not successful.
  • The file was generated by Claude.ai, which may use a specific encoding or include special characters that the current file reading mechanism cannot handle.

Possible Solutions to Investigate

  1. Implement a more robust file reading mechanism that can handle various file encodings, especially those used by Claude.ai.
  2. Add error handling to gracefully manage file reading issues and provide more informative error messages.
  3. Implement a feature to attempt reading files with multiple common encodings (UTF-8, UTF-16, ISO-8859-1, etc.) if the initial attempt fails.
  4. Coordinate with the Claude.ai team to understand the encoding and format of the files they generate, and ensure compatibility.

Impact

This bug significantly limits the assistant's ability to work with certain HTML files, particularly those generated by Claude.ai. This affects tasks related to web development, code analysis, and file modifications, and hinders the assistant's ability to seamlessly work with artifacts from its own ecosystem.

Given that working with Claude.ai-generated files is likely a common use case, resolving this issue is crucial for maintaining the assistant's functionality and user experience.

Feature: virtual Python environment

Setting up a virtual Python environment is best practice to avoid issues with conflicting dependencies and would make it more user-friendly to run and get started, especially for beginners.

I created a PR for this here:

No code_execution_requirements.txt file

Trying to follow these instructions in the README in the repo:

Step 4: ....

python -m venv code_execution_env
source code_execution_env/bin/activate # On Windows, use: code_execution_env\Scripts\activate
pip install -r code_execution_requirements.txt
deactivate

But there is no file code_execution_requirements.txt in the files I cloned from the repo.

A visual refresh | display_token_usage()

image

def display_token_usage():
    console = Console()

    table = Table(box=box.ROUNDED)
    table.add_column("Model", style="cyan")
    table.add_column("Input", style="magenta")
    table.add_column("Output", style="magenta")
    table.add_column("Total", style="green")
    table.add_column("% of Context", style="yellow")
    table.add_column("Cost ($)", style="red")

    total_input = 0
    total_output = 0
    grand_total = 0
    total_cost = 0

    for model, tokens in [
        ("Main Model", main_model_tokens),
        ("Tool Checker", tool_checker_tokens),
        ("Code Editor", code_editor_tokens),
        ("Code Execution", code_execution_tokens),
    ]:
        total = tokens["input"] + tokens["output"]
        percentage = (total / MAX_CONTEXT_TOKENS) * 100
        input_cost = (tokens["input"] / 1_000_000) * 3.00
        output_cost = (tokens["output"] / 1_000_000) * 15.00
        model_cost = input_cost + output_cost

        total_input += tokens["input"]
        total_output += tokens["output"]
        grand_total += total
        total_cost += model_cost

        table.add_row(
            model,
            str(tokens["input"]),
            str(tokens["output"]),
            str(total),
            f"{percentage:.2f}%",
            f"${model_cost:.3f}",
        )

    total_percentage = (grand_total / MAX_CONTEXT_TOKENS) * 100

    table.add_row(
        "Total",
        str(total_input),
        str(total_output),
        str(grand_total),
        f"{total_percentage:.2f}%",
        f"${total_cost:.3f}",
        style="bold",
    )

    console.print(table)

    summary_panel = Panel(
        f"[bold]Total Input Tokens:[/bold] {total_input:,}\n"
        f"[bold]Total Output Tokens:[/bold] {total_output:,}\n"
        f"[bold]Grand Total Tokens:[/bold] {grand_total:,}\n"
        f"[bold]Context Window Usage:[/bold] {total_percentage:.2f}%\n"
        f"[bold]Total Cost:[/bold] ${total_cost:.3f}",
        title="Token Usage Summary",
        border_style="blue",
    )

    console.print(summary_panel)

Pietro Schirano what do you think about this?

invalid_request_error: 'Your API request included an `assistant` message in the final position, which would pre-fill the `assistant` response. When using tools, pre-filling the `assistant` response is not supported.'

Hello,
I'm testing the software and I'm getting a lot of these errors:

You: Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'Your API request included an `assistant` message in the final position, which would pre-fill the `assistant` response. When using tools, pre-filling the `assistant` response is not supported.'}}
I'm sorry, there was an error communicating with the AI. Please try again.

Paid account

Dem

Improve process for generating and integrating large codebases with Claude

This issue addresses the limitations of Claude's code generation capabilities for large files and proposes solutions to improve the process.

Claude's output is limited to 4096 tokens. Considering text that is added to the code output, this means that Claude is very limited in its ability to output complete files which are longer than 250 lines, and instead Claude tends to return partial, incomplete files, with comments like "// ... rest of the file remains unchanged".

When users try to combine or integrate these partial outputs into a complete codebase, they often encounter errors or issues due to inconsistencies between different parts of the code generated in separate responses, missing context or dependencies when code is generated in isolation and human error in the process of combining these partial outputs. For me, the diff feature did not solve the issue.

In my attempts to address the issue, I use two methods that I found to be useful and I'm now happy to share them.
First, I use line numbers. I do that by adding line numbers in the read_files tool, and requiring Claude to include those line numbers in its output (both in the files he provides and in the explanations).
Here are the relevant lines (btw note the encoding="utf-8" which is important sometimes):

# adding line numbers in read_files tool
with open(path, "r", encoding="utf-8") as f:
    file_content = f.read()
    lines = file_content.splitlines()
    # Add line numbers and format the content
    numbered_lines = [f"{i+1:4d}  {line}" for i, line in enumerate(lines)]
    ...

This little trick is helpful, but far from enough. What really was a game changer for me was the next trick, which is to split my project files to code sections of up to 200 lines each. For example, if my python file is 700 lines, I split the same file to 4 sections by including commented <SECTION> tags in the file:

# <SECTION 1>
# .... code for section 1... (lines 2- 180)
# </SECTION 1>
# <SECTION 2>
# .... code for section 2... (lines 184- 350)
# </SECTION 2>
etc...

Then I require Claude to provide full code sections, a single section in each file it saves using the create_file tool. I don't give him the option to use write_to_file or edit_and_apply tools, but only the 'create_file' tool.
I found that this makes the integration of the changes made by Claude much easier and less error prone.
To make it work well, I'm shameful to admit that I needed to kind of "threaten" Claude that if it will not respect these rules I will reject and ignore his work. This is the suffix I append to any prompt before the call to chat_with_claude :
"""
REMEMBER! \n --- before starting to work on your task it's important that you will read again and follow your Rules of Conduct.\n
If you do not include the full content of code sections in the file you create - your work will be rejected and ignored! \n
If you include comments in the file like "// ... rest of the file remains unchanged" - your work will be rejected and ignored! \n
If you include more than a single code section in a single file - your work will be rejected and ignored! \n
Please just follow the Rules of Conduct, and we will be happy with your work.
"""

Hope you all find it useful, and cheers to Pietro - great work!

roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'

You: automode
Entering automode. Please provide your request.

You: create a web ecommerce store with home and PLP
Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'}}
I'm sorry, there was an error communicating with the AI. Please try again.
Continuation iteration 1 completed.
Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'}}
I'm sorry, there was an error communicating with the AI. Please try again.
Continuation iteration 2 completed.
Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'}}
I'm sorry, there was an error communicating with the AI. Please try again.
Continuation iteration 3 completed.
Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "user" roles in a row'}}

SyntaxWarning: invalid escape sequence '\<'

I get this warning when running python3 main.py

(venv) parker@PxB-MBP-16 claude-engineer % python3 main.py                
/Users/parker/claude-engineer/main.py:34: SyntaxWarning: invalid escape sequence '\<'
  system_prompt = """

Unexpected response repetition

claude-repeat-1
claude-repeat-2

I have no clue why this is happening just yet and from the looks of it Claude either doesn't know why its happening or that it's happening. If I discover something I will update.

Claude Engineer became acustic

Almost any action it attempts, ends up in failure...
image
image
image

It all started when it was unable to read the file because of encoding? so I fixed that read_file function to include encoding="UTF-8"
so it read the file fine, but now it's unable to do anything... did it became acoustic? was it nerfed?

Expensive

Just did a small application and it $.66 - that is crazy expensive. Can we use other cheaper models?

Question

Hey
What is the difference between Claude engineer and maestro
Can I use them for developing mid size business apps

regards

Unexpected keyword "Tools" Issue

I am getting the same issue each time I run it.
It keeps on showing :-
Error calling Claude API: Messages.create() got an unexpected keyword argument 'tools'
I'm sorry, there was an error communicating with the AI. Please try again.

Broke with first prompt asked.

Certainly! I'll create a simple Rust application that runs a given command in the current directory and all its subdirectories. This application will be runnable as an executable without any external dependencies. Let's break this down into steps:

  1. Create a new Rust project
  2. Write the main.rs file with the required functionality
  3. Build and test the application

Let's start by creating a new Rust project:

To create a new Rust project, we need to use the `create_folder` tool to create a project directory, and then use the `create_file` tool to create the main.rs file. We'll name our project "recursive_command_runner". To create a simple Rust application that runs a given command in the current directory and all its subdirectories, we'll need to create a new Rust project and implement the required functionality. Let's start by creating the necessary files for our Rust project.

You: Go ahead. Complete the exercise.

Tool Used: create_file
Tool Input: {'path': 'recursive_command_runner/src/main.rs', 'content': 'use std::env;\nuse std::fs;\nuse std::path::Path;\nuse std::process::Command;\n\nfn main() {\n let args: Vec = env::args().collect();\n if args.len() < 2 {\n eprintln!("Usage: {} ", args[0]);\n std::process::exit(1);\n }\n\n let command = &args[1..].join(" ");\n let current_dir = env::current_dir().expect("Failed to get current directory");\n\n run_command_recursively(&current_dir, command);\n}\n\nfn run_command_recursively(dir: &Path, command: &str) {\n println!("Executing in: {}", dir.display());\n\n // Run the command in the current directory\n let output = Command::new("sh")\n .arg("-c")\n .arg(command)\n .current_dir(dir)\n .output()\n .expect("Failed to execute command");\n\n println!("Output:");\n println!("{}", String::from_utf8_lossy(&output.stdout));\n eprintln!("{}", String::from_utf8_lossy(&output.stderr));\n\n // Recursively run the command in subdirectories\n if let Ok(entries) = fs::read_dir(dir) {\n for entry in entries {\n if let Ok(entry) = entry {\n let path = entry.path();\n if path.is_dir() {\n run_command_recursively(&path, command);\n }\n }\n }\n }\n}'}
Tool Result: Error creating file: [Errno 2] No such file or directory: 'recursive_command_runner/src/main.rs'

Duplicate output for web search

Claude Engineer prints answer twice after being asked what specific site is about:

You: tell me what is github.com about                                                                                                                                                                                                        
Claude: Certainly! I'll search for information about github.com for you.

Tool Used: tavily_search
Tool Input: {'query': 'What is github.com about?'}
Tool Result: GitHub is a web-based platform used for version control and collaboration on software development projects. It offers features such as code hosting, project management, and team collaboration tools. In 2018, Microsoft acquired GitHub for US$7.5 billion. GitHub also provides free education bundles to schools and offers services like GitHub Pages for web hosting.

Claude: Thank you for asking about GitHub. I'll provide you with information based on the search results and my knowledge about the platform.

GitHub (github.com) is a widely-used web-based platform that plays a crucial role in software development and collaboration. Here are the key points about GitHub:

1. Version Control: GitHub is primarily used for version control, allowing developers to track changes in their code over time and collaborate on projects efficiently.

2. Collaboration Platform: It provides a space for developers to work together on projects, regardless of their physical location. This makes it ideal for both open-source and private development projects.

3. Code Hosting: GitHub hosts millions of repositories containing source code, documentation, and other project-related files.

4. Project Management: The platform offers various tools for project management, including issue tracking, pull requests, and project boards.

5. Team Collaboration: GitHub facilitates team collaboration through features like code reviews, discussions, and team management tools.

6. Microsoft Acquisition: In 2018, Microsoft acquired GitHub for US$7.5 billion, though GitHub continues to operate independently.

7. Educational Support: GitHub provides free education bundles to schools, supporting computer science education and fostering the next generation of developers.

8. Web Hosting: Through GitHub Pages, users can host websites directly from their GitHub repositories, which is particularly useful for project documentation or personal sites.

9. Community: GitHub hosts a large community of developers and is home to numerous open-source projects, making it a hub for knowledge sharing and collaboration in the tech world.

10. Integration: It integrates with many other development tools and services, making it a central part of many developers' workflows.

GitHub has become an essential tool in the software development ecosystem, used by individual developers, small teams, large corporations, and open-source projects alike. Its combination of version control, collaboration features, and large community has made it a go-to platform for code management and software project collaboration.
Certainly! I'll search for information about github.com for you.Thank you for asking about GitHub. I'll provide you with information based on the search results and my knowledge about the platform.

GitHub (github.com) is a widely-used web-based platform that plays a crucial role in software development and collaboration. Here are the key points about GitHub:

1. Version Control: GitHub is primarily used for version control, allowing developers to track changes in their code over time and collaborate on projects efficiently.

2. Collaboration Platform: It provides a space for developers to work together on projects, regardless of their physical location. This makes it ideal for both open-source and private development projects.

3. Code Hosting: GitHub hosts millions of repositories containing source code, documentation, and other project-related files.

4. Project Management: The platform offers various tools for project management, including issue tracking, pull requests, and project boards.

5. Team Collaboration: GitHub facilitates team collaboration through features like code reviews, discussions, and team management tools.

6. Microsoft Acquisition: In 2018, Microsoft acquired GitHub for US$7.5 billion, though GitHub continues to operate independently.

7. Educational Support: GitHub provides free education bundles to schools, supporting computer science education and fostering the next generation of developers.

8. Web Hosting: Through GitHub Pages, users can host websites directly from their GitHub repositories, which is particularly useful for project documentation or personal sites.

9. Community: GitHub hosts a large community of developers and is home to numerous open-source projects, making it a hub for knowledge sharing and collaboration in the tech world.

10. Integration: It integrates with many other development tools and services, making it a central part of many developers' workflows.

GitHub has become an essential tool in the software development ecosystem, used by individual developers, small teams, large corporations, and open-source projects alike. Its combination of version control, collaboration features, and large community has made it a go-to platform for code management and software project collaboration.

Maintain external state

Iโ€™m having an issue where I quickly run out of tokens. This is fine, as Iโ€™m not in a rush, but it means the session dies and I have to recreate it later. Is there a way to capture state of the system - what was done, what is being worked on, etc. externally so that when I restart, we can recover most/all?

Output hit Content Filter

grafik

Tool Used: create_file
Tool Input: {'path': 'tetris-game/style.css', 'content': 'body {\n font-family: Arial, sans-serif;\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100vh;\n margin: 0;\n background-color: #f0f0f0;\n}\n\n.game-container {\n display: flex;\n gap: 20px;\n}\n\ncanvas {\n border: 2px solid #000;\n background-color: #fff;\n}\n\n.game-info {\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n\nbutton {\n margin-top: 10px;\n padding: 10px;\n font-size: 16px;\n cursor: pointer;\n}'}
Tool Result: File created: tetris-game/style.css
Error in tool response: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'Output blocked by content filtering policy'}}
Certainly! Let's create the CSS file for styling our Tetris game.
I encountered an error while processing the tool result. Please try again

Assistant position

Hello and thanks for a great tool. When using the newest version I get this:
You: Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'Your API request included an assistant message in the final position, which would pre-fill the assistant response. When using tools, pre-filling the assistant response is not supported.'}}

Error calling Claude API

Here is the issue in automode:

Error calling Claude API: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.126: all messages must have non-empty content except for the optional final assistant message'}}
I'm sorry, there was an error communicating with the AI. Please try again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.