Skip to content

Slash Commands

Every AI coding agent has a set of built-in commands you access by typing a forward slash. Gemini CLI has nine of them, and they do more than you'd guess from the names alone. /compact saves you from hitting the context ceiling mid-session. /init generates the scaffolding for a new project. /model lets you switch models without restarting. This lesson covers all nine, when to reach for each, and the ones you'll use daily versus the ones you'll touch once per project.

Owl mascot

What you'll learn

  • Nine slash commands: /help, /clear, /compact, /memory, /init, /model, /config, /status, /exit
  • Daily drivers: /compact (summarize when context fills up), /clear (reset the conversation), /model (switch models mid-session)
  • Project setup: /init generates GEMINI.md and directory structure; use it once per project
  • Diagnostics: /status shows token usage, model, and session stats; /config shows active configuration
  • Migration note: Antigravity CLI keeps these slash commands but may add new ones. The core set is stable across platforms.

The problem

A long session with Gemini CLI eventually hits a wall: the context window fills up, responses get less coherent, and you lose earlier parts of the conversation. You need to either restart (losing everything) or compact (keeping the gist). Meanwhile, switching models or checking token usage means digging through documentation. Slash commands solve all of this from inside the REPL, no exit required.

Options & when to use each

CommandWhat it doesWhen to use itWhat it costs you
/helpLists all slash commands with brief descriptionsFirst time in Gemini CLI, or you forgot what's availableNothing
/clearWipes the conversation historyYou've gone down a wrong path and want a clean slate, or you're starting a new task unrelated to the current oneLoses all context. The agent forgets everything from the session
/compactSummarizes the conversation so far, freeing context window spaceResponses are getting worse, or Gemini CLI warns you about context limitsLoses detail. The agent remembers the summary, not the specifics
/memoryShows or manages persistent memory across sessionsYou want to see what Gemini CLI remembers from past sessionsMemory takes context space. Too much memory crowds out the current task
/initGenerates a GEMINI.md file and project scaffoldingStarting a new project and want Gemini CLI to understand it from the first sessionCreates files. Review what it generates before committing
/modelSwitches the underlying modelYou want to try a different model for a specific task, or the current model is too slow/expensiveDifferent models have different capabilities and costs
/configShows current configuration settingsDebugging why a feature isn't working, or checking which model/provider is activeRead-only, no cost
/statusShows session stats: tokens used, model, uptimeChecking if you're close to the context limit, or monitoring usageRead-only, no cost
/exitExits the REPLYou're done, or you need to switch to a different project directoryEnds the session. Use /compact first if you want to preserve context for next time

Build it

Step 1: The daily drivers

Start a REPL session and run through the three commands you'll use every day:

bash
gemini

Enter the help command to view all available built-in operations.

text
> /help

You'll see the full list of slash commands. Make a note of any you don't recognize -- we'll cover them all.

text
> Write a Python script called hello.py that prints "Hello World" with the current timestamp

Gemini CLI creates the file. Now check your session status:

text
> /status

The output shows tokens used, the active model, and how many turns you've had. If tokens used is climbing toward the model's limit, it's time to compact.

text
> What's in hello.py?
> How many lines?
> Can you add error handling?

After a few more turns, compact the session:

text
> /compact

Gemini CLI summarizes everything that happened -- the file created, the edits made, the questions asked -- into a condensed form. The session continues, but with more headroom in the context window.

Now try clearing:

Issue the clear command to wipe the session history. This forces the agent to forget the preceding context.

text
> /clear

The conversation history is gone. Ask "What script did we just create?" and Gemini CLI won't know. /clear is a hard reset -- use it when you're switching to a completely different task.

Step 2: Model switching

Gemini CLI ships with access to multiple models. Switch mid-session:

text
> /model

Gemini CLI lists available models. Pick one by typing its name. If you're on a free tier, the selection may be limited. Paid tiers get access to larger and faster models.

The practical use: start a session with a fast, cheap model for exploration and reading files, then switch to a more capable model for complex edits or generation.

Step 3: Project initialization

Exit the REPL and create a test project:

bash
mkdir -p /tmp/gemini-demo
cd /tmp/gemini-demo
gemini

Inside the REPL:

Trigger the init workflow to generate the baseline configuration file for the project.

text
> /init

Gemini CLI scans the directory, asks a few questions about your project (language, framework, goals), and generates a GEMINI.md file. This file is loaded at the start of every session in this directory. We'll cover what goes in it in the next lesson.

Read what it generated:

Inspect the resulting markdown file to review the generated project context.

bash
cat GEMINI.md

The content will vary based on your answers, but it typically includes the project's language, build commands, coding conventions, and directory structure. Review it before committing -- /init makes reasonable guesses, but it doesn't know your project like you do.

Step 4: Check configuration

Display the active settings and model configuration. This helps troubleshoot connection or provider issues.

text
> /config

This shows the active provider, model, any custom settings, and feature flags. Use it when something isn't working the way you expect -- it's the first diagnostic step before searching documentation.

What goes wrong

MistakeHow you notice itThe fix
Run /clear too soon and lose important contextYou ask a follow-up question and Gemini CLI has no idea what you're talking aboutUse /compact instead of /clear when you want to preserve the gist. Only /clear when you genuinely want a reset
/compact loses a critical detailGemini CLI forgets a specific file path or variable name from earlier in the session/compact summarizes, it doesn't transcribe. After compacting, remind the agent of critical details that got dropped
Switch models and the new one can't complete the same taskResponses get worse or the model refuses tasks the previous model handledNot all models have the same capabilities. Switch back with /model or check /config to see what model you're on
/init generates a GEMINI.md that's wrong for your projectBuild commands are incorrect, or the file describes a different tech stack than you actually use/init is a starting point, not the final answer. Edit GEMINI.md by hand with real project details. We'll cover what to put in it in the next lesson
Forget which model you're onResponses are unexpectedly slow or fast, and you can't tell whyRun /status -- it shows the active model. Make a habit of checking after /model switches

Confirm it worked

Run this sequence in a single REPL session. Every command should work without errors:

text
# Start a REPL
gemini

# 1. Check available commands
> /help

# 2. Check status
> /status

# 3. Create a file
> Create /tmp/slash-test.txt with the text "slash commands working"

# 4. Compact the session
> /compact

# 5. Switch models (if multiple available)
> /model
# (select any available model)

# 6. Verify the file still exists (context survived compact)
> What's in /tmp/slash-test.txt?

# 7. Clear and confirm the reset
> /clear
> What file did we just create?
# (should respond that it doesn't know)

# 8. Exit
> /exit

If every command ran cleanly and the post-/clear response confirms the reset, you know all nine slash commands -- even the ones you'll use only once per project.

Next: GEMINI.md -- Project Context