Skip to content

Vibe Coding with AI CLIs

"Vibe coding" just means treating natural language as your primary way of directing a codebase, telling an AI CLI what you want built, fixed, or refactored, instead of typing every line yourself. Gemini CLI is where you'll do most of that in this course, and the difference between using it casually and using it well comes down to five specific habits: giving it persistent memory of your project, scripting your own repeatable commands, feeding it real file context instead of making it guess, knowing when to let it run unattended, and always having an undo button ready when it doesn't. Five short labs, one habit each.

Run every lab below from your workspace: ~/AI_BOOTCAMP. For a deeper reference on Gemini CLI beyond these five habits, see the full tips guide.

Gnome mascot

What you'll learn

  • Persistent project memory via GEMINI.md, loaded automatically every session
  • Building custom slash commands to script repetitive workflows
  • Checkpointing and /restore as a lightweight undo button for AI-made changes

🗺️ gemini-cli Training Curriculum Map

This roadmap outlines the progression of labs in this lesson, taking you from initial context setup to advanced automation and safety mechanisms:


📦 Lab 1: Persistent Project Context & Memory Setup

NOTE

Stop repeating setup instructions in your chat prompts. A local GEMINI.md holds permanent project rules; /memory stores dynamic insights you pick up during an active debug session.

🎯 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

Package a complex, multi-line prompt you use often, a security audit, a schema generator, a test-writing pass, into an instant, reusable custom slash command instead of retyping it every time.

🎯 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

Never let the model guess at file contents or fly blind on shell output. Use @ to inject a real file or directory into the prompt, and ! to run a system command directly without leaving 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

Gemini CLI can write helper scripts and run them on the fly. YOLO mode skips the confirmation prompt for every action, which is what makes large batch tasks fast, and what makes it genuinely risky on a filesystem you care about. Use it deliberately, not as a default.

🎯 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

YOLO mode and complex multi-file refactors can both leave you with broken imports or a buggy edit you didn't ask for. Checkpointing is what turns that from a disaster into a one-command revert.

🎯 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!

What goes wrong

MistakeHow you notice itThe fix
Repeating the same setup context in every promptYou're retyping your stack/conventions constantly, and the model still sometimes forgets them mid-sessionPut it in GEMINI.md once, it loads automatically every session
Running YOLO mode as a default habitAn unattended edit does something you didn't intend, with no confirmation step to catch itReserve YOLO mode for batch tasks you've thought through; leave confirmations on otherwise
Refactoring without checkpointing enabledA broken multi-file edit has no clean way backLaunch with gemini --checkpointing before any refactor you're not 100% sure about
Asking the model to reason about a file it hasn't actually seenConfidently wrong suggestions about code that doesn't match what's really thereInject the real file with @path/to/file instead of describing it from memory

Confirm it worked

Run /memory show after Lab 1 and confirm your project's real stack details come back, not a generic answer, but your actual conda environment name and database port. Then run /restore list after Lab 5's intentional bad refactor and confirm the pre-refactor snapshot is there, ready to roll back to. If both check out, Gemini CLI is actually configured for this course, not just installed.

Next: Prompting & Context Engineering , the craft underneath every prompt you just wrote in these labs.