An intelligent command-line tool that helps every developer code better using OpenAI's powerful language models.
- Ask Questions: Get instant help with coding problems, debugging, and best practices
- Code Analysis: Analyze your code files for potential issues, optimizations, and improvements
- Code Generation: Generate code snippets based on natural language descriptions
- Multi-language Support: Works with Python, JavaScript, Java, C++, and many more languages
- Easy Setup: Simple .env configuration with your OpenAI API key
π New to the assistant? Check out our Getting Started Guide for a step-by-step walkthrough!
git clone https://github.com/mrsbeep/coding-assistant.git
cd coding-assistant
pip install -r requirements.txt
Copy the example environment file and add your OpenAI API key:
cp .env.example .env
Edit .env
and add your OpenAI API key:
OPENAI_API_KEY=sk-your-actual-api-key-here
python coding_assistant.py setup
# Basic question
python coding_assistant.py ask "How do I reverse a string in Python?"
# With language context
python coding_assistant.py ask "How to handle exceptions?" --language python
# With additional context
python coding_assistant.py ask "Optimize this algorithm" --context "Working with large datasets"
python coding_assistant.py analyze my_script.py
python coding_assistant.py analyze src/main.js
# Generate code snippet
python coding_assistant.py generate "Create a function to calculate factorial"
# Generate for specific language
python coding_assistant.py generate "REST API endpoint for user authentication" --language python
# Save to file
python coding_assistant.py generate "Binary search algorithm" --language python --output binary_search.py
For easier access, install as a command-line tool:
pip install -e .
Then use with shorter commands:
coding-assistant ask "How to use decorators in Python?"
ca analyze my_file.py # 'ca' is a short alias
Create a .env
file with the following options:
# Required: Your OpenAI API key
OPENAI_API_KEY=sk-your-api-key-here
# Optional: Choose your preferred model (default: gpt-3.5-turbo)
OPENAI_MODEL=gpt-4
# OPENAI_MODEL=gpt-3.5-turbo
gpt-3.5-turbo
(default, faster and cheaper)gpt-4
(more capable but slower and more expensive)
python coding_assistant.py ask "My Python script has a memory leak, how can I debug it?" --language python
python coding_assistant.py analyze examples/sample_flask_app.py
python coding_assistant.py ask "Explain async/await in JavaScript with examples" --language javascript
python coding_assistant.py generate "Express.js server with JWT authentication" --language javascript --output server.js
π More examples available in examples/usage_examples.md
- Learning: Get explanations and examples for new programming concepts
- Debugging: Help identify and fix bugs in your code
- Code Review: Get suggestions for code improvements and optimizations
- Boilerplate Generation: Quickly generate common code patterns
- Best Practices: Learn industry standards and best practices
- Refactoring: Get suggestions for cleaner, more maintainable code
- Python 3.7 or higher
- OpenAI API key
- Internet connection
Feel free to open issues and submit pull requests to improve this coding assistant!
This project is licensed under the MIT License - see the LICENSE file for details.
- Make sure you've created a
.env
file with your API key - Check that the key starts with
sk-
and is valid
- Verify your API key is correct and has sufficient credits
- Check your internet connection
- Ensure you're using a supported model name
- Make sure you've installed all requirements:
pip install -r requirements.txt
- Try running the setup command:
python coding_assistant.py setup