Useful "rules" for coding assistants

Coding assistants Cursor (and recently Copilot) accept rules to guide responses. I’ve read that coding assistant results can be greatly improved with well defined rules. To that end I’d like to dedicate this thread to Julia specific rules that people have found helpful so that others can benefit. If you have a list of helpful rules please share.

1 Like

Hi, can you provide some context, some links…, on what is a “rule” for the AI code assistants?

Custom rules provide context for LLM generated results in addition to what’s being provided by the coding assistant. It can be viewed as a form of prompt engineering. Examples for other languages can be found here

1 Like

When suggesting the final lines of a function, Copilot often suggests the beginning of a docstring for a hallucinated upcoming function. For example

function write_to_s3(io, path)
    bytes = take!(io) 
    write#=start suggestion here=#(path, bytes)
end

"""
    write_to_azure(io, path)
Put the bytes written to `io` #= end suggestion =#

"""
    my_real_function(x)
This is a docstring, but is no longer in a string because of the
bad copilot suggestion
"""

I don’t know if Copilot can accept rules, but it would be nice to be able to tell it to please not include docstrings in a suggestion that ends the function I’m currently editing.

1 Like