Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MahdiMirshafiee/codemate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  1. Get an API key from OpenRouter
  2. 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 All Files In Direcory

Debug All Files In Direcory

Debug a Python File

Debug a Python File

Refactor a JavaScript File

Refactor a JavaScript File

Inline Code Analysis

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

About

An AI-powered CLI assistant for debugging and refactoring code.

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages