Open2

Gemini CLIことはじめ

oratakeoratake

概要

Gemini Code Assistは使ってたがCLIが出たのでつかってみる

試用

グローバルにインストール

$ npm i -g @google/gemini-cli

サンドボックスで対話型のプロンプトを起動

$ gemini -s

/quit もしくは Ctrl+c 2回でquit

なるほどこんなん出るのね

ちなみに起動自体はできたが1エラーとあり内容を見るとこんな感じ

Error getting folder structure for /Users/<ユーザ名>: Error: EPERM: operation not permitted, scandir '/Users/<ユーザ名>/.Trash'

んで調べたらこんなんがあり
https://github.com/google-gemini/gemini-cli/issues/1543
ターミナルにFull Disk Accessの権限与えたら?ということかな
システム環境設定 > プライバシーとセキュリティ > フルディスクアクセス
iTermをTrueにしてあげてエラーが消えた。

あとこんなんも出た

Failed to login. Message: Resource has been exhausted (e.g. check quota).

普通に再ログイン。混んでるだけ?
何回か落ちることもあるのでまだ不安定なんかな。

あまりにもAuthが切れるのでAPIでやってみる
https://monomonotech.jp/kurage/memo/m240725_get_gemini_api_key.html

設定を確認する。
~/.gemini/settings.json

サンドボックスで起動 "sandbox" : "true" を入れておく。ちなみにtrueの代わりに "docker" を入れておくとDocker内でやってくれるらしい。

oratakeoratake

MCP

  • Serene
    コードをLSPで認識させてLLMに対して情報を整理して投げてやろうという魂胆
    pythonのパッケージマネージャをbrewで入れて実行、というのがよさそう
$ brew install uv
~/.gemini/settings.json
{
  // 省略
  "mcpServers": {
    "serena": {
      "command": "uvx",
      "args": [
        "--from", "git+https://github.com/oraios/serena",
        "serena-mcp-server",
        "--context", "ide-assistant",
        "--enable-web-dashboard", "false",
        "--project", "${PWD}"
      ]
    }
  }
}

参考
https://qiita.com/miuraken/items/a61fc2f826ba442c5f63#2-gemini-cli-の設定

開発

https://zenn.dev/beijaflor/articles/8643c86e1d4833
準備大事らしいので準備する

メモ: Kiroで設計を書かせ、Geminiに読ませるスタイルで開発を行っている。
25/08/13現在のGEMINI.md

- Base development on the requirement definition files found in the `.kiro/` directory, which were defined by the Kiro AI agent.
- When starting a new task defined in `.kiro/specs/<SeviceName>/tasks.md`, use the `gh` command to check for a corresponding GitHub Issue. If no match is found, confirm with the user before proceeding.
- Commit frequently after each logical unit of work to maintain a granular history. Each commit should represent a single, meaningful change (e.g., a feature addition or a bug fix).
- When starting a new task, create a new Git branch with the format: <Issue_Number>-<english_task_name> (e.g., 2-implement_data_model_and_schema).
- All responses to the user must be in Japanese.
- For commands that require `sqlx-cli` or other tools that may not be in the environment, present the command to the user and ask them to execute it. This applies to commands run via Cargo or Docker as well.
- The Gemini CLI operates in a sandboxed environment. Commands that require access to local user data (like `gh` auth) or system-level modifications may not work as expected.

例示の sqlx-cli はRustを書かせてみたときのやつなので。