Project Structure
Understanding the codebase organization and architecture of Gemini CLI
Project Overview
Gemini CLI is organized as a monorepo with multiple interconnected packages
Gemini CLI is a Lerna-based monorepo project that modularizes functionality into independent packages for easier development, testing, and maintenance.
Package Structure
Core packages that make up the Gemini CLI ecosystem
CLI Package
packages/cliMain command-line interface and user-facing commands
Key Responsibilities:
- Command parsing and routing
- User interface and interaction
- Configuration management
- Error handling and reporting
- Help and documentation display
Core Package
packages/coreCore functionality and business logic
Key Responsibilities:
- API client implementations
- Model interactions
- Tool management system
- MCP protocol handling
- State management
Tools Package
packages/toolsBuilt-in tools and utilities
Key Responsibilities:
- File system operations
- Shell command execution
- Web requests and searches
- Memory management
- Tool registration
Extensions Package
packages/extensionsExtension system and plugin management
Key Responsibilities:
- Extension loading and management
- Plugin registry
- Extension API
- Lifecycle management
- Dependency resolution
Development Workflow
How to work with the codebase effectively
Global Commands
npm run bootstrapInstall and link all packages
npm run buildBuild all packages
npm run testRun all tests
npm run lintLint all packages
Package-specific Commands
lerna run build --scope @gemini/cliBuild specific package
lerna run test --scope @gemini/coreTest specific package
lerna add lodash packages/coreAdd dependency to package
Architecture Principles
Key principles guiding the project structure
Modular Design
Each package has a single responsibility
- Clear separation of concerns
- Minimal inter-package dependencies
- Well-defined interfaces
- Independent testing
Extensible Architecture
Built for extensibility and customization
- Plugin-based architecture
- Tool registration system
- Event-driven communication
- Configuration-driven behavior
Next Steps
Continue your development journey with these resources