03 · What You Need to Know
Understanding Human and AI Contributions to Research Software
What Does It Mean for Research Code to Be AI-Generated?
AI-generated research code is source code produced by a generative AI system in response to instructions or contextual information. It may consist of a complete script, an individual function, a modification to existing code, or a suggested implementation of an analytical procedure.
However, research programming rarely follows a simple division between code written entirely by humans and code generated entirely by AI.
A researcher might specify the algorithm, request an implementation from AI, correct its errors, and integrate the result into an existing project. Another researcher might write the implementation independently but use AI to explain an error message.
These interactions involve different levels of AI contribution, even though both researchers could reasonably describe their workflows as AI-assisted programming.
For transparency, it is useful to distinguish the origin of a code component from the nature of the assistance involved in developing it.
Why Is the Human-Written Versus AI-Generated Distinction Often Incomplete?
The distinction becomes difficult when code undergoes iterative development.
Consider a function initially generated by AI. A researcher changes its parameters, replaces its calculations, corrects its handling of missing data, and rewrites its documentation. Is the resulting function still AI-generated?
There is no universally accepted numerical threshold at which an AI-generated function becomes human-written. Counting changed lines would not necessarily resolve the question because a small methodological correction can be more consequential than extensive cosmetic rewriting.
A more useful classification describes the development process rather than assigning an artificial percentage of authorship.
| Development situation |
Possible description |
What should be documented |
| Researcher writes the implementation independently |
Human-written code |
Relevant development and verification records |
| AI generates a function that is accepted with minimal changes |
AI-generated, human-reviewed code |
AI contribution, accepted implementation, and verification |
| AI generates a function that the researcher substantially revises |
AI-assisted, human-modified code |
Original contribution and consequential corrections |
| Researcher writes code and AI suggests a correction |
Human-written code with AI-assisted revision |
Nature and significance of the accepted correction |
| AI only explains syntax without changing the implementation |
Human-written code developed with AI assistance |
Assistance where relevant or required |
| Several researchers and AI systems iteratively revise a function |
Collaboratively developed, AI-assisted code |
Traceable revisions and consequential contributions |
These descriptions are practical documentation categories, not standardized legal or research-integrity classifications. Researchers should use terminology that accurately represents the development process.
Can Researchers Identify AI-Generated Code by Examining Its Style?
Not reliably.
AI-generated code may exhibit recognizable stylistic patterns, such as conventional variable names, extensive comments, or standardized function structures. However, human programmers also use these conventions, and AI systems can generate code in many different styles.
Common algorithms and programming idioms further complicate identification. A short function for calculating a mean or sorting observations may look nearly identical regardless of whether it was written by a researcher, copied from documentation, or generated by AI.
Subsequent editing can remove stylistic characteristics that might otherwise suggest a particular origin.
Consequently, researchers should not treat stylistic impressions or unsupported AI-code detection scores as definitive evidence of authorship.
Reliable provenance generally depends on contemporaneous records of how the code was developed.
How Can Git Help Distinguish Human and AI Contributions?
Git can record changes to research software and associate those changes with identifiable commits. This allows researchers to inspect when functions were introduced, modified, or removed.
For example, a commit message might explain that a data-cleaning function was drafted with AI assistance and subsequently corrected to match the study's missing-data protocol.
However, Git does not automatically know whether code was generated by AI. Its author and committer metadata identify configured Git identities, not necessarily the original intellectual source of every line.
Git's history and blame functionality can help locate the revision that introduced particular code, but the interpretation of that revision still depends on the available development documentation.
Researchers should therefore combine version control for AI-generated code changes with descriptive commit messages or a separate AI-assistance log.
Should Every AI-Generated Line Be Labeled?
Usually, no.
Line-by-line labels may appear precise, but they can become misleading when code is repeatedly modified. A function may retain some AI-generated syntax while implementing a researcher-designed algorithm that differs substantially from the original suggestion.
Likewise, a single AI-generated line may introduce a consequential methodological change, while dozens of generated comments may have no effect on the analysis.
Researchers should prioritize the significance of the contribution rather than the number of lines involved.
For relatively simple projects, a project-level statement describing the extent of AI assistance may be sufficient. More complex projects may benefit from function-level documentation or records associated with particular commits.
Where AI-generated code is itself the object of investigation, more granular provenance may be necessary because the origin of specific outputs forms part of the research evidence.
What Should an AI-Assistance Log Record?
A structured development log can document AI contributions without placing repetitive comments throughout the source code.
For consequential interactions, the log may identify:
- The date and purpose of the AI-assisted coding activity.
- The AI provider, model identifier, and available version information.
- The relevant source-code files or functions.
- The nature of the contribution, such as generation, debugging, refactoring, or test creation.
- Whether the generated suggestion was accepted, modified, or rejected.
- The significant human corrections or methodological decisions.
- The verification procedures applied to the accepted code.
- The corresponding Git commit or archived release.
When the original instructions materially explain the implementation, researchers may also preserve relevant AI prompts and responses.
The log should distinguish verified information from retrospective recollections. If the exact model or original prompt is unavailable, that limitation should be recorded rather than concealed.
Should Researchers Record Which AI Model Generated Each Component?
Model-level provenance can be useful when different AI systems contribute to separate parts of a project.
For instance, one model may generate preprocessing functions while another suggests statistical analysis code. If the distinction is relevant to an audit or research evaluation, documenting the models separately can clarify the development history.
However, a project does not necessarily require a model identifier beside every function. The appropriate level of detail depends on the significance of the contribution and the research purpose.
Researchers should consider documenting the models used for consequential coding tasks, especially where model behavior itself is being evaluated.
How Should Researchers Handle Code That Has Been Heavily Rewritten?
Substantial human revision does not erase the historical fact that AI contributed to an earlier implementation. At the same time, describing the final code simply as AI-generated may understate the researcher's subsequent work.
The most accurate description may be that the implementation was initially drafted with AI assistance and subsequently revised and verified by the researcher.
Researchers should document the important changes rather than attempt to calculate an unsupported percentage of human or AI authorship.
If the final implementation no longer contains any of the AI-generated code, the earlier interaction may still be relevant to development provenance, particularly if it influenced the chosen algorithm or analytical approach.
Whether that interaction requires disclosure depends on its significance and applicable policies.
Does Code Provenance Determine Scientific Responsibility?
No. The origin of code and responsibility for its use are separate questions.
Code provenance
Describes how source code originated, which tools or people contributed to its development, and how it changed over time.
Scientific responsibility
Concerns the research team's obligation to evaluate the methods, verify the computations, and justify the results reported in the study.
Researchers cannot establish scientific validity merely by showing that code was written by a human. Human-written code can contain serious errors.
Similarly, AI-generated code is not automatically incorrect. Its suitability depends on whether it accurately implements the intended method and passes appropriate verification.
The question of whether code authorship matters after full verification therefore requires distinguishing scientific reliability from transparency about the development process.
In ordinary research practice, the researchers using the code remain accountable for its analytical consequences.
Does AI-Generated Code Need Different Verification From Human-Written Code?
Both require verification appropriate to their purpose and potential consequences.
AI-generated code may introduce particular review challenges because a researcher can receive a substantial implementation without having constructed each step personally. Plausible explanations accompanying the generated code may also encourage unwarranted confidence.
However, the appropriate response is not to assume that human-written code is trustworthy by default. Research software should be evaluated according to what it does.
Verification may involve reviewing algorithms, checking statistical assumptions, comparing outputs with independently established calculations, and applying unit tests to consequential functions.
When AI helps generate the tests themselves, researchers should assess whether those tests independently evaluate the intended behavior rather than merely reproduce the implementation's assumptions.
What If Multiple Researchers Use AI on the Same Project?
Collaborative research introduces additional provenance questions. Different team members may use different AI systems, prompts, or coding environments.
Without agreed documentation practices, the project may contain AI-assisted components whose development histories are difficult to reconstruct.
Research teams can establish conventions for recording consequential AI assistance, reviewing proposed changes, and linking accepted implementations to identifiable revisions.
The objective is not to monitor every programming interaction. It is to ensure that the team can explain how important analytical components were developed and verified.
These conventions may be especially useful when code is transferred between collaborators or when the original developer is no longer available.
Should Human and AI Contributions Be Disclosed in the Manuscript?
Researchers should distinguish internal provenance documentation from public disclosure.
Internal records may contain detailed information about individual functions, prompts, model versions, and corrections. A manuscript disclosure may instead summarize the purpose and extent of AI assistance.
The appropriate disclosure depends on the journal's current policies, institutional requirements, and the role of AI in the research.
Where AI-generated code is central to the methodology, the methods section or supplementary materials may need to explain how the code was generated, verified, and used.
Researchers should not assume that disclosing AI assistance eliminates the need for verification. Nor should they assume that fully verified code automatically makes its development provenance irrelevant to every disclosure policy.