Build and Test
Complete guide to building, testing, and debugging Gemini CLI
Build Process
Understanding the build system and development workflow
npm run bootstrap
Install dependencies and link packages
Usage:
Initial setup and after adding new dependencies
npm run build
Build all packages in dependency order
Usage:
Before testing or releasing
npm run build:watch
Build packages in watch mode
Usage:
During active development
npm run clean
Clean build artifacts and node_modules
Usage:
When encountering build issues
Testing Framework
Comprehensive testing with Jest and TypeScript
npm run test
Run all tests across packages
Usage:
Full test suite execution
npm run test:watch
Run tests in watch mode
Usage:
During development
npm run test:coverage
Generate test coverage reports
Usage:
Quality assurance and CI/CD
lerna run test --scope @gemini/core
Run tests for specific package
Usage:
Focused testing
Development Workflow
Recommended development and testing workflow
Initial Setup
Set up development environment and install dependencies
git clone https://github.com/google-gemini/gemini-cli.git && cd gemini-cli && npm run bootstrap
Development Mode
Start watch mode for automatic rebuilding
npm run build:watch
Testing
Continuously run tests during development
npm run test:watch
Quality Check
Run code checks, formatting, and type checking before committing
npm run lint && npm run type-check && npm run test:coverage
Debugging
Tools and techniques for debugging issues
Debug Mode
Enable debug logging for detailed output
DEBUG=gemini:* gemini ask "Hello"
This will show detailed logs for all Gemini CLI operations
VS Code Debugging
Use the provided VS Code launch configuration
.vscode/launch.json
Set breakpoints and debug directly in VS Code
Test Debugging
Debug specific tests
npm run test -- --testNamePattern="API Client"
Run and debug specific test cases
Performance Profiling
Profile performance issues
node --prof packages/cli/bin/gemini
Generate performance profiles for analysis
Continuous Integration
Automated testing and quality assurance
Build
Compile TypeScript and build all packages
Test
Run unit tests and generate coverage reports
Deploy
Publish packages and deploy documentation
Common Issues
Solutions to common build and test problems
Build Failures
If builds fail after pulling changes, try cleaning and reinstalling
npm run clean && npm run bootstrap && npm run build
Test Failures
For intermittent test failures, run tests with increased timeout
npm run test -- --testTimeout=10000
Memory Issues
If you encounter out-of-memory errors during builds
NODE_OPTIONS="--max-old-space-size=4096" npm run build
Next Steps
Continue your development journey with these resources