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/
Config¶
- Generate a key from Google AI Studio.
- Set it as an environment variable in your terminal. Replace
YOUR_API_KEYwith your generated 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.
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 caseAGENTS.md.general.previewFeatures: Set totrueto enable preview features such as Gemini 3.0.GITHUB_MCP_PAT: This environment variable must be set with your GitHub PAT for thegithubMCP server.
Usage¶
Once installed and authenticated, start interacting with Gemini from the shell.
Example
Pipe content to the CLI from stdin
List Models¶
Note
Assuming that your Gemini key is stored in the GEMINI_API_KEY environmental variable and jq is installed.
Code
References¶
- https://github.com/google-gemini/gemini-cli
- https://github.com/github/github-mcp-server/blob/6a57e75d729f9767827bc4f96e80ff9bd8538a46/docs/installation-guides/install-gemini-cli.md