I am seeking some clarification around the policy of not allowing AI-generated content on Stack Overflow, specifically in relation to the use of GitHub Copilot (and, I suppose, similar AI tools which are specifically built to assist with software development, rather than more general purpose large language models). I understand, and broadly support, the reason for introducing the policy - Stack Overflow is a fantasically useful resource, and we don't want people lazily filling it up with confident sounding but misleading or downright wrong AI slop. However, since I've started using Copilot, I'm no longer sure whether I'm able to post answers to Stack Overflow without violating the policy.
First, I'd like to describe the role that Copilot plays in my workflow.
I have been employed as a software developer for over 20 years now. Last year, my employer adopted Copilot and made it available to all of us developers, along with plenty of training on how to make the best use of it. I've been using it, mostly the flavour which is integrated into Visual Studio, for maybe 9 months now, and I've been so impressed with it that I've even bought a subscription with my own money for my own personal use.
The Copilot feature that I use the most is the inline code suggestions - I start typing (for example) a method signature and then a block of grey text (being Copilot's prediction of what I might be about to type next) appears, and I can press tab to accept the suggestion, or I can ignore it and carry on typing. Sometimes the suggestion is completely wrong, not what I was intending, or doesn't even compile. But often it's close enough to what I was about to type that it's quicker for me to accept the suggestion and then edit it than for me to type it myself. And I'm an experienced enough developer to be able to tell the difference. Copilot, for me, is a productivity tool. It is absolutely not (and I always emphasise this point when talking with non-technical colleagues about it) a substitute for knowing how to write code, or for having an understanding of the problem domain that the code is to be used for.
So now I've got a chunk of code, some of it was typed by me, some of it was suggested by Copilot, and maybe edited by me afterwards.
Did I write that code? I'll leave that question to the philosophers.
Am I responsible for that code? Hell yeah, even if I didn't type every single character, I'm still responsible for it. It's my name on the pull request, and if a code review determines that the pull request isn't up to scratch then it's up to me to fix it. And if some dodgy code with my name on the pull request somehow makes it into production and causes a problem, it's my neck on the line, I can't just blame the AI. And rightly so, I'm still responsible for doing the thinking, understanding the codebase, and making sure that the solution as a whole is fit for purpose. If I don't understand the code that Copilot has suggested then I dive into the documentation and research it (and maybe ask the Copilot chat to explain it, but I never treat the response as gospel) until I do understand it, just the same as I would with some code I've copied from SO which appears to solve my problem but which I don't yet understand.
Consider the scenario. I see a question on SO which doesn't have an answer yet, and I understand the question and write an answer, and I include some code to illustrate the answer. I didn't ask Copilot to answer the question for me - if I needed to do that then it's a strong sign that I'm the wrong person to post an answer. But it's likely that some of the code I include in my answer was originally suggested by Copilot, although you can be sure that I'll have tested it to make sure that it works as intended.
Would that answer be a violation of the policy? Reading through Policy: Generative AI (e.g., ChatGPT) is banned and all its answers, this use case isn't explicitly covered.
Related discussions
I don't believe this question is a duplicate of Should we flag human-written questions that use code generated by ChatGPT?, because that question is about whether it's OK to ask questions about AI-generated code, whereas my question is about whether it's OK to use use code which may have been suggested by Copilot, but which I understand and know works correctly, to illustrate an answer to a question.
I also don't believe this is a duplicate of Is it acceptable to post answers generated by an AI, such as GitHub Copilot? [duplicate] because that question specifically calls out the fact that the answer being discussed says that
This code was written by Github Copilot with minimal supervision
And raises the following potential problems which may arise from this
- user submitting such an answer might not be able to reason about the answer at all
- there is high rate of incorrectness with Copilot generated code
- does the user even have the rights to submit such code into Stack Overflow
I'll admit that the third bullet point may be problematic, but the rest of that question doesn't really apply to the situation I'm asking about, because I wouldn't be asking Copilot to generate an answer, I'd be writing an answer myself, based on my own experience gained from working with the subject matter in the question (so I'd be able to reason about it), and illustrated using some code that I'd part typed myself and part accepted from Copilot suggestions (and of course tested) whilst gaining that experience.
Maybe it would help if I provide some background to the answer I'm thinking of posting, which prompted me to ask this question. I was looking for a way to add particular functionality to an application, and found an answer containing the key knowledge that I needed to get started, but which I feel is an incomplete and not very flexible implementation. Since then I've incorporated it into a class library which I was writing anyway, and extensively refactored it for ease of unit testing and extensibility, we're talking about a number of weeks work here, and I thought it would be helpful to add another answer showing the improvements I've made and the thinking which led me to make them. In this case the code wasn't written specifically for an answer, and that's why I couldn't tell you now which lines I typed and which ones were suggested by Copilot.