This document contains hands-on exercises for learning to use Gemini CLI for professional development workflows.
- Lab 1: Getting Started and Project Creation
- Lab 2: Code Exploration
- Lab 3: GEMINI.md and Context Management
- Lab 4: Test Generation
- Lab 5: Configuration and Safety
- Lab 6: Advanced Features
- Lab 7: Optional Team Adoption Module
- Gemini CLI installed:
npm install -g @google/gemini-cli(version 0.37.x or later) - API key set:
export GEMINI_API_KEY="your-key" - Git installed and configured
- Development environment for Python, JavaScript, or Java
- Docker (optional, for sandbox mode)
As of Gemini CLI 0.34, plan is the default approval mode. When you launch
gemini, it will draft a plan before executing any tool calls. For most
of these labs you'll want to accept the plan (press Shift+Tab to cycle
modes, or accept each step) before commands run. If a step feels "stuck,"
check whether Gemini is waiting for plan approval.
To skip plan mode entirely for a lab step:
gemini --approval-mode default # per-tool approval
gemini --approval-mode auto_edit # auto-approve editsAlso note the keyboard shortcut change in 0.37: Ctrl+G opens the
external editor (it used to be Ctrl+X).
Duration: 25 minutes
Goal: Get comfortable with Gemini CLI while building a task manager application from scratch
-
Create a new empty directory:
mkdir my-task-manager && cd my-task-manager
-
Initialize git:
git init
-
Start Gemini CLI:
gemini
-
Explore the interface:
What are your main capabilities for helping with development?Then explore the available commands:
/helpReview the slash commands before diving in.
-
Project foundation:
Create a Node.js task manager application with: - A Task class with id, title, description, status, and dueDate - Functions to add, remove, update, and list tasks - JSON file storage for persistence - A simple CLI interface using readline -
Check your work with shell integration:
!ls -laUse shell commands to see what Gemini created. Observe how the output is displayed.
-
Enhanced functionality (Stretch Goal - if time permits):
Add these features to the task manager: - Filter tasks by status (pending, in-progress, completed) - Sort tasks by due date - Search tasks by title or description - Colored console output for different statuses -
Check context and memory:
/memory showSee what context Gemini has loaded about your project.
-
Testing:
Create comprehensive tests for the task manager using Jest: - Unit tests for all Task class methods - Integration tests for file persistence - Edge cases like empty lists, invalid inputs -
Documentation:
Create a README.md with: - Project description and features - Installation instructions - Usage examples with sample output - API documentation for developers -
Keyboard shortcuts: Before moving to git, try these shortcuts:
Ctrl+Lto clear the screenCtrl+Yto toggle YOLO mode (observe the indicator change)Ctrl+Yagain to toggle back to default mode
-
Git workflow:
Help me create a proper commit history: 1. Commit the initial project structure 2. Create a feature branch for "priority-levels" 3. Add priority (low, medium, high) to tasks 4. Create a commit message following conventional commits
- Understand Gemini CLI's conversational interface
- Know essential slash commands and keyboard shortcuts
- Build a functional application from scratch
- Experience iterative development with AI assistance
- Practice the full development cycle: concept → code → tests → docs
- Be comfortable with shell integration
Duration: 15 minutes
Goal: Use Gemini CLI to understand complex codebases
Choose one of the provided exercise projects:
exercises/python/weather-app(Flask application)exercises/javascript/task-manager(Node.js CLI app)exercises/java/bookstore-api(Spring Boot REST API)
Navigate to the project directory and start Gemini CLI.
-
Project overview:
Analyze the architecture of this project and explain the main components. Reference @./src/ (or @. for a flat project like the Python weather app) to examine the source code. -
Technology identification:
What frameworks, libraries, and tools does this project use? Check @./package.json or @./pom.xml for dependencies. -
Entry point discovery:
Show me the main entry point of this application and trace the initialization flow. -
File reference practice:
Explain how the main routing logic handles incoming requests. - Python: @app/routes/weather.py - Java: @src/main/java/com/example/bookstore/controller/BookController.java - JavaScript: @src/taskManager.js -
Architecture documentation:
Create a Mermaid diagram showing the main components and their relationships in this project. -
Web search integration:
Search the web for best practices for [Flask/Express/Spring Boot] application structure and compare with this project.
- Quickly understand unfamiliar codebases
- Master file references with
@syntax - Leverage web search for current best practices
- Generate visual documentation
Duration: 20 minutes
Goal: Set up effective project context using GEMINI.md files
Continue with the project from Lab 2, or start fresh in a new directory.
-
Generate initial GEMINI.md:
/initReview the generated file and understand its structure.
-
Customize the context:
Update the GEMINI.md to include: - Our team's coding standards (PEP 8 for Python, or equivalent) - Preferred testing frameworks and patterns - Current sprint focus: implementing caching - Code review checklist items -
Test context loading:
/memory showVerify your customizations are loaded.
-
Create hierarchical context:
# Create subdirectory-specific context mkdir -p src/apiThen ask Gemini:
Create a GEMINI.md file for the src/api/ directory that specifies: - All API endpoints should return JSON - Use consistent error response format - Include request validation - Document all endpoints with OpenAPI comments -
Global context setup:
Help me create a global GEMINI.md at ~/.gemini/GEMINI.md with: - My preferred coding style (concise, well-documented) - Common libraries I use across projects - My Git commit message format preferences -
Modular imports:
Break the project GEMINI.md into modular files: - Create docs/coding-standards.md - Create docs/api-guidelines.md - Update GEMINI.md to import these using @docs/coding-standards.md syntax -
Refresh and verify:
/memory refresh /memory showConfirm all contexts are properly loaded.
- Create effective GEMINI.md files
- Understand hierarchical context loading
- Use modular imports for maintainability
- Set up global and project-specific context
Duration: 15 minutes
Goal: Generate comprehensive test suites with Gemini CLI
Use the project from previous labs or choose a new exercise project with existing source code.
-
Unit test generation:
Create unit tests for a chosen file: - Java: @exercises/java/bookstore-api/src/main/java/com/example/bookstore/service/BookService.java using JUnit 5 - JavaScript: @exercises/javascript/task-manager/src/taskManager.js using Jest - Python: @exercises/python/weather-app/app/services/weather_service.py using pytest Requirements: - Tests for all public methods - Edge cases (empty inputs, null values) - Mocking of external dependencies -
Test coverage analysis:
Analyze @./src/models/ and identify which classes and methods are missing test coverage. Generate tests to fill the gaps. -
Edge case discovery:
What edge cases should I test for the user authentication flow? List them and generate test cases for each. -
Integration tests:
Create integration tests for the API endpoints in @./src/routes/ that test the full request-response cycle with test fixtures. -
Test data generation:
Generate realistic test fixtures for: - 10 sample users with varied data - 20 sample tasks with different statuses and dates - Edge cases like unicode characters, very long strings Save as JSON files in tests/fixtures/ -
Run and verify:
# Execute the generated tests !pytest -v # Or for Node.js: !npm test
Then ask:
Analyze the test results and fix any failing tests.
- Generate comprehensive test suites
- Identify and test edge cases
- Create realistic test fixtures
- Iterate on failing tests
Duration: 20 minutes
Goal: Configure Gemini CLI for safe, efficient workflows
Create a test project for experimenting with configuration:
mkdir config-test && cd config-test
git init
echo "# Config Test" > README.md-
Explore settings:
/settingsReview the current settings interface.
-
Create project settings:
Create a .gemini/settings.json file with: - Use the current nested schema sections (general/ui/tools) - Vim mode enabled - Checkpointing enabled - Sandbox mode disabled - Hide tips set to true -
Tool restrictions:
Update settings.json to: - Exclude the run_shell_command tool for safety - Use tools.allowed to only allow read_file, write_file, and glob tools -
Test sandbox mode:
# Start in sandbox mode gemini --sandboxThen try:
Create a file called test.txt with "Hello World"Observe how sandbox mode affects file operations.
-
Checkpointing practice:
Enable checkpointing in settings, then:
Create a complex file structure: - src/index.js with a basic Express server - src/routes/api.js with sample routes - package.json with dependenciesThen:
/restoreView available checkpoints.
-
Approval modes:
# Try different approval modes gemini --approval-mode auto_editRequest a file edit and observe auto-approval behavior.
# Compare with YOLO mode gemini --approval-mode yoloTry creating files and observe the difference.
-
Environment variables:
Create a .gemini/.env file with: GEMINI_MODEL=gemini-2.5-flash Then restart Gemini and verify the model change.
- Configure project-specific settings
- Understand sandbox and checkpointing
- Practice different approval modes
- Set up environment-based configuration
Duration: 30 minutes
Goal: Master MCP servers, extensions, custom commands, and session management
-
Create a session: Start an interactive session and do some work:
gemini > Create a simple Python calculator module with add, subtract, multiply, divide > Add error handling for division by zero > Create tests for the calculatorExit with
Ctrl+D -
List sessions:
gemini --list-sessions
-
Resume session:
gemini --resume
Continue where you left off:
Add a power function to the calculator and update the tests -
Session browser and rewind: In interactive mode, run:
/resume /rewindReview what each workflow enables and when you'd prefer one over the other.
-
Create a review command:
mkdir -p ~/.gemini/commandsThen create the file
~/.gemini/commands/review.tomlwith:description = "Review code for security, performance, and best practices" prompt = """ Review the provided code for: - Security vulnerabilities (injection, credentials, validation) - Performance issues (inefficient algorithms, resource leaks) - Best practices and code quality Provide findings with severity levels: - CRITICAL: Must fix before deployment - WARNING: Should fix soon - INFO: Consider improving {{args}} """
-
Test the custom command: In a new session, create a file to review:
Create a file called sample.py with some intentionally problematic code: - SQL injection vulnerability - Hardcoded credentials - Inefficient loopThen use your command:
/review @./sample.py -
Create a docs command: Create the file
~/.gemini/commands/docs.tomlwith:description = "Generate documentation for code" prompt = """ Generate comprehensive documentation for the provided code: - Function signatures with parameters and return types - Usage examples - Markdown format suitable for a README {{args}} """
-
List available MCP servers:
gemini mcp list
-
Configure Firecrawl MCP:
Help me configure the Firecrawl MCP server in .gemini/settings.json: - Use the @modelcontextprotocol/server-firecrawl package - Set up my FIRECRAWL_API_KEY from environment - Ensure it allows scraping web content -
Test MCP integration:
If configured:
```
Use the Firecrawl MCP to search for "latest features of Gemini 3 Pro" and summarize the findings.
```
-
Explore MCP tools:
What MCP tools are available in this session? Show me an example of using one of them. -
Prompt quality booster:
/prompt-suggestAsk Gemini for 3 stronger variants of your last MCP prompt and compare the results.
-
JSON output for scripting:
gemini -o json "List the files in current directory and describe each"Observe the structured output format.
-
Stream JSON:
gemini -o stream-json "Explain the concept of microservices architecture"Watch the real-time streaming output.
-
Piped workflows:
echo "What are the top 5 Python web frameworks?" | gemini -o json
-
List extensions:
gemini --list-extensions
-
Create a simple extension:
Help me create a basic extension at ~/.gemini/extensions/my-tools/ that adds a custom tool for formatting code. Include the gemini-extension.json configuration. -
Enable specific extensions:
gemini -e my-tools "Format the code in @./src/"
After completing this lab:
- Manage and resume sessions effectively
- Create reusable custom commands
- Configure and use MCP servers
- Use output formats for automation
- Understand the extension system
Duration: 30-45 minutes (optional / take-home)
Goal: Practice production-oriented workflows for authentication strategy, governance, skills/MCP controls, and CI automation.
-
Compare auth options: Create a short matrix in
AUTH_NOTES.mdthat compares:- Login with Google
GEMINI_API_KEY- Vertex AI with ADC
- Service account credentials for CI
Include when each is preferred and one drawback.
-
Validate one non-default path: Choose one of these:
- Vertex path (
GOOGLE_CLOUD_PROJECT,GOOGLE_CLOUD_LOCATION) - API-key path (
GEMINI_API_KEY)
Then run:
gemini --version gemini --list-sessions
Confirm your environment is usable with the chosen auth setup.
- Vertex path (
-
Create a team-safe project settings file: In
.gemini/settings.json, configure:general.defaultApprovalModetoauto_editorplantools.sandboxenabledgeneral.checkpointing.enabledset totrue
Then create a
policy.tomlfile alongside it with adenyrule forrun_shell_commandand launch Gemini withgemini --policy policy.toml. (The legacytools.excludekey still works but is deprecated as of Gemini CLI 0.30 — the Policy Engine is the forward path.) -
Inspect hooks and policy behavior: In interactive mode, run:
/hooks list /policies listAsk Gemini to explain what each active control does and which risks it reduces.
-
Skills lifecycle drill: In interactive mode:
/skills list /skills disable <one-skill-name> /skills enable <one-skill-name>Observe how discoverable skills change.
-
MCP scoping exercise: Update one MCP server in
.gemini/settings.jsonto:- Add
includeToolsfor only the tools you need - Add
excludeToolsfor at least one sensitive tool
Then run:
gemini mcp list
In interactive mode:
/mcp list /mcp refresh - Add
-
MCP resource prompt practice: If your MCP server exposes resources, use one URI with
@...in a prompt and summarize what changed versus a tool-only prompt.
-
Create a repeatable automation check: Add a script snippet to
automation_notes.md:gemini -o json "Review @./src/ for security issues" > review.json if gemini -o json "Summarize risk level in one sentence"; then echo "Gemini check completed" else echo "Gemini check failed" && exit 1 fi
-
Post-process output: Parse
review.jsonwith your preferred tool (jq, Node, Python) and extract one field for a simple pass/fail decision.
After completing this optional lab:
- Choose the right auth method for local, team, and CI contexts
- Apply practical governance controls with settings, hooks, and policies
- Restrict MCP/skills behavior to safer team defaults
- Build a basic non-interactive Gemini CLI automation pattern
- Be specific about what you want to achieve
- Use file references (
@path/to/file) for context - Iterate for complex tasks - don't try everything at once
- Provide examples when the output format matters
- Start with default approval mode, use YOLO after building trust
- Enable checkpointing before risky operations
- Keep GEMINI.md files updated with current project state
- Commit regularly to have a safety net
- Review all AI-generated code before accepting
Issue: Gemini doesn't understand the project structure Solution: Create a comprehensive GEMINI.md with architecture details
Issue: Generated code doesn't match project style Solution: Add coding standards to your GEMINI.md
Issue: API rate limits Solution: Use Gemini 2.5 Flash for faster, cheaper operations
Issue: Context not loading
Solution: Run /memory refresh and check file paths
Issue: MCP server not connecting
Solution: Check server configuration in settings.json, then use gemini mcp list and /mcp refresh
After completing these labs:
- Practice daily: Use Gemini CLI for regular development tasks
- Customize: Build your personal GEMINI.md and command library
- Explore MCP: Set up servers for your common tools and services
- Share: Document workflows for your team
- Stay updated: Follow Gemini CLI releases for new features
- Gemini CLI Documentation
- Google AI Studio - API keys and playground
- MCP Server Registry
- Gemini CLI Cheatsheet