Skip to content

Add content on attribution for code generated by AI agents or assistants #1093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/developer-experience/copilots.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ The next version of Copilot offers a number of new use-cases beyond code complet

It can do most of what Labs can do with "brushes" as "topics", but whereas Labs changes the code in your file, the chat functionality just shows what it would change in the window. However, there is also an "inline mode" for GitHub Copilot Chat that allows you to make changes to your code inline which does not have this same limitation.

## GitHub Copilot Agent

The [GitHub Copilot Coding Agent](https://docs.github.com/en/copilot/how-tos/agents/copilot-coding-agent) is an AI software development agent that can be assigned to work on issues within the GitHub work management system such as bugs or development tasks. The bot analyzes the work item, creates a branch, starts a virtual environment to execute and test the code iteratively, writes commits, and finally opens a pull request for review.

## ChatGPT / Bing Chat

For coding, generic AI chat tools such as ChatGPT and Bing Chat are less useful, but they still have their place. GitHub Copilot will only answer "questions about coding" and it's interpretation of that rule can be a little restrictive. Some cases for using ChatGPT or Bing Chat include:
Expand All @@ -64,4 +68,8 @@ Chat AI tools are only as good as the prompts you give them. The quality and app

## Considerations

It is important when using AI tools to understand how the data (including private or commercial code) might be used by the system. Read more about how GitHub Copilot handles your data and code [here](https://resources.github.com/copilot-for-business/).
If you make use of AI tools, consider the following:

* It is important when using AI tools to understand how the data (including private or commercial code) might be used by the system. Read more about how GitHub Copilot handles your data and code [here](https://resources.github.com/copilot-for-business/).

* You may want to consider how you will handle [attribution of AI-generated code](../source-control/git-guidance/README.md#ai-assisted-code-authorship) for accountability, code review, and auditing purposes.
42 changes: 42 additions & 0 deletions docs/source-control/git-guidance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,48 @@ For more information on commit message conventions, see:
* [Information in commit messages](https://wiki.openstack.org/wiki/GitCommitMessages#Information_in_commit_messages)
* [On commit messages](http://who-t.blogspot.com/2009/12/on-commit-messages.html)

### AI-Assisted Code Authorship

When using AI tools to generate code, it can be beneficial to maintain transparency about authorship for accountability, code review, and auditing purposes. This can be done easily by using [Git trailers](https://git-scm.com/docs/git-interpret-trailers) that append structured metadata to the end of commit messages.

#### Agentic Code Authorship

When using agentic AI tools to generate code, such as the GitHub Coding Agent feature where a GitHub issue (such as a story or task) can be assigned to a software engineering bot that analyzes the request, creates a branch, writes commits, and opens a pull request, authorship is typically attributed using tool-specific mechanisms that follow conventions similar to pair programming. For example, the GitHub Coding Agent creates its commits using the agent as an author with the supervising person acknowledged using the `Co-authored-by` trailer in the commit message. This allows AI-generated code to be attributed to the agent while still giving credit (and accountability) to the person who supervised or initiated the task.

#### IDE Assistant Attribution

When using an AI coding assistant inside an IDE, such as GitHub Copilot in Visual Studio Code, consider providing attribution in cases when the commit consists of primarily AI-generated code. This might occur when:

* More than 50% of the lines in the commit were generated by AI
* The AI provided the core logic or algorithmic approach
* Substantial code blocks were accepted from AI suggestions

This can be done by appending one or more custom trailers in the commit message, such as:

```text
Assistant-model: GPT-4o
```

Because most Git tooling expects `Co-authored-by` trailers to be formatted as email addresses, you should use a different trailer key to avoid confusion and to distinguish authorship from assistance.

Trailers can be added manually at the end of a commit message, or by using the `git commit` command with the `--trailer` option:

```sh
git commit --message "Implement feature" --trailer "Assistant-model: GPT-4o"
```

Trailers can be displayed using the [pretty formats](https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-trailersoptions) option to `git log` command. For example, for a formatted history showing the hash, author name, and assistant models used for each commit:
```sh
git log --color --pretty=format:"%C(yellow)%h%C(reset) %C(blue)%an%C(reset) [%C(magenta)%(trailers:key=Assistant-model,valueonly=true,separator=%x2C)%C(reset)] %s%C(bold cyan)%d%C(reset)"
```
```text
2100e6c Author [GPT-4.1,Claude Sonnet 4] Test commit 4 (HEAD -> work-item-8)
7120221 Author [GPT-4.1] Test commit 3
ea03d91 Author [] Test commit 2
f93fd8e Author [GPT-4o] Test commit 1
dde0159 Copilot [] Test work item (#7) (origin/main, origin/HEAD)
```

## Managing Remotes

A local git repository can have one or more backing remote repositories. You can list the remote repositories using `git remote` - by default, the remote repository you cloned from will be called origin
Expand Down