Skip to main content

CodeSpector

CodeSpector is a Python package designed to review code changes for quality and security issues using AI chat agents. It supports different chat agents like Codestral and ChatGPT.

Features

  • Automated code review using AI chat agents.
  • Supports multiple chat agents and models.
  • Generates detailed review reports in markdown format.
  • Configurable via environment variables and command-line options.

Installation

To install the package, use the following command:

pip install codespector
uv add codespector

Usage

Command-Line Interface

You can use the codespector command to start a code review. Below are the available options:

Usage: codespector [OPTIONS]

Options:
  --chat-token TEXT          Chat agent token  [env var: CODESPECTOR_CHAT_TOKEN]
  --chat-model TEXT          Choose the chat model to use  [env var: CODESPECTOR_CHAT_MODEL]
  --chat-agent TEXT          Choose the chat agent to use (codestral, chatgpt, deepseek)
                            or set your own  [env var: CODESPECTOR_CHAT_AGENT]
  -b, --compare-branch TEXT  Select the branch to compare the current one with
  --output-dir TEXT         Select the output directory  [default: codespector]
                            [env var: CODESPECTOR_OUTPUT_DIR]
  --system-content TEXT     Content which used in system field for agent
                            [env var: CODESPECTOR_SYSTEM_CONTENT]
  --prompt-content TEXT     Prompt content which included to review prompt
                            [env var: CODESPECTOR_PROMPT_CONTENT]
  --result-file TEXT        Set file for saving the result
                            [env var: CODESPECTOR_RESULT_FILE]
  --exclude-file-ext LIST   Exclude file extensions from the review
                            [env var: CODESPECTOR_EXCLUDE_FILE_EXT]
  --version                 Show the version and exit.
  --help                    Show this message and exit.

Example

To run a code review, use the following command:

codespector --chat-token YOUR_CHAT_TOKEN --chat-agent codestral --compare-branch develop --result-file result.md --system-content "system content" --prompt-content "prompt content"

Configuration

You can also configure CodeSpector using environment variables. Create a .env file in the root directory of your project with the following content:

CODESPECTOR_CHAT_TOKEN=your_token
CODESPECTOR_OUTPUT_DIR=codespector
CODESPECTOR_SYSTEM_CONTENT="Ты код ревьювер. Отвечай на русском"
CODESPECTOR_PROMPT_CONTENT="Оцени код на безопасноть, соблюдение лучших техник"
CODESPECTOR_RESULT_FILE="result.md"
CODESPECTOR_CHAT_AGENT=codestral
CODESPECTOR_CHAT_MODEL=your_model
CODESPECTOR_EXCLUDE_FILE_EXT=.pyc,.pyo

Makefile Commands

  • lint: Run linting and formatting checks.
  • format: Format the code.
  • fix: Fix linting issues and format the code.
  • test: Run the tests.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Metadata

Release files for codespector 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codespector 1.0.1
File Size Uploaded Provenance
codespector-1.0.1.tar.gz 23.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for codespector 1.0.1
File Interpreter ABI Platform
codespector-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.5 kB

Release files / codespector-1.0.1.tar.gz

Download URL codespector-1.0.1.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
30c7c6b645078718acb32391af22db482ca4ed1485530f19fdd467544a125701
BLAKE2b-256 checksum
How to use checksums
f9ba75f7490f3c4a2de0fe917334ce7e27f1f8429a2d93b64a9cf84ae58ada76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

Release files / codespector-1.0.1-py3-none-any.whl

Download URL codespector-1.0.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ff9bd1094b977940a7cbe46769b2f922c1c02bb8639d1484408fdd45032cb59
BLAKE2b-256 checksum
How to use checksums
48ddcb5e6ed420b84eeb6cc3ccd2f90b69ff387109b785647433cb3af5597294
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

Security for codespector 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codespector-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page