You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a section about expectations around using AI tools to the
contributor docs.
Also adds a PR checklist item calling them out (although like the first
checklist item they are a subset of the overall docs that the next entry
links to).
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/contributing/Tree-hygiene.md
+74-1Lines changed: 74 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -309,12 +309,85 @@ When commenting on a PR, keep in mind the following mantra:
309
309
310
310
It's better to close a PR than to leave it in limbo.
311
311
312
-
_See also: [How to review a Flutter PR](https://docs.google.com/presentation/d/1apKVLEAEqxINby49JhLWSLI-CMH0nxCcnrf90nW4cts/edit?usp=sharing) presentation_
312
+
_See also:_
313
+
*_[How to review a Flutter PR](https://docs.google.com/presentation/d/1apKVLEAEqxINby49JhLWSLI-CMH0nxCcnrf90nW4cts/edit?usp=sharing)_
314
+
*_[AI guidelines for reviewers](#reviewer-guidelines)_
313
315
314
316
### What (to do when the patch is abandoned)
315
317
316
318
Sometimes the contributor is unable to finish the work of landing the patch. In that case, if the PR has promise, we may close it but mention it on the relevant issue so that other interested parties can pick it up. Such issues are given the label [`has partial patch`](https://github.com/flutter/flutter/labels/has%20partial%20patch).
317
319
320
+
## AI contribution guidelines
321
+
322
+
PRs prepared using AI tools must follow these requirements:
323
+
324
+
1. You must review all AI-generated code before opening a (non-draft) PR, and before requesting
325
+
re-review of any updates to the PR.
326
+
* You are responsible for ensuring that code you submit meets the Flutter project’s standards.
327
+
* Unmodified AI output generally does not meet those standards.
328
+
2. You must understand and be able to discuss the code in the PR.
329
+
* Non-trivial PRs require discussion and iteration during review. If you do not understand the
330
+
code, you cannot meaningfully respond to review feedback.
331
+
* In our experience, simply feeding review feedback into an AI agent and uncritically reposting
332
+
its output will not lead to a constructive review.
333
+
3. You must verify the accuracy of any AI-generated text you include in the PR description or
334
+
review discussion comments.
335
+
* If an AI provides you incorrect information, it is just hallucinating; if you choose to paste
336
+
that text into GitHub, you are misrepresenting your PR to your reviewer.
337
+
* In particular, do not tell a reviewer that you have addressed their feedback just because
338
+
AI output says so. It is your responsibility to make sure that review feedback has actually
339
+
been addressed.
340
+
341
+
### Reviewer guidelines
342
+
343
+
Because the Flutter team’s time is limited, and the capacity for people outside the team to generate
344
+
plausible-looking code is unlimited, be mindful as a reviewer about what code you choose to review.
345
+
Consider immediately closing PRs that have any of the following red flags:
346
+
347
+
* The PR description has entirely replaced our template with AI-generated output, and the PR is
348
+
missing at least one obvious checklist item (tests, issue link, etc.).
349
+
* If the contributor did not follow our process from the outset, they are unlikely to
350
+
understand what is expected of them during review.
351
+
* The PR description does not match the changes.
352
+
* If the contributor did not review both the changes and the description enough to notice this,
353
+
they have not followed the AI contribution policy.
354
+
* The PR contains irrelevant AI-generated files, such as agent planning .md files.
355
+
* If the contributor did not review the changes enough to notice and remove these files, they
356
+
have not followed the AI contribution policy.
357
+
358
+
As always when closing a PR, explain why and provide next steps.
359
+
360
+
As a guiding principle, if at any point in the process you feel that you are getting unfiltered
361
+
or minimally filtered AI output as code and/or comment responses, ask yourself:
362
+
* If this PR weren’t here, would I choose to spend my time fixing this issue?
363
+
* Would I choose to fix it using an AI agent that took hours or days to respond to every prompt?
364
+
365
+
Unless the answer to both questions is yes, the review is not a good use of your time.
366
+
367
+
This applies even if you are multiple rounds into the review: if the contributor closed the PR,
368
+
would you take it over using an extremely high-latency agent? Beware the sunk cost fallacy.
369
+
370
+
### Philosophy
371
+
372
+
A common question in discussions around AI policies for open source projects is: “Why have an
373
+
AI policy at all? Why does it matter how the code was created; shouldn’t the code speak for itself?”
374
+
375
+
In general, we agree, which is why our policy focuses on behaviors rather than tools. The behaviors
376
+
that led to the creation of this policy are problematic regardless of whether they are AI-generated
377
+
or human-generated. However, it is useful to highlight these policies in the context of AI because
378
+
we have seen that these behaviors are orders of magnitude more common when AI is involved. For example:
379
+
* Submitting a PR containing hundreds of lines of code that the contributor doesn't understand is
380
+
always a problem. This was rare before the widespread use of AI agents, but is more common with
381
+
AI-assisted development.
382
+
* Having several rounds of exchanges where a reviewer asks for a change, and the contributor says
383
+
that they have made that change but haven't, is always a waste of reviewer time. It’s very rare
384
+
for a contributor to deliberately and obviously lie to a reviewer, but unfortunately common
385
+
for contributors to uncritically repeat AI agent hallucinations.
386
+
* PRs that ignore our process have always been problematic, because standardizing the PR process
387
+
is an important part of how we keep our review load manageable. However, a contributor who has
388
+
spent hours or days on a PR is much more likely to take some time to learn and follow our process
389
+
to avoid having that effort be wasted than someone who spent a few minutes generating the PR.
390
+
318
391
## Landing a patch
319
392
320
393
Once you have submitted your patch and received your LGTM, if you do not have commit access to
0 commit comments