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.
- 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
pip install codesmategit clone https://github.com/MahdiMirshafiee/codemate.git
cd codemate
pip install .Before using codemate, you need to configure your OpenRouter API key:
- Get an API key from OpenRouter
- Configure codemate with your API key:
codemate --configYou'll be prompted to enter your OpenRouter API key. This will be stored in ~/.codemate/config.json .
Analyze all supported files in the current directory for bugs:
codematecodemate filename.py
codemate src/main.jsGet refactoring suggestions for a specific file:
codemate -r filename.py
codemate --refactor src/component.jsxAnalyze 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)codemate --configRemove stored API key and configuration:
codemate --deleteTo see all available options:
codemate --helpThis 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)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.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for developers by developers