DEV Community

Abhishek Gupta
Abhishek Gupta

Posted on

Gemini & Gemini CLI — Beginner Learning Notes

A short, beginner-friendly guide to understanding, installing, and using Gemini CLI.

1. What is Gemini?

Gemini is a family of artificial intelligence (AI) models developed by Google.

You can use Gemini to:

  • Answer questions and explain concepts.
  • Write, understand, and improve code.
  • Summarize documents and text.
  • Generate ideas and solve problems.
  • Help with learning and research.

Example: You can ask Gemini, “Explain JavaScript functions in simple English with examples.”

2. What is Gemini CLI?

Gemini CLI is an open-source AI coding assistant that lets you use Gemini directly from your terminal.

CLI stands for Command-Line Interface.

Instead of working only through a website, you can ask Gemini CLI to help with files and code inside your project.

What can Gemini CLI do?

  • Explain existing code.
  • Create and edit files.
  • Generate code from instructions.
  • Find and fix bugs.
  • Run commands and tests when permitted.
  • Help write documentation.
  • Search the web using its available tools.
  • Understand a project using its files and instructions.

Gemini vs. Gemini CLI

Gemini Gemini CLI
Commonly used through a chat interface Used through a terminal
Great for questions, learning, and general tasks Great for tasks involving your local project
Usually works with content you provide in chat Can use available tools to inspect and work with project files
You often copy code into your editor It can make changes to files with your permission

Remember: Gemini is the AI model family; Gemini CLI is a tool for interacting with Gemini from the command line.

3. What is a terminal?

A terminal is an application where you type commands to interact with your computer.

Examples:

  • Windows: PowerShell or Windows Terminal.
  • Linux: Terminal.
  • macOS: Terminal.

For example:

mkdir my-project
Enter fullscreen mode Exit fullscreen mode

This command creates a directory named my-project.

You can use Gemini CLI in a terminal to work with your code.

4. Requirements before installation

You need:

  • A Windows or Linux computer.
  • An internet connection.
  • Node.js version 20 or later for the npm installation method.
  • A supported authentication method for Gemini CLI.

Check whether Node.js and npm are installed:

node --version
npm --version
Enter fullscreen mode Exit fullscreen mode

If both commands display version numbers, they are available in your terminal.

If not, install Node.js from the official website:

https://nodejs.org/

Choose an appropriate version for your operating system.

5. Install Gemini CLI on Windows

The npm method is recommended for a straightforward installation.

Step 1: Install Node.js

  1. Open https://nodejs.org/
  2. Download a suitable supported version.
  3. Run the installer.
  4. Follow the installation instructions.
  5. Open a new PowerShell window.

Step 2: Verify installation

Run:

node --version
npm --version
Enter fullscreen mode Exit fullscreen mode

Both commands should return version numbers.

Step 3: Install Gemini CLI

npm install -g @google/gemini-cli
Enter fullscreen mode Exit fullscreen mode

The -g option installs the CLI globally so you can launch it from different project directories.

Step 4: Verify Gemini CLI

gemini --version
Enter fullscreen mode Exit fullscreen mode

If a version number appears, the command is available.

Step 5: Start Gemini CLI

gemini
Enter fullscreen mode Exit fullscreen mode

Follow the authentication instructions displayed in the terminal.

6. Install Gemini CLI on Linux using npm

These instructions apply to common Linux distributions.

Step 1: Install Node.js

Install a supported Node.js version from:

https://nodejs.org/

Use your distribution's package manager or another trusted installation method when appropriate.

Step 2: Verify Node.js and npm

node --version
npm --version
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Gemini CLI

npm install -g @google/gemini-cli
Enter fullscreen mode Exit fullscreen mode

Step 4: Verify and start

gemini --version
gemini
Enter fullscreen mode Exit fullscreen mode

Permission tip: If npm reports a permissions error, don't immediately use sudo npm install -g. Consider configuring npm's global directory or using a Node.js version manager.

7. Install Gemini CLI on Linux using Snap

Snap is a package system that installs applications on supported Linux distributions.

This method uses a community-maintained Snap package, not an official Google-published package. The official Gemini CLI source code is maintained separately.

Step 1: Check Snap

snap version
Enter fullscreen mode Exit fullscreen mode

If the command works, Snap is available.

If Snap is not installed, follow the setup instructions for your Linux distribution:

https://snapcraft.io/docs/installing-snapd

Step 2: Install Gemini CLI

sudo snap install gemini-cli
Enter fullscreen mode Exit fullscreen mode

Step 3: Verify the installation

gemini --version
Enter fullscreen mode Exit fullscreen mode

Step 4: Start Gemini CLI

gemini
Enter fullscreen mode Exit fullscreen mode

Important: Snap packages can have filesystem restrictions. If the Snap version cannot access your project files, check the package's filesystem-access documentation before changing permissions or switching installation methods.

Snap package information:

https://snapcraft.io/gemini-cli

8. Authenticate Gemini CLI

On the first launch, Gemini CLI may ask you to choose an authentication method.

For a typical beginner setup:

  1. Run gemini.
  2. Choose the Google account login option if it is offered and suitable for your account.
  3. Complete the browser-based sign-in.
  4. Return to the terminal.
  5. Follow any remaining setup instructions.

Authentication options and availability can vary by account, location, and configuration. Follow the current official guide if your screen differs.

Official authentication guide:

https://geminicli.com/docs/

9. Start working with a project

Gemini CLI works best when you launch it from the directory you want it to help with.

Step 1: Create a project directory

mkdir learning-project
cd learning-project
Enter fullscreen mode Exit fullscreen mode

Step 2: Start Gemini CLI

gemini
Enter fullscreen mode Exit fullscreen mode

Step 3: Give it a clear instruction

For example:

Explain the files in this project. Tell me what each file does. Do not change anything yet.

Gemini CLI can inspect relevant files using its available tools and permissions.

Step 4: Ask for the next task

For example:

Create a simple HTML page with a heading, a paragraph, and a button. Keep the code beginner-friendly.

Review the suggested changes before accepting them.

10. How to write good prompts

A prompt is the instruction or question you give an AI.

A clear prompt helps the AI understand what you need.

A simple prompt formula

Include these four things when useful:

  1. Goal: What do you want?
  2. Context: What project or files are involved?
  3. Requirements: What should the result include?
  4. Restrictions: What should it avoid changing?

Example: Weak prompt

Make a website.
Enter fullscreen mode Exit fullscreen mode

The request is too broad. The AI must guess the design, content, and functionality.

Example: Better prompt

Create a responsive personal portfolio website.

Requirements:
- Use HTML, CSS, and JavaScript.
- Include About, Skills, Projects, and Contact sections.
- Use a clean, modern design.
- Make it work on mobile and desktop.
- Keep the code simple and readable.
Enter fullscreen mode Exit fullscreen mode

Helpful prompting tips

  • Be specific about your goal.
  • Mention the programming language and framework.
  • State what should and should not change.
  • Ask the AI to explain unfamiliar code.
  • Provide error messages when debugging.
  • Request tests or verification when appropriate.
  • Review the result instead of blindly trusting it.

11. Useful Gemini CLI commands

Run these commands inside Gemini CLI where supported.

Command Purpose
/help Display help and available commands
/tools Inspect available tools
/clear Clear the current conversation context
/quit Exit, if supported by your installed version

The available commands can change between versions. Use /help to see the commands available in your installation.

Useful terminal commands

These are shell commands, not Gemini CLI slash commands.

Command Purpose
pwd Show the current directory on Linux/macOS
ls List files on Linux/macOS
dir List files in Windows PowerShell
cd folder-name Move into a directory
node --version Check the Node.js version
npm --version Check the npm version
gemini --version Check the Gemini CLI version

12. Understand, edit, and debug code

Gemini CLI can help with different stages of development.

Understand code

Explain this project structure in simple English.
Identify the main entry point and explain how the application starts.
Do not modify any files.
Enter fullscreen mode Exit fullscreen mode

Create code

Create a simple calculator using HTML, CSS, and JavaScript.
Support addition, subtraction, multiplication, and division.
Keep the interface responsive and the code readable.
Enter fullscreen mode Exit fullscreen mode

Fix a bug

Inspect the relevant code and identify the cause of the bug.
Explain the problem before making changes.
Apply the smallest suitable fix and run the relevant tests if available.
Enter fullscreen mode Exit fullscreen mode

Improve existing code

Review this code for readability and maintainability.
Suggest improvements first.
Do not rewrite unrelated files.
Enter fullscreen mode Exit fullscreen mode

13. What is GEMINI.md?

GEMINI.md is a Markdown file that can provide Gemini CLI with project-specific instructions and context.

You can use it to explain how the project should be developed.

Example:

# Project Instructions

- Use JavaScript for frontend code.
- Keep functions small and readable.
- Follow the existing project structure.
- Avoid changing unrelated files.
- Explain important changes.
- Run relevant tests when possible.
Enter fullscreen mode Exit fullscreen mode

Place the file where Gemini CLI can discover it according to the project's instruction-loading rules.

Why use it? You can define project conventions once instead of repeating them in every prompt.

Documentation:

https://geminicli.com/docs/

14. Common installation problems

Problem What to check
node command not found Install Node.js and reopen the terminal
npm command not found Check your Node.js installation and PATH
gemini command not found Check installation output, npm's global path, or Snap setup
Permission denied Review installation permissions and filesystem restrictions
Login does not work Check your browser, network, account, and authentication method
CLI cannot access files Check the current directory and the tool's filesystem permissions
AI produces incorrect code Provide more context, inspect the changes, and run tests

For additional troubleshooting, consult the official documentation:

https://geminicli.com/docs/

15. Safety and best practices

AI tools can make mistakes. Always review their work.

  • Never share passwords, API keys, access tokens, or private credentials in prompts.
  • Keep important work committed to Git or backed up.
  • Review file changes before accepting them.
  • Be careful with commands that delete files or modify system settings.
  • Understand commands before allowing them to run.
  • Test generated code before using it in production.
  • Do not assume that generated code is secure or correct.
  • Check the permissions and source of third-party packages.

16. Quick revision

  • Gemini: Google's family of AI models.
  • Gemini CLI: A terminal-based tool for working with Gemini.
  • CLI: Command-Line Interface.
  • Terminal: An application for entering commands.
  • Node.js: A JavaScript runtime used by the npm installation method.
  • npm: A package manager used to install Gemini CLI.
  • Snap: A package system available on supported Linux distributions.
  • Prompt: An instruction given to the AI.
  • GEMINI.md: A file for project-specific instructions.
  • Authentication: The process of signing in or configuring access.
  • Debugging: Finding and fixing problems in code.

Remember these commands

# Check requirements
node --version
npm --version

# Install through npm
npm install -g @google/gemini-cli

# Or install through Snap on supported Linux systems
sudo snap install gemini-cli

# Check the version
gemini --version

# Start Gemini CLI
gemini
Enter fullscreen mode Exit fullscreen mode

Use only the installation method appropriate for your operating system.

Top comments (0)