Skip to content

gemini Google Gemini CLI

Google Gemini CLI is used as an AI agent that can be used directly in a terminal.

I use the Gemini CLI to help generate bash script files and markdown documents for zensical. It is my preferred coding agent at the moment since I already pay for Google One.

🛠 Installation

Config path: ~/.gemini/

npm install -g @google/gemini-cli
npx https://github.com/google-gemini/gemini-cli
gemini

⚙ Config

  1. Generate a key from Google AI Studio.
  2. Set it as an environment variable in your terminal. Replace YOUR_API_KEY with your generated key.
export GEMINI_API_KEY="YOUR_API_KEY"
export GEMINI_API_KEY="YOUR_API_KEY"

✍ Syntax Files

Syntax files are used to customize the iutput from Gemini.

docs/GEMINI.md
# New Docker Application Guidelines for Gemini

**Context:** This directory contains all Docker applications.
- The `.template` folder is to be used as a template folder for new applications.

## Persona
You are a Docker and containerization specialist. You are expert in writing efficient, secure, and readable `compose.yaml` files and managing Docker environments. You understand the importance of keeping containers lightweight and using official images.

## Tech Stack
-   **Engine:** Docker
-   **Orchestration:** Docker Compose
-   **Templating:** Jinja2 (for `.tmpl.j2` files)
-   **Task Runner:** Task (Taskfile.yml)

## Boundaries
-   **Do not** use `latest` tag for images; always specify a version if possible.
-   **Do not** expose ports unnecessarily; use internal networks where possible.
-   **Do not** run containers as root unless absolutely necessary.
-   **Do** use environment variables for configuration.
-   **Do** document all environment variables in `.env.tmpl.j2`.

## Creating a New Docker Application

To create a new Docker application, follow these steps:

1. **Copy the template:** Copy the `.template` directory to a new directory named after your application (e.g., `my-docker-app/`).

2. **Update the files:** The following files need to be updated with the new application's information:

    - `.env.tmpl.j2`: This file contains environment variables.
      - `CONTAINER_NAME`: Set this to the desired name for the Docker container.
      - Read environmental variables from `compose.yaml` and add them to `.env.tmpl`.
      - The the following default values if the variables exist in `compose.yaml`.
        - `PG_DATABASE=postgress`
        - `PG_USER=postgress`
        - `POSTGRESS_USER=postgress`
        - `PG_PASSWORD=postgress`
        - `POSTGRESS_PASSWORD=postgress`
    -   `compose.yaml.j2`: This is the Docker Compose file.
      - Update the service name from `{{ APP_NAME | lower }}` to your application's name.
      - Update the image name `ghcr.io/{{ USER_NAME }}/{{ APP_NAME | lower }}:1.0.0` with the correct user and image name and the correct application version.
    - `README.md.j2`: This is the documentation for the application.
      - Update the `APP_NAME` to the new application's name.
    - `Taskfile.yml`: This file contains tasks for managing the application.
      - Update `{{ .CONTAINER_NAME }}` to the container name you set in the `.env.tmpl.j2` file.

3.  **Finalize:** Once you have updated these files, you can remove the `.j2` extension from the templated files.

AGENTS.md files can also be used to enable the use of other AI agents.

Enable gemini-cli to use AGENTS.md files.

~/.gemini/settings.json

{ "contextFileName": "AGENTS.md" }

🤖 MCP Servers

The GitHub MCP Server can be used to allow Gemini to interact with GitHub repositories.

~/.gemini/settings.json

{
    "context": {
        "fileName": "AGENTS.md"
    },
    "mcpServers": {
        "MCP_DOCKER": {
            "command": "docker",
            "args": [
                "mcp",
                "gateway",
                "run"
            ]
        },
        "github": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "GITHUB_PERSONAL_ACCESS_TOKEN",
                "ghcr.io/github/github-mcp-server"
            ],
            "env": {
                "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_MCP_PAT"
            }
        }
    },
    "security": {
        "auth": {
            "selectedType": "oauth-personal"
        }
    },
    "general": {
        "previewFeatures": true
    }
}
  • context.fileName: Specifies the file to use for context, in this case AGENTS.md.
  • general.previewFeatures: Set to true to enable preview features such as Gemini 3.0.
  • GITHUB_MCP_PAT: This environment variable must be set with your GitHub PAT for the github MCP server.

📝 Usage

Once installed and authenticated, start interacting with Gemini from the shell.

Example

git clone https://github.com/google-gemini/gemini-cli
cd gemini-cli
gemini
> Give me a summary of all of the changes that went in yesterday

Start a chat

gemini

Pipe content to the CLI from stdin

echo "Explain the content of this file docs/README.md" | gemini -p

List Models

Note

Assuming that your Gemini key is stored in the GEMINI_API_KEY environmental variable and jq is installed.

Code

curl "https://generativelanguage.googleapis.com/v1beta/models?key=${GEMINI_API_KEY}" | jq -r '.models[].name'

🔗 References