Skip to main content

Cody by Cody Labs

Cody is an AI-powered code summarization and review tool, designed to integrate seamlessly as a GitHub Action. It serves as an interface between your repository and leading AI language models, such as OpenAI's GPT-4o.

When you submit a Pull Request on GitHub, Cody automatically summarizes your changes and reviews your code with the expertise typical of a senior software engineer from a top tech company.

Cody pull request

Installation

Installation is as simple as adding your Open API key, and adding a Github Actions workflow file to your repo.

  1. Add OPENAI_API_KEY as a GitHub repo secret via Settings > Actions > Secrets and variables > New repository secret. The variable name should be OPENAI_API_KEY, and the value should be your Open API API Key.

Open API Api Key

Add secrets

Note that GITHUB_TOKEN does not need to be added as it is available by default.

  1. Create a new folder and file in your repo .github/workflows/code_review.yml

Copy the file from here: cody_review.yml

Or available below:

name: Automated Code Review by Cody

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
code_review:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Clone cody-code-reviewer repository
run: |
git clone https://github.com/codylabs/cody-code-reviewer.git
cd cody-code-reviewer

- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run Code Review Model
run: |
python src/review_pull_request.py ${{ github.event.pull_request.number }} ${{ github.repository }} > ${{ github.workspace }}/output.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# Optional: update to a model of your choice from https://platform.openai.com/docs/models
OPENAI_MODEL: "gpt-4o"

- name: Comment on Pull Request
run: |
python src/comment_on_pr.py ${{ github.event.pull_request.number }} "${{ secrets.GITHUB_TOKEN }}" ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: read
pull-requests: write
  1. Commit your code, create a pull request and watch Cody in action!

Trigger pull request review

Cody pull request

Questions, Suggestions and Licencing

Contributions are welcome! Whether it's submitting issues, suggesting improvements, or contributing code, we appreciate your input on our GitHub.

Please note that while this project is currently open for contributions, it is not open source. There may be an enterprise plan available in the future that will include additional features and support.