ai-codex-cli
v1.0.3
Published
Your AI Dev Companion - A powerful CLI tool for developers
Downloads
16
Maintainers
Readme
🚀 AI Codex CLI - Your AI Dev Companion
A powerful command-line interface that brings AI assistance directly to your terminal. Get instant help with coding concepts, debugging, code generation, and more!
✨ Features
- 🤖 AI-Powered Assistance: Integrated with OpenAI GPT and Google Gemini
- 💡 Multiple Commands: Explain concepts, debug errors, generate code, and ask questions
- 💬 Interactive Chat: Continuous conversation mode with context awareness
- 📝 History Tracking: Save and review past queries and responses
- 🔄 Response Management: Save responses to files and share via GitHub Gists
- ⚙️ Configurable: Switch between AI providers and test connections
- 🎨 Beautiful UI: Colorful output with ASCII art branding
🛠️ Installation
Global Installation (Recommended)
Install the package globally to use it as a command-line tool:
npm install -g ai-codex-cliAfter installation, you can use the tool with either codex or ai commands:
codex explain "async/await in JavaScript"
# OR
ai explain "async/await in JavaScript"Local Installation
To use it within a project:
npm install ai-codex-cliSet Up Your API Keys
After installation, run the config command to set up your API keys:
codex configOr manually create a .env file in your home directory:
# Choose your preferred AI provider
AI_PROVIDER=gemini
# Add your API keys
GEMINI_API_KEY=your_gemini_api_key_here
# Optional: GitHub token for sharing gists
GITHUB_TOKEN=your_github_token_here🎯 Commands
Core Commands
# Explain programming concepts
codex explain "async/awcodext in JavaScript"
codex explain "Docker containers"
# Debug errors and get solutions
codex debug "TypeError: Cannot read property 'length' of undefined"
codex debug "CORS error in Express.js"
# Generate code snippets
codex generate "React login form with validation"
codex generate "Python function to parse CSV files"
# Ask any programming question
codex ask "What's the difference between let and const?"
codex ask "How to optimize SQL queries?"
# Interactive chat mode
codex chatUtility Commands
# Save last response to file
codex save my-solution.md
# View command history
codex history
# Share last response to GitHub Gist
codex share
# Configure settings
codex config🚀 Getting Started
First, test your setup:
codex config # Choose "Test API Connection"Try explaining a concept:
codex explain "REST API"Generate some code:
codex generate "Express.js hello world server"Start an interactive chat:
codex chat
🔧 Configuration
Switching AI Providers
You can easily switch between OpenAI and Gemini:
codex config
# Choose "Switch AI Provider"Or manually edit your .env file:
AI_PROVIDER=gemini # or openaiAPI Keys Setup
For Google Gemini:
- Go to Google AI Studio
- Create an API key
- Add it to your
.envfile asGEMINI_API_KEY
For OpenAI:
- Go to OpenAI API Keys
- Create an API key
- Add it to your
.envfile asOPENAI_API_KEY
For GitHub Gists (optional):
- Go to GitHub Personal Access Tokens
- Create a token with
gistpermissions - Add it to your
.envfile asGITHUB_TOKEN
🎨 Examples
Explaining Concepts
$ codex explain "GraphQL vs REST"
🤖 Explaining: GraphQL vs REST
📖 Explanation:
GraphQL and REST are both approaches for building APIs, but they differ significantly...
[Detailed explanation follows]Debugging Errors
$ codex debug "Module not found error in Node.js"
🐛 Debugging Error: Module not found error in Node.js
🔧 Debug Analysis:
This error typically occurs when Node.js cannot locate a module...
[Detailed debugging steps follow]Code Generation
$ codex generate "Python function to validate email addresses"
⚡ Generating Code: Python function to validate email addresses
💻 Generated Code:
```python
import re
def validate_email(email):
"""
Validates an email address using regex pattern
[Complete implementation follows]Interactive Chat
$ codex chat
💬 Interactive Chat Mode
Type "exit" or "quit" to end the chat session
You: How do I handle errors in async functions?
AI: Great question! Here are the main ways to handle errors in async functions...
You: Can you show me an example?
AI: Certainly! Here's a practical example...🤝 Contributing
Feel free to contribute by:
- Adding new commands
- Improving existing functionality
- Adding support for more AI providers
- Enhancing the user interface
- Fixing bugs
📄 License
MIT License - feel free to use this project for personal or commercial purposes.
🆘 Troubleshooting
Common Issues
"No valid AI provider configured"
- Check your
.envfile has the correct API keys - Run
codex configto test your connection
- Check your
"Module not found" errors
- Run
npm installto install dependencies
- Run
"Permission denied" when running commands
- Make sure
cli.jsis executable:chmod +x cli.js
- Make sure
API rate limits
- Both OpenAI and Gemini have rate limits
- Wait a moment between requests if you hit limits
Getting Help
- Use
codex --helpfor command list - Use
codex configto test your setup - Check the
.envfile for proper API key configuration - Review command history with
codex history
Happy Coding! 🎉
Made with ❤️ for developers who love AI assistance in their terminal.
