Mastering Your Environment
To effectively use the Gemini CLI, you must understand how to navigate and manipulate your project's workspace. The workspace is the root directory where the agent operates, and every action it takes is relative to this location.
The Working Directory
The Current Working Directory (CWD) is the starting point for all file paths. When you ask the CLI to read a file like src/app.js, it looks for that file starting from the root of your project. Understanding your CWD is crucial for providing accurate instructions and avoiding "file not found" errors.
Visualizing Project Structure
The list_directory tool is your primary way to see the layout of your project. It returns a list of files and subdirectories within a specified path. This helps you (and the agent) understand the architecture, naming conventions, and location of key files before making any changes.
Glob Patterns: Power Searching
Glob patterns are wildcards used to find multiple files that match a specific naming scheme. Common patterns include:
*.js: Matches all JavaScript files in the current folder.src/**/*.ts: Matches all TypeScript files in thesrcfolder and all of its subdirectories (recursive).data/*.{json,csv}: Matches both JSON and CSV files in the data folder.
The include-directories Flag
When listing files or performing searches, you may sometimes want to filter out directories to focus solely on files, or vice-versa. The --include-directories flag allows you to toggle whether directory names should be included in the results.