On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practices

Syed Mohammad Kashif, Peng Liang, Amjed TahirarXiv 2025 · DOI

Abstract

As AI code generation becomes a standard part of the developer's toolkit, a new practice is emerging: "self-declaration." This study investigates how and why developers explicitly label AI-generated code in their projects. Findings indicate that while 76.6% of practitioners do so for traceability and ethical transparency, many cease labeling once they have heavily modified the AI's output.

Introduction: The Problem of Provenance

AI-generated code introduces specific risks, including potential security vulnerabilities, technical debt, and licensing ambiguities. Managing these risks requires knowing which parts of a codebase originated from a human and which were generated by a Large Language Model (LLM). Currently, no automated industry standard exists for "watermarking" such code; instead, the community relies on voluntary developer declarations. This research addresses the lack of empirical data on these practices, exploring how developers label code, what information they share, and their motivations for transparency.

Example of a self-declaration comment in a Python script, highlighting the use of GitHub Copilot.

Methodology

The study employed a mixed-methods approach consisting of two distinct phases:

  1. Repository Mining: A keyword-based search on GitHub identified real-world examples of declarations (e.g., "written by ChatGPT"). After manual filtering, a dataset of 613 code snippets was curated.
  2. Practitioner Survey: 111 developers from 26 countries were surveyed to understand the motivations and barriers behind self-declaration. Thematic analysis was used to categorize open-ended responses.
Overview of the research design, detailing the repository mining (RQ1) and survey (RQ1/RQ2) workflows.

Datasets and Contributions

The research utilized two primary data sources:

  • GitHub Dataset: 613 self-declared AI-generated code snippets from 586 unique repositories, covering top programming languages like JavaScript and Python.
  • Survey Data: Responses from 111 practitioners ranging from junior developers to CTOs.

The authors have made the curated dataset of self-declared snippets publicly available to facilitate further research into AI-human co-programming patterns.

Key Insights: The Modification Threshold

A critical finding is the "modification threshold": developers are significantly more likely to declare AI code when used "as-is." Extensive refactoring often leads developers to feel the code has become their own, causing the label to vanish. Furthermore, many who abstain from declaration view LLMs as analogous to spell-checkers or IDE auto-completes, arguing that one does not credit a tool for standard assistance.

Declarations typically occur at the snippet level (69.4%) rather than the file level, indicating a preference for precise traceability. While functional reasons (e.g., debugging markers) are common, 20.7% of developers declare code primarily for ethical transparency and accountability.

Results and Declaration Styles

  • Adoption Rates: 76.6% of surveyed developers self-declare at least "sometimes," though only 13.5% do so "always."
  • Tool Usage: ChatGPT (56%) and GitHub Copilot (43%) are the most frequently mentioned tools.
  • Comment Categories: Declarations range from simple tool mentions to contextual explanations including prompts or chat links, and quality indications (e.g., warnings about potential bugs).
  • Sentiment: 85% of declaration comments were positive regarding the tool's speed, while 15% served as negative warnings against trusting the specific snippet.

Limitations and Future Outlook

The study is limited by selection bias (only capturing those who choose to declare) and its focus on public GitHub repositories. Future work should explore automated IDE features for declaration and investigate how these practices impact long-term maintenance and code review efficiency.

Summary updated

BibTeX
@misc{kashif2025developers,
  author = {Syed Mohammad Kashif and Peng Liang and Amjed Tahir},
  title = {{On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practices}},
  year = {2025},
  eprint = {2504.16485},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.16485},
}
Figure