Skip to content

🤖 Gemini CLI Masterclass: Hands-On Training Program

This program is built from the ground up to train you to become a power user of the Gemini CLI, your primary AI coding assistant. It incorporates the core principles, pro-tips, and hidden terminal features derived from Addy Osmani's canonical Gemini CLI Tips and Tricks guide.

All labs and projects are to be executed inside your optimized workspace:
📁 ~/AI_BOOTCAMP


🗺️ Gemini CLI Training Curriculum Map


📦 Lab 1: Persistent Project Context & Memory Setup

NOTE

Tip 1 & 4 (Addy's Guide): Stop repeating setup instructions in your chat prompts. Use a local GEMINI.md for permanent project rules, and leverage /memory to store dynamic insights during active debug sessions.

🎯 Goal

Seed Gemini CLI with your active environment (ai_dev conda env, PostgreSQL port 5432 from tools.yaml, and the ~/AI_BOOTCAMP folder structure) so it always knows your tech stack out-of-the-box.

🚶 Step-by-Step Instructions

  1. Initialize the Local Context File: Launch the terminal inside your workspace and generate the starter template:
    bash
    cd ~/AI_BOOTCAMP
    npx @google/gemini-cli
    gemini> /init
    This will create a .gemini/GEMINI.md file in the root of AI_BOOTCAMP.
  2. Apply Your AI Engineering Guidelines: Open the newly created .gemini/GEMINI.md and overwrite it with this clean, project-specific context block:
    markdown
    # AI_BOOTCAMP - AI Bootcamp Workspace Context
    
    ## Active Dev Environment
    - **Language**: Python >=3.10
    - **Primary Env**: Conda environment `ai_dev`
    - **Package Installer**: `uv` (Rust-based)
    - **Database**: PostgreSQL (port 5432, vector search enabled)
    
    ## Coding Standards
    - Write clean, asynchronous code using Python's `asyncio` wherever possible.
    - Always enforce strict data validation utilizing `Pydantic v2`.
    - Provide complete drop-in replacement snippets instead of placeholders like `// TODO`.
  3. Audit Loaded Memory: In the Gemini CLI, verify that the context was loaded successfully:
    bash
    gemini> /memory show
  4. Add Dynamic Fact Memory: During your session, instruct Gemini to remember the PostgreSQL credentials from your tools.yaml without editing the markdown file manually:
    bash
    gemini> /memory add "PostgreSQL credentials: User 'agent_user', DB 'postgres', Password 'YOUR_DB_PASSWORD'"
    Verify it appended to your memory list using /memory show.

⌨️ Lab 2: Custom Slash Commands (TOML Scripting)

TIP

Tip 2 (Addy's Guide): Package your complex, multi-line prompts (like security auditing, SQL schema generation, or unit-test writing) into instant, reusable custom slash commands.

🎯 Goal

Create a custom slash command /agent:new that takes a name as an argument and generates a boilerplate asynchronous FastAPI agent script inside AI_BOOTCAMP.

🚶 Step-by-Step Instructions

  1. Create the Commands Directory: Create the folder structure inside your .gemini workspace folder:
    bash
    cd ~/AI_BOOTCAMP
    mkdir -p .gemini/commands/agent
  2. Draft the Custom TOML Command: Create a new file named new.toml inside .gemini/commands/agent/: Path: ~/AI_BOOTCAMP/.gemini/commands/agent/new.toml Write the following structure:
    toml
    # Invoked inside Gemini CLI as: /agent:new "MyBillingAgent"
    description = "Generates a boilerplate asynchronous FastAPI agent structure."
    prompt = """
    You are an expert AI software architect. Please write a fully implemented, production-grade asynchronous Python FastAPI agent boilerplate.
    
    Specifications:
    1. The agent class name should be: {{args}}
    2. Utilize Pydantic v2 for validating request payloads.
    3. Include a robust mock cognitive loop using asyncio.sleep().
    4. Provide logging using Python's standard `logging` library.
    5. Save this code into a file named '01_cli_tools/{{args}}_agent.py'.
    """
  3. Execute the Command: Restart or refresh your Gemini CLI session, and run your new custom shortcut:
    bash
    gemini> /agent:new "WorkflowOrchestrator"
    Watch as Gemini CLI parses the template, generates the code, and creates the file inside your 01_cli_tools/ folder!

📂 Lab 3: Context Injection & Shell Passthrough

IMPORTANT

Tip 7 & 16 (Addy's Guide): Avoid asking the AI to guess file contents or execute shell steps blind. Use @ to inject files and directories, and ! to execute system commands directly without exiting the REPL.

🎯 Goal

Perform a security and performance audit on your newly generated agent file using explicit file context and direct terminal feedback.

🚶 Step-by-Step Instructions

  1. Direct Context Injection: Start Gemini CLI and inject the agent code directly into the prompt using the @ symbol:
    bash
    gemini> Audit this file for async race conditions or performance issues: @./01_cli_tools/WorkflowOrchestrator_agent.py
  2. Review Proposed Edits: When Gemini proposes optimization edits, inspect the /diff window to check what changes it suggests.
  3. Execute Shell Commands (Bang !): Instead of exiting the chat to run a linter or test, execute a shell command directly from the gemini> prompt using !:
    bash
    gemini> !pytest -v 01_cli_tools/
    # Or to check python version in the active environment:
    gemini> !~/miniconda3/envs/ai_dev/bin/python --version
    This maintains your active chat context while giving you direct console access!

⚡ Lab 4: On-the-Fly Tool Creation & YOLO Mode

CAUTION

Tip 8 & 10 (Addy's Guide): Gemini CLI can autonomously write helper scripts and execute them on the fly. By enabling YOLO Mode, you bypass confirmations to automate large-scale batch tasks. Use with extreme caution on sensitive filesystems.

🎯 Goal

Write an autonomous helper tool that scrapes all .py files in your workspace, finds any hardcoded passwords, and flags them. We will run this in YOLO mode to fast-track file creation and execution.

🚶 Step-by-Step Instructions

  1. Enable YOLO Mode: Launch Gemini CLI in YOLO mode, or toggle it inside your active session by pressing Ctrl + Y:
    bash
    gemini --yolo
    # (Notice the auto-approve indicator active in your terminal)
  2. Request On-the-Fly Automation: Prompt the assistant to build and run a security utility script:
    bash
    gemini> Create a python script '01_cli_tools/secret_scanner.py' that recursively searches the current directory for hardcoded API keys or passwords using regex. Then, execute the script and output the results.
  3. Observe Autonomous Execution: Because YOLO mode is enabled, Gemini CLI will:
    • Write the python scanner file immediately.
    • Run ~/miniconda3/envs/ai_dev/bin/python 01_cli_tools/secret_scanner.py immediately.
    • Deliver the scanner logs directly in your chat without a single prompt pause!

🛡️ Lab 5: Safety Nets, Checkpointing & /restore

WARNING

Tip 5 (Addy's Guide): YOLO mode or complex multi-file refactors can sometimes lead to broken imports or buggy edits. Always enforce checkpointing to get a "revert button" for AI filesystem edits.

🎯 Goal

Enable checkpointing, intentionally command the AI to execute a destructive or broken refactor, and roll back the workspace to its exact prior state.

🚶 Step-by-Step Instructions

  1. Boot with Checkpoints Active: Launch the CLI with checkpointing enabled:
    bash
    gemini --checkpointing
  2. Simulate a Destructive Refactor: Command the AI to apply an aggressive modification:
    bash
    gemini> Delete all comments and docstrings in '01_cli_tools/secret_scanner.py' and change all variable names to single characters.
    Approve the tool execution. Look for the console message: [Checkpoint saved].
  3. Inspect the Damage: Look at the messy output file. You have a broken, unreadable script.
  4. Revert via /restore: List available snapshots:
    bash
    gemini> /restore list
    Roll back to the snapshot captured before the refactor was executed:
    bash
    gemini> /restore 0
    Open the scanner file—it is fully restored with comments, docstrings, and original variables intact!