|
1 | | -# Running LLMs |
| 1 | +# Working with LLMs |
2 | 2 |
|
3 | 3 | This is a non-binding list of suggestions for working with LLMs. |
4 | 4 | This is not our moderation policy; see [Forge][LLM policy]. |
5 | 5 |
|
6 | | -## Review bots |
| 6 | +[LLM policy]: https://forge.rust-lang.org/policies/llm-usage.html |
| 7 | + |
| 8 | +## Automated checks and LLM review |
7 | 9 |
|
8 | 10 | - If a more reliable tool, such as a linter or formatter, already exists for the language you're writing, we strongly suggest using that tool instead of or in addition to the LLM. |
9 | 11 | - Configure LLM review tools to reduce false positives and excessive focus on trivialities, as these are common, exhausting failure modes. |
10 | 12 | - Wherever possible, ask an LLM to *generate a linter*, which you then tell it to run. |
11 | 13 | This both saves on token costs, and allows people who are not using an LLM to run the analysis. |
12 | | -- Note that LLMs sometimes demonstrate a preference for LLM output, particularly output from the same model. |
| 14 | +- LLMs sometimes prefer LLM-generated output, particularly output from the same |
| 15 | + model. Treat LLM review as advisory, and do not rely on the model that |
| 16 | + produced a change as its only reviewer. |
13 | 17 |
|
14 | | -## LLM-authored code |
| 18 | +## Writing LLM-created code |
15 | 19 |
|
16 | | -- We recommend, but do not require, using a second LLM for adversarial local review before publishing your changes. |
| 20 | +- We recommend, but do not require, using a different model for adversarial |
| 21 | + local review before publishing your changes. This does not replace human |
| 22 | + self-review. |
17 | 23 | - Mass renames or rewrites should *strongly* prefer using a proper syntax rewrite tool, such as [`ast-grep`]. |
18 | 24 | You may use an LLM for generating the instructions for that tool, but you should be very cautious about performing the rewrite directly with an LLM. |
19 | 25 |
|
20 | | -[LLM policy]: https://forge.rust-lang.org/policies/llm-usage.html |
| 26 | +[`ast-grep`]: https://astgrep.com/ |
| 27 | + |
| 28 | +## Reviewing LLM-created code |
| 29 | + |
| 30 | +Point people to [#llm-mentoring](https://rust-lang.zulipchat.com/#narrow/channel/606558-llm-mentoring/) liberally. |
| 31 | +Deal with low-quality PRs by closing the PR and asking the author to follow the "solicited" rule in the Forge policy. |
| 32 | +Deal with borderline PRs by asking the author to do work that shows they're paying attention; it's ok to ask for that work before you've put much time into review yourself. |
| 33 | +For example, ask them to reproduce the bug, explain the change in their own |
| 34 | +words, identify relevant edge cases, or add or justify tests. |
| 35 | + |
| 36 | +If you find yourself suggesting the same fixes on multiple PRs, |
| 37 | +consider adding them to the dev-guide. |
| 38 | + |
| 39 | +## Disclosure guidelines |
| 40 | + |
| 41 | +Disclose the *extent* and *purpose* of your LLM use. |
| 42 | +We don't care which model you used, but we do care whether you used the LLM to |
| 43 | +implement the idea or to come up with it. |
| 44 | +Write the disclosure yourself. You may use an LLM to privately review a |
| 45 | +disclosure you have written, but not to draft or rewrite it. |
| 46 | + |
| 47 | +**Good** examples: |
| 48 | + |
| 49 | +> LLM disclosure: I wrote the three commits by hand after viewing profiling data. I used an LLM to review the commits before submitting. The LLM identified that ImplString::is_negative was no longer used, so I removed that field by hand. |
| 50 | +
|
| 51 | +> Created with the help of Claude Code, which: |
| 52 | +> - traced the missing cache hits to the unconditional return(pass) by inspecting Fastly vs CloudFront headers, |
| 53 | +> - reviewed the git history to understand why the snippet was added, and |
| 54 | +> - made the VCL change. |
| 55 | +
|
| 56 | +**Bad** examples: |
| 57 | + |
| 58 | +> 🤖 Generated with Claude Code |
| 59 | +
|
| 60 | +> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
0 commit comments