Improve Anthropic code generation prompt
Copy of some tips how to improve Anthropic prompt we use for code generation suggested in this Slack thread:
-
[ ] You say " Here are a few examples" [you could delete the extra space there], but then only give one example. Best would be to give multiple examples. If not, you can rewrite to say "Here is an example".(multiple examples are used) -
If you do give multiple examples, you could use those to illustrate some of the rules 1-6, particularly the ones around the cursor being in the middle of a word. -
It should be return self.visibility == 'PUBLIC', right, not just self.visibility == 'PUBLIC'? -
Since you are not closing the XML tag, I wouldn't have it be an XML tag at all; instead, I'd probably use {{cursor}} (replacing through the whole of the prompt). -
I would dedent the entire block, meaning both the tags themselves, and the start of the content of the examples. Within the example code, you would continue to indent as is natural for the code. -
[nit] I'd say "best possible code." over "most likely code based on instructions." -
[nit] I'd change "most likely new code to generate" to "best code to generate" -
[nit] "any of already existing" -> "any of the already existing" -
8. [nit] I'd remove "by other autocomplete agents" -
9. I'd change "You are a coding autocomplete agent." to "You are a tremendously accurate and skilled coding autocomplete agent." -
10. This would be a bigger change, but have you considered/tried using CoT? -
11. I'm curious if you have a list of example[s] that you choose from dynamically based on similarity to the code prefix and suffix or if you always use the same one. Choosing dynamically would probably provide a boost.
Edited by Jan Provaznik