| ▲ | minimaxir 5 hours ago |
| One trick I've found that works well is to tell it to refactor, e.g for Python: Refactor the Python code to make it more Pythonic, e.g. fewer classes/singletons, especially if it will provide a speedup. The Python code **MUST** follow code organization standards expected of popular open-source Python packages code without causing any benchmark performance regressions.
A variant I've used for Rust code: The Rust codebase in `/src` has become bloated with several files >1k LoC. Refactor the Rust codebase to fit code organization standards expected of popular open-source Rust code without causing any benchmark performance regressions.
Those types of prompts appear to a) reorganize the code logically and b) do seem to get better performance from the agents because the file names now provide semantic hints to where relevant code resides. For bloated 5k LoC files, the agent has to Read several chunks to find relevant code which is inefficient.In terms of benchmark performance it generally improves after the refactor which I suspect is coincidental (especially in Rust where it shouldn't matter due to compiling) but I'm not complaining. |
|
| ▲ | woggy 3 hours ago | parent | next [-] |
| Asking it to apply the YAGNI principle also sems to work well for trimming codebases down. Generally ask it to review, generate a list of review points, then we go through each one together and I make a decision yes/no on each one (or suggest further modifications). |
|
| ▲ | loremium 4 hours ago | parent | prev | next [-] |
| the word your looking for is idiomatic |
| |
| ▲ | bckr 3 hours ago | parent | next [-] | | Yes and Pythonic is the Pythonic word for idiomatic | |
| ▲ | minimaxir 2 hours ago | parent | prev | next [-] | | Pythonic is a specific type of idiomatic; it never hurts to be overly specific with modern agents. Also, as evident from the different tones in these two prompts, my prompts are often freeform. | |
| ▲ | kelnos 3 hours ago | parent | prev [-] | | The word you are looking for is "you're". (Can we not play language police? It's boring and doesn't lead to interesting discussion.) | | |
| ▲ | dprkh an hour ago | parent [-] | | I think in this context it is actually important to share exact wording that causes the AI to perform well. My favorite is "Do not use your own knowledge." |
|
|
|
| ▲ | hatefulheart 3 hours ago | parent | prev | next [-] |
| Have you tried telling it: “Write perfect code, make no mistakes” I use this one in my Ralph Harness all the time, it’s a classic! It’s not that it can’t do that, it’s just that you haven’t told it to! |
| |
| ▲ | minimaxir 2 hours ago | parent [-] | | That's not what this is. Refactors are necessary because LLMs tend to bloat even with controls against it, but it's ok to make mistakes if they can be easily fixed. | | |
| ▲ | hatefulheart 2 hours ago | parent [-] | | So wait you’ve told it not to make any mistakes or you haven’t? Seems like you’re missing this one easy trick! It’s not about making mistakes, it’s about telling it not to make mistakes! |
|
|
|
| ▲ | cpill 5 hours ago | parent | prev [-] |
| yeah, me too. I usually ask it to do a code review using SOLID standards and it usually does a good job, if not a little overkill sometimes. |