The Cartographer · 10 min mission
Tools & Commands: How You Drive Gemini CLI
Master the built-in tools, slash commands, @ file refs, and ! shell — and who calls what.
On this page
Gemini CLI (@google/gemini-cli, stable v0.46.0, released 2026-06-10) runs an agent loop: the model requests a built-in tool, you approve it, the CLI runs it and returns the result, repeat. You never call a tool by name. This guide covers the tool set the model calls, the slash commands you type to drive the CLI, and the @path and !command prefixes that feed the prompt. After it you can read /tools output, restrict the tool set in settings.json, and route file content or shell output into a request.
Two name spaces
Tools are functions the model calls — read_file, run_shell_command, google_web_search. You see them in approval prompts and in /tools output, but you never type them. Slash commands are what you type to steer the program. Tool names drift between versions (text search is now grep_search, not the older search_file_content), so trust /tools over memory.
| Tool | Family | What it does | Approval |
|---|---|---|---|
list_directory *(ReadFolder)* | File system | Lists files/subdirs; arg dir_path; honors .gitignore / .geminiignore | Auto (read-only) |
read_file *(ReadFile)* | File system | Reads one file (text, images, audio, PDF); args file_path, offset, limit | Auto (read-only) |
glob *(FindFiles)* | File system | Finds files by pattern, newest first; respect_git_ignore default true | Auto (read-only) |
grep_search *(SearchText)* | File system | Regex content search; uses git grep when available; arg pattern | Auto (read-only) |
read_many_files | File system | Reads/concatenates many files; this is what the @ syntax fires internally | Auto (read-only) |
write_file *(WriteFile)* | File system | Creates/overwrites a file; args file_path, content | Prompts you |
replace *(Edit)* | File system | In-file edit; expects one match unless allow_multiple: true | Prompts you |
run_shell_command | Execution | bash -c (or powershell.exe -NoProfile -Command on Windows); sets GEMINI_CLI=1 | Prompts you |
google_web_search | Web | Google Search; arg query; returns a grounded summary with source links | Auto (read-only) |
web_fetch | Web | Fetches URLs in the prompt (up to 20); uses Gemini API urlContext | Auto (confirms in Plan Mode) |
Planning and interaction tools
The agent has a layer of tools it calls on its own; you never type them:
ask_user— pauses to ask 1–4 questions of typechoice,text, oryesno.write_todos— session todo list, exactly one taskin_progressat a time (status enumpending|in_progress|completed|cancelled|blocked); toggle the view with Ctrl+T.enter_plan_mode/exit_plan_mode— flip into read-only Plan Mode;exit_plan_modewrites the finalized plan to~/.gemini/tmp/<project>/plans/.enter_plan_modeis unavailable in YOLO mode.list_mcp_resources/read_mcp_resource— read resources from connected MCP servers (read-only;serverNameoptional,urirequired).activate_skill— loads procedural expertise from.gemini/skills(argname).get_internal_docs— reads Gemini CLI's owndocs/so it answers about itself accurately.
Slash commands you drive the CLI with
Slash commands steer the program, not the conversation. There are 40-plus; /help prints the full list. Below are the ones to know on day one.
| Command | What it does |
|---|---|
/help (/?) | Lists every command and shortcut |
/tools ([desc]) | Lists tools the agent can call now; /tools desc adds descriptions |
/stats | Session statistics — /stats session (default), model, tools |
/model | Model config — /model set <model-name> [--persist], /model manage |
/mcp | Manage MCP servers — list/ls, auth, enable, disable, reload, schema, desc |
/memory | Manage hierarchical GEMINI.md memory — list, show, refresh |
/resume | Browse/resume sessions; checkpoints — list, save <tag>, resume <tag>, delete <tag> |
/chat | Alias for /resume — same session browser and checkpoint subcommands |
/init | Analyzes the cwd and generates a tailored GEMINI.md |
/clear (Ctrl+L) | Clears the screen |
/quit (/exit) | Exits; --delete wipes the session history and temp files |
@path — inject file content into a prompt
Prefix a path with @ to inject that file or directory's content into the prompt before it sends. It fires read_many_files internally, so it works on whole directories.
@README.md What is this file?— one file.@src/ Summarize this code— a directory.@My\ Documents/file.txt— escape spaces with a backslash.- A lone
@with no path passes the query through unchanged.
@ is git-aware by default: it excludes git-ignored paths (node_modules/, dist/, .git/, .env), so @. will not sweep in your secrets file. Tune this with context.fileFiltering in settings.
!command — run a one-off shell command
!ls -la or !git status runs that one command directly (bash on macOS/Linux, powershell.exe -NoProfile -Command on Windows), prints the output, and returns control to the agent. It sets GEMINI_CLI=1 in the subprocess so scripts can detect the launch context. A lone ! toggles persistent shell mode (distinct prompt and color) where every line is a shell command until you toggle back. ! commands run with your full permissions and no approval prompt — it is not a sandbox.
Three typed inputs, three jobs
`/command` — drive the CLI
Configures the program: pick a model, list tools, manage MCP, resume a session. /tools, /model set <id>, /mcp list, /stats.
Never touches your files directly.
`@path` and `!cmd` — feed the prompt
@path injects file/dir content (git-aware, via read_many_files). !cmd runs a shell command with your permissions and pipes the output back.
Both put real context and real actions into the loop.
Restrict the tool set
tools.core in settings.json is an allowlist for every built-in tool, not just the shell. Setting any value disables every tool not listed. To restrict the shell and keep file tools, list them all. Shell-specific entries take the form run_shell_command(<prefix>).
{
"tools": {
"core": [
"read_file",
"write_file",
"replace",
"glob",
"grep_search",
"list_directory",
"run_shell_command(git)",
"run_shell_command(npm)"
]
}
}Knowledge check
You set `"tools": { "core": ["run_shell_command(git)"] }` in `~/.gemini/settings.json` to limit the shell to git. The next session, the agent says it cannot read or edit files. Why?
Classify what you typed: /, @, !, or a plain prompt
Command explorer
Every built-in slash command worth knowing, grouped by what it touches. Search by name or purpose, filter by group, and pick one for the full when-to-use and the gotchas the menu never tells you.
32 commands
Show version, model, account, and connectivity.
When: Confirm which model and auth method are active — including the classic case where a stray ANTHROPIC_API_KEY is shadowing your subscription. Works mid-response.
Availability varies by plan, platform, and version — type / in your own session to see exactly what is live for you.
First-session drill
Survey the surface
Launch
gemini, run/helpto list every command, then/toolsto see exactly which tools the agent can call right now. Confirm names here rather than from memory.Feed context with @
Point the agent at code:
@src/ What does this module do?.@is git-aware, so ignored files and.envstay out unless you changecontext.fileFiltering.Check ground truth with !
Verify a claim with a raw shell command:
!git status,!npm test. The output joins the context. A lone!toggles persistent shell mode.Let the model pick the tools
State the outcome in plain language and approve the actions it proposes. Keep
defaultapproval mode until you trust a workflow; widen toauto_edit(or--yoloin a sandbox) only once you know what it will do.
Reach the end and this star joins your charted sky.