13
3w
2

Good practice with coding: ask the LLM to audit and refactor the code at the end

(Going to make a bunch of posts over the next day or so to start populating this new community)

When you're at the end of your project and it's mostly coded, it's worth sending a prompt styled something like:

Let's do a final, full audit of the code before shipping. Identify and fix any lingering bugs, possible edge cases and error handling. Optimize and refactor the code for function logic, resource usage, and general performance. [Optional: Write a Audit.md file to document what you found and did during this audit]

It will be very comprehensive and most likely redo a lot of the code which could be problematic (this is why you keep backups!), but it also usually finds stuff to fix or handle. Sometimes you end up with fewer lines in the code than you started with.

percyraskova - 3w

You can actually implement a lot of this using static analysis and linting tools to guarantee a consistent output. You have the right idea but for something like linting and formatting IMO it is better to have a static analysis tool that gives you the same result every single time. Turn it into a pre commit hook to ensure consistency of code and taht your LLM agent stays on track. But you got the right idea.

Great for Python projects

3
CriticalResist8 - 3w

Looks cool! Yeah feel free to share, the point is to learn from each other 😎

3