Code Attributions
Learn how to analyze code statistics and attributions using Codegen
AI Impact Analysis
This tutorial shows how to use Codegen’s attribution extension to analyze the impact of AI on your codebase. You’ll learn how to identify which parts of your code were written by AI tools like GitHub Copilot, Devin, or other AI assistants.
Note: the code is flexible - you can track CI pipeline bots, or any other contributor you want.
Overview
The attribution extension analyzes git history to:
- Identify which symbols (functions, classes, etc.) were authored or modified by AI tools
- Calculate the percentage of AI contributions in your codebase
- Find high-impact AI-written code (code that many other parts depend on)
- Track the evolution of AI contributions over time
Installation
The attribution extension is included with Codegen. No additional installation is required.
Basic Usage
Running the Analysis
You can run the AI impact analysis using the Codegen CLI:
Or from Python code:
Understanding the Results
The analysis will print a summary of AI contributions to your console and save detailed results to a JSON file. The summary includes:
- List of all contributors (human and AI)
- Percentage of commits made by AI
- Number of files and symbols touched by AI
- High-impact AI-written code (code with many dependents)
- Top files by AI contribution percentage
Advanced Usage
Accessing Attribution Information
After running the analysis, each symbol in your codebase will have attribution information attached to it:
Customizing AI Author Detection
By default, the analysis looks for common AI bot names in commit authors. You can customize this by providing your own list of AI authors:
Example: Contributor Analysis
Here’s a complete example that analyzes contributors to your codebase and their impact:
Conclusion
The attribution extension provides valuable insights into how AI tools are being used in your development process. By understanding which parts of your codebase are authored by AI, you can:
- Track the adoption of AI coding assistants in your team
- Identify areas where AI is most effective
- Ensure appropriate review of AI-generated code
- Measure the impact of AI on developer productivity
For more advanced usage, check out the API reference for the attribution extension.
Was this page helpful?