A powerful CLI tool that combines Repomix with Google Gemini AI to provide intelligent codebase analysis and guidance for achieving specific development goals.
- Intelligent Codebase Analysis: Automatically packs your entire codebase using repomix
- AI-Powered Guidance: Leverages Google Gemini AI to understand your code structure and provide actionable insights
- Goal-Oriented Analysis: Focuses analysis on helping you achieve specific development objectives
- Clipboard Integration: Optional copying of results to clipboard for easy sharing
- Beautiful CLI Interface: Clean, colored output with progress indicators
- Node.js: Version 16 or higher
- Gemini API Key: Get your API key from Google AI Studio
Note: Repomix is automatically downloaded and run via
npx
, so no global installation is required.
-
Clone or create the project files (package.json and index.js from above)
-
Install dependencies:
npm install
-
Install globally:
npm install -g .
Or use the included install script:
chmod +x install.sh ./install.sh
Or if you prefer to install directly from npm (after publishing):
npm install -g codebase-guide
Set your Gemini API key as an environment variable:
export GEMINI_API_KEY="your-gemini-api-key-here"
To make this permanent, add it to your shell profile (.bashrc
, .zshrc
, etc.):
echo 'export GEMINI_API_KEY="your-gemini-api-key-here"' >> ~/.zshrc
source ~/.zshrc
Navigate to your project directory and run:
codebase-guide "Add user authentication with JWT tokens"
You can also pipe the goal via stdin:
echo "Add user authentication with JWT tokens" | codebase-guide
cat my_goal.txt | codebase-guide
To keep the analysis focused on code and reduce processing time, the following file types are automatically ignored:
- Images: SVG, PNG, JPG, JPEG, GIF, BMP, TIFF, WebP, ICO, ICNS
- Videos: MP4, AVI, MOV, WMV, FLV, WebM, MKV
- Audio: MP3, WAV, FLAC, AAC, OGG, WMA
- Archives: ZIP, RAR, 7Z, TAR, GZ, BZ2
- Fonts: TTF, OTF, WOFF, WOFF2, EOT
- Executables: EXE, DLL, SO, DYLIB
- Documents: PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX
The tool also respects your .gitignore
file and repomix's default ignore patterns.
codebase-guide "Implement a REST API for blog posts" --copy
Specify a different Gemini model (default is gemini-2.5-pro-preview-05-06
):
codebase-guide "Your goal" --model "gemini-1.5-pro"
Suppress progress indicators for piping or scripting:
codebase-guide "Your goal" --quiet
Force pipe mode to output only the analysis result:
codebase-guide "Your goal" --pipe
By default, the tool ignores image files (SVG, PNG, JPG, etc.), binary files, and other non-text files to reduce the size of the analysis. You can add additional ignore patterns:
codebase-guide "Add user authentication" --additional-ignore "**/*.test.js,**/docs/**"
Here are some example goals you can use:
# Feature Development
codebase-guide "Add real-time chat functionality using WebSockets"
codebase-guide "Implement user roles and permissions system"
codebase-guide "Add payment processing with Stripe integration"
# Code Quality & Architecture
codebase-guide "Refactor the codebase to use TypeScript"
codebase-guide "Implement comprehensive error handling"
codebase-guide "Add unit tests for the core business logic"
# Performance & Optimization
codebase-guide "Optimize database queries and add caching"
codebase-guide "Implement lazy loading for large datasets"
codebase-guide "Add monitoring and logging capabilities"
# Migration & Updates
codebase-guide "Migrate from Express to Fastify"
codebase-guide "Update React components to use hooks"
codebase-guide "Add Docker containerization"
The AI analysis provides:
- Codebase Overview: High-level structure and key directories
- Relevant Files: Files most important for your goal
- Dependencies & Relationships: How components interact
- Implementation Areas: Where to focus your changes
- Potential Challenges: Issues to consider
- Action Plan: Suggested order of implementation
🤖 Codebase Guide
Goal: Add user authentication with JWT tokens
✓ Packing codebase with repomix...
✓ Analyzing codebase with Gemini AI...
✨ Analysis Complete!
────────────────────────────────────────────────────────────────────────────────
<analysis>
## Codebase Overview
Your Express.js application follows a standard MVC architecture with the following key directories:
### Key Directories
- `/src/routes/` - API endpoint definitions
- `/src/models/` - Database models and schemas
- `/src/middleware/` - Custom middleware functions
- `/src/controllers/` - Business logic handlers
## Relevant Files for JWT Authentication
1. **src/models/User.js** - User model that will need password hashing
2. **src/routes/auth.js** - Will need creation for auth endpoints
3. **src/middleware/auth.js** - JWT verification middleware to create
4. **package.json** - Dependencies to add (jsonwebtoken, bcrypt)
...
</analysis>
────────────────────────────────────────────────────────────────────────────────
✅ Result copied to clipboard!
-
GEMINI_API_KEY
: Your Google Gemini API key (required)
You can use either codebase-guide
or the shorter alias cg
:
cg "Add user authentication with JWT tokens"
- Codebase Packing: Uses repomix to create a comprehensive snapshot of your codebase
- AI Analysis: Sends your codebase and goal to Google Gemini for intelligent analysis
- Structured Guidance: Receives detailed, actionable guidance tailored to your specific goal
- Result Display: Shows the analysis in a clean, readable format
Ensure Node.js and npm are properly installed:
# Check if Node.js is installed
node --version
# Check if npm is installed
npm --version
If not installed, visit nodejs.org to download and install Node.js (which includes npm).
Set your API key:
export GEMINI_API_KEY="your-api-key-here"
Use additional ignore patterns to reduce size:
codebase-guide "Your goal" --additional-ignore "**/*.log,tmp/,node_modules/"
Check your Google AI Studio usage and quota limits.
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Repomix - For excellent codebase packing
- Google Gemini - For powerful AI analysis
- Commander.js - For CLI interface