Appearance
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.

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:
/initgenerates GEMINI.md and directory structure; use it once per project - Diagnostics:
/statusshows token usage, model, and session stats;/configshows 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
| Command | What it does | When to use it | What it costs you |
|---|---|---|---|
/help | Lists all slash commands with brief descriptions | First time in Gemini CLI, or you forgot what's available | Nothing |
/clear | Wipes the conversation history | You've gone down a wrong path and want a clean slate, or you're starting a new task unrelated to the current one | Loses all context. The agent forgets everything from the session |
/compact | Summarizes the conversation so far, freeing context window space | Responses are getting worse, or Gemini CLI warns you about context limits | Loses detail. The agent remembers the summary, not the specifics |
/memory | Shows or manages persistent memory across sessions | You want to see what Gemini CLI remembers from past sessions | Memory takes context space. Too much memory crowds out the current task |
/init | Generates a GEMINI.md file and project scaffolding | Starting a new project and want Gemini CLI to understand it from the first session | Creates files. Review what it generates before committing |
/model | Switches the underlying model | You want to try a different model for a specific task, or the current model is too slow/expensive | Different models have different capabilities and costs |
/config | Shows current configuration settings | Debugging why a feature isn't working, or checking which model/provider is active | Read-only, no cost |
/status | Shows session stats: tokens used, model, uptime | Checking if you're close to the context limit, or monitoring usage | Read-only, no cost |
/exit | Exits the REPL | You're done, or you need to switch to a different project directory | Ends 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
geminiEnter the help command to view all available built-in operations.
text
> /helpYou'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 timestampGemini CLI creates the file. Now check your session status:
text
> /statusThe 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
> /compactGemini 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
> /clearThe 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
> /modelGemini 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
geminiInside the REPL:
Trigger the init workflow to generate the baseline configuration file for the project.
text
> /initGemini 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.mdThe 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
> /configThis 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
| Mistake | How you notice it | The fix |
|---|---|---|
Run /clear too soon and lose important context | You ask a follow-up question and Gemini CLI has no idea what you're talking about | Use /compact instead of /clear when you want to preserve the gist. Only /clear when you genuinely want a reset |
/compact loses a critical detail | Gemini 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 task | Responses get worse or the model refuses tasks the previous model handled | Not 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 project | Build 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 on | Responses are unexpectedly slow or fast, and you can't tell why | Run /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
> /exitIf 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.