An intelligent command-line tool that uses Claude AI to analyze, explain, and generate code.
- Code Analysis: Get detailed code quality assessments, bug detection, and optimization suggestions
- Code Explanation: Understand complex code with clear, step-by-step explanations
- Code Generation: Generate code from natural language descriptions
- Interactive Chat: Have conversations with Claude about your code
- Streaming Support: Real-time streaming responses for better UX
- Node.js 20 or higher
- Anthropic API key (Get one here)
- Clone the repository:
git clone <your-repo-url>
cd ai-code-assistant- Install dependencies:
npm install- Configure environment variables:
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEYnpm run dev analyze path/to/your/file.jsnpm run dev explain path/to/your/file.tsnpm run dev generate "create a function to validate email addresses" --language typescript# Regular response
npm run dev chat "How do I optimize this SQL query?"
# Streaming response
npm run dev chat "Explain async/await in JavaScript" --streamEdit .env file to customize:
ANTHROPIC_API_KEY: Your Anthropic API key (required)MODEL: Claude model to use (default: claude-sonnet-4-5-20250929)MAX_TOKENS: Maximum tokens per response (default: 4096)LOG_LEVEL: Logging level (info, warn, error, debug)
claude-sonnet-4-5-20250929: Best balance of speed and intelligence (recommended)claude-opus-4-5-20250929: Maximum capability for complex tasksclaude-haiku-3.5: Fast and cost-effective
# Run in development mode with auto-reload
npm run dev
# Build TypeScript
npm run build
# Run production build
npm start
# Run tests
npm test
# Lint code
npm run lint
# Format code
npm run formatai-code-assistant/
├── src/
│ ├── index.ts # CLI entry point
│ ├── api/
│ │ └── claude.ts # Claude API client
│ ├── utils/
│ │ ├── config.ts # Configuration management
│ │ └── logger.ts # Logging utilities
├── .claude/ # Claude Code configuration
│ ├── CLAUDE.md # Project context
│ ├── skills/ # Custom skills
│ └── commands/ # Slash commands
└── tests/ # Test files
This project includes Claude Code configuration in .claude/:
- Skills: Expert knowledge for Claude API integration
- Commands: Custom slash commands like
/analyzeand/explain - Context: Project-specific guidelines in CLAUDE.md
npm run dev analyze src/utils/helper.jsOutput:
Code Analysis:
==================================================
1. Code Quality: 8/10
- Well-structured and readable
- Good use of modern JavaScript features
2. Potential Issues:
- Missing error handling in line 15
- Potential null reference at line 23
3. Performance Optimizations:
- Consider memoization for expensive calculations
- Use Set instead of Array for uniqueness checks
...
- Always validate inputs before sending to the API
- Use streaming for longer responses
- Monitor token usage to control costs
- Implement rate limiting for production use
- Keep API keys secure (never commit .env files)
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit changes:
git commit -m 'feat: add new feature' - Push to branch:
git push origin feature/my-feature - Open a Pull Request
MIT
For issues and questions:
- Open an issue on GitHub
- Check Claude API Documentation
- Visit Anthropic Console