AI Assistant CLI for debugging and refactoring code
Project description
codemate
An AI-powered CLI tool that helps developers debug and refactor their code efficiently. Using OpenRouter's GPT-4o API, it analyzes source code files to identify bugs, suggest fixes, and recommend refactoring improvements across multiple programming languages.
Features
- Smart Debugging: Automatically detect syntax errors, logical errors, runtime issues, and security vulnerabilities
- Code Refactoring: Get intelligent suggestions to improve code quality, maintainability, and performance
- Multi-file Analysis: Process entire directories or single files
- Inline Code Support: Analyze code snippets directly from command line or stdin
- Wide Language Support: Supports 40+ programming languages and file types
- Fast & Efficient: Powered by GPT-4o through OpenRouter API
Installation
From PyPI (Recommended)
pip install codesmate
From Source
git clone https://github.com/MahdiMirshafiee/codemate.git
cd codemate
pip install .
Setup
Before using codemate, you need to configure your OpenRouter API key:
- Get an API key from OpenRouter
- Configure codemate with your API key:
codemate --config
You'll be prompted to enter your OpenRouter API key. This will be stored in ~/.codemate/config.json .
Usage
Debug Current Directory
Analyze all supported files in the current directory for bugs:
codemate
Debug Specific File
codemate filename.py
codemate src/main.js
Refactor Code
Get refactoring suggestions for a specific file:
codemate -r filename.py
codemate --refactor src/component.jsx
Inline Code Analysis
Analyze code directly from command line:
codemate -i "def hello(): print('Hello World')"
Read code from stdin:
cat myfile.py | codemate -i -
# or
codemate -i -
# Then paste your code and press Ctrl+D (Linux/macOS) or Ctrl+Z+Enter (Windows)
Configuration Management
Set API Key
codemate --config
Delete Configuration
Remove stored API key and configuration:
codemate --delete
Help
To see all available options:
codemate --help
This will display:
usage: codemate [-h] [-r] [-i INLINE] [-c] [-d] [filename]
Codemate CLI: AI Assistant for debug and refactor codes
positional arguments:
filename (optional) filename to debug/refactor (if omitted, debug current dir)
options:
-h, --help show this help message and exit
-r, --refactor Refactor the specified file (use with filename)
-i INLINE, --inline INLINE
Inline code OR use "-" to read code from stdin
-c, --config Set OpenRouter API Key
-d, --delete Delete the codemate config directory (erase API key)
Examples
Debug a Python File
Refactor a JavaScript File
Inline Code Analysis
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Authors
Made with ❤️ for developers by developers
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codesmate-0.1.0.tar.gz.
File metadata
- Download URL: codesmate-0.1.0.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f78d32afd479413ae11ba59a1d0e525c370f0a844b0cbc7e8ddbe0c5e7e9865
|
|
| MD5 |
6b28f5fef81001b16b792836c8be525a
|
|
| BLAKE2b-256 |
c727273badd69b61990f97c82ad786988facf59525937478f5214978ca0fe344
|
File details
Details for the file codesmate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: codesmate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
910a2a2ccad2e65bc38b6a258e84142402e96b23d7630c9f1407ba798d31ad9b
|
|
| MD5 |
65ae52dc5b4cc8ee99cd1ea5e0cf926d
|
|
| BLAKE2b-256 |
9182e3a76f0401ded65fd28743c3b918dbfc59e6f5c2a3f46931aa430b93435c
|