# Useful "rules" for coding assistants

**URL:** <https://discourse.julialang.org/t/useful-rules-for-coding-assistants/122868>\
**Category:** General Usage\
**Created:** [November 20, 2024, 7:40pm UTC](https://discourse.julialang.org/t/useful-rules-for-coding-assistants/122868 "2024-11-20T19:40:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-s-gardner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alex-s-gardner/32/30210_2.png) [@alex-s-gardner](https://discourse.julialang.org/u/alex-s-gardner)\
**Post date:** [November 20, 2024, 7:40pm UTC](https://discourse.julialang.org/t/useful-rules-for-coding-assistants/122868/1 "2024-11-20T19:40:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [November 20, 2024, 8:50pm UTC](https://discourse.julialang.org/t/useful-rules-for-coding-assistants/122868/2 "2024-11-20T20:50:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alex-s-gardner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alex-s-gardner/32/30210_2.png) [@alex-s-gardner](https://discourse.julialang.org/u/alex-s-gardner)\
**Post date:** [November 20, 2024, 9:23pm UTC](https://discourse.julialang.org/t/useful-rules-for-coding-assistants/122868/3 "2024-11-20T21:23:15Z")

</div>

Custom [rules](https://docs.cursor.com/context/rules-for-ai) 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](https://dotcursorrules.com/)

---

<div class="post-metadata">

**Author:** ![mrufsvold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrufsvold/32/31600_2.png) [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Post date:** [November 21, 2024, 3:52am UTC](https://discourse.julialang.org/t/useful-rules-for-coding-assistants/122868/4 "2024-11-21T03:52:34Z")

</div>

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

```julia
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.
