# Gemini CLI

> **About this page**
>
> - Task definition version: `swaleio/gemini-cli@0.72.0`
> - Summary: Runs Google's Gemini CLI once, unattended, on a directory, and returns its final answer.
> - Published: 2026-12-03, the latest version
> - Page: https://hub.swale.io/swaleio/gemini-cli/v/0.72.0
> - Latest version's copy: https://hub.swale.io/swaleio/gemini-cli.md
> - Versions: https://hub.swale.io/swaleio/gemini-cli/versions
> - Index of Swale Hub: https://hub.swale.io/llms.txt
>
> The YAML block below is the task definition's frontmatter, which declares its inputs, outputs and container, and its readme follows. Both are the text of the account that published this task definition, not Swale's.

```yaml
name: Gemini CLI
description: Runs Google's Gemini CLI once, unattended, on a directory, and returns its final answer.
category: coding-assistants
inputs:
  prompt:
    description: The instructions for the agent.
    required: true
  directory:
    description: Absolute path of the directory the agent works in, such as a repository an earlier task cloned (e.g. ${{env.WORKFLOW_STORAGE}}/repo).
    required: true
  model:
    description: The Gemini model, such as gemini-3.8-flash.
    required: true
  api_key:
    description: Your Gemini API key (pass a secret). Google bills it directly.
    default: ""
  permission:
    description: What the agent may do with nobody there to approve it (read, edit or full). See Permissions.
    default: edit
  result_path:
    description: Path of a file to also write the final answer to. Empty writes none.
    default: ""
  max_minutes:
    description: Minutes after which the run stops and the task fails.
    default: "60"
outputs:
  result:
    description: The agent's final answer, as a JSON string.
exec:
  # docker.io/swaleio/gemini-cli:0.72.0
  image: docker.io/swaleio/gemini-cli@sha256:cb171daf8ba139826ed23480c1fd4ec3b7a27acc87a751678e85bfef0b7749cf
  args: []
```

# Gemini CLI

Runs [Gemini CLI](https://github.com/google-gemini/gemini-cli), Google's coding
agent, once and unattended in `directory`, with the instructions in `prompt`.
Its final answer becomes the `result` output, and a file at `result_path` when
you give one. The image's entrypoint is the wrapper, so there are no `args`:
every setting is an input.

Gemini CLI is a product of Google. This task definition is built by Swale;
Google does not build, endorse or support it. The agent's answers and changes
can be wrong: review them before you rely on them.

## Inputs

| Input | Required | Default | Description |
|-------|----------|---------|-------------|
| `prompt` | yes | — | The instructions for the agent. |
| `directory` | yes | — | Absolute path the agent works in, such as a repository an earlier task cloned (e.g. `${{env.WORKFLOW_STORAGE}}/repo`). |
| `model` | yes | — | The Gemini model, such as `gemini-3.8-flash`. |
| `api_key` | no | — | Your Gemini API key (pass a secret). Google bills it directly. |
| `permission` | no | `edit` | `read`, `edit` or `full`. See [Permissions](#permissions). |
| `result_path` | no | — | Path of a file to also write the final answer to. |
| `max_minutes` | no | `60` | Minutes after which the run stops and the task fails. |

## Outputs

| Output | Description |
|--------|-------------|
| `result` | The agent's final answer, as a JSON string. Read it with `fromJSON(tasks.<id>.outputs.result)`. |

## Permissions

Nobody is there to approve what the agent wants to do, so `permission` says up
front what it may do. Anything else it asks for is refused.

| `permission` | What the agent can do |
|--------------|-----------------------|
| `read` | Read files. No edits, no commands. |
| `edit` | Also edit files. No commands. |
| `full` | Everything Gemini CLI can do, commands included, with no approval. |

## Signing in

Sign in with your own Gemini API key, which Google bills directly. Gemini CLI
talks only to Google's API, so it has no `base_url`. A Google account sign-in
cannot be used: it needs a browser, and the task runs unattended. The agent
sends your prompt and what it reads to Google, under your own account there.

## Security

The task holds only what the workflow passes it. The agent acts on everything it
reads, though: the files in `directory`, the pages and command output it sees,
and the repository's own instruction files (`GEMINI.md`) and settings
(`.gemini/settings.json`), whose hooks can run commands at every level. An
instruction planted in any of them can steer it. With `full`, that can mean a
command that sends your key or your code somewhere else. Give it the lowest
level the job needs, run it on repositories you trust, and put a spending limit
on the key. Run unattended, Gemini CLI refuses a folder nobody has trusted, so
the task trusts `directory` for the run and those settings load.

## Compute

**CPU.** The model runs at the provider or at `base_url`; this task only runs the agent, so a GPU compute type wastes money.

## Example

```yaml
name: Gemini CLI example
compute_type: cpu-4
entry_point: main

blocks:
  main:
    tasks:
      checkout:
        name: Checkout
        uses: swaleio/git-clone
        args:
          repository_url: https://github.com/acme/app.git
          dest: ${{env.WORKFLOW_STORAGE}}/repo
      review:
        name: Review the code
        uses: swaleio/gemini-cli
        start_on:
          - checkout
        args:
          prompt: Review this repository for bugs. List each one with its file and line.
          directory: ${{env.WORKFLOW_STORAGE}}/repo
          model: gemini-3.8-flash
          api_key: ${{secrets.gemini_api_key}}
          permission: read
          result_path: ${{env.WORKFLOW_STORAGE}}/review.md
```

The review is in `${{env.WORKFLOW_STORAGE}}/review.md` for later tasks, and in
`${{tasks.review.outputs.result}}`.

---

For the workflow syntax these examples use, see the
[workflow definition reference](https://docs.swale.io/reference/workflow-definition-syntax)
in the [Swale documentation](https://docs.swale.io).

Licensed under the [MIT License](https://github.com/swaleio/task-definitions/blob/main/LICENSE).
