Appearance
🤖 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
- Initialize the Local Context File: Launch the terminal inside your workspace and generate the starter template:bashThis will create a
cd ~/AI_BOOTCAMP npx @google/gemini-cli gemini> /init.gemini/GEMINI.mdfile in the root ofAI_BOOTCAMP. - Apply Your AI Engineering Guidelines: Open the newly created
.gemini/GEMINI.mdand 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`. - Audit Loaded Memory: In the Gemini CLI, verify that the context was loaded successfully:bash
gemini> /memory show - Add Dynamic Fact Memory: During your session, instruct Gemini to remember the PostgreSQL credentials from your
tools.yamlwithout editing the markdown file manually:bashVerify it appended to your memory list usinggemini> /memory add "PostgreSQL credentials: User 'agent_user', DB 'postgres', Password 'YOUR_DB_PASSWORD'"/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
- Create the Commands Directory: Create the folder structure inside your
.geminiworkspace folder:bashcd ~/AI_BOOTCAMP mkdir -p .gemini/commands/agent - Draft the Custom TOML Command: Create a new file named
new.tomlinside.gemini/commands/agent/: Path:~/AI_BOOTCAMP/.gemini/commands/agent/new.tomlWrite 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'. """ - Execute the Command: Restart or refresh your Gemini CLI session, and run your new custom shortcut:bashWatch as Gemini CLI parses the template, generates the code, and creates the file inside your
gemini> /agent:new "WorkflowOrchestrator"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
- Direct Context Injection: Start Gemini CLI and inject the agent code directly into the prompt using the
@symbol:bashgemini> Audit this file for async race conditions or performance issues: @./01_cli_tools/WorkflowOrchestrator_agent.py - Review Proposed Edits: When Gemini proposes optimization edits, inspect the
/diffwindow to check what changes it suggests. - Execute Shell Commands (Bang
!): Instead of exiting the chat to run a linter or test, execute a shell command directly from thegemini>prompt using!:bashThis maintains your active chat context while giving you direct console access!gemini> !pytest -v 01_cli_tools/ # Or to check python version in the active environment: gemini> !~/miniconda3/envs/ai_dev/bin/python --version
⚡ 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
- Enable YOLO Mode: Launch Gemini CLI in YOLO mode, or toggle it inside your active session by pressing
Ctrl + Y:bashgemini --yolo # (Notice the auto-approve indicator active in your terminal) - 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. - 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.pyimmediately. - 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
- Boot with Checkpoints Active: Launch the CLI with checkpointing enabled:bash
gemini --checkpointing - Simulate a Destructive Refactor: Command the AI to apply an aggressive modification:bashApprove the tool execution. Look for the console message:
gemini> Delete all comments and docstrings in '01_cli_tools/secret_scanner.py' and change all variable names to single characters.[Checkpoint saved]. - Inspect the Damage: Look at the messy output file. You have a broken, unreadable script.
- Revert via
/restore: List available snapshots:bashRoll back to the snapshot captured before the refactor was executed:gemini> /restore listbashOpen the scanner file—it is fully restored with comments, docstrings, and original variables intact!gemini> /restore 0