{
 "schema_version": 1,
 "generated": "2026-10-25",
 "id": "google-gemini-gemini-cli--run-gemini-headless-in-scripts-and-ci",
 "repo": "google-gemini/gemini-cli",
 "repo_url": "https://github.com/google-gemini/gemini-cli",
 "repo_slug": "google-gemini-gemini-cli",
 "title": "Run Gemini headless in scripts and CI with JSON output",
 "page_title": "How to run Gemini headless in scripts and CI with JSON output with Gemini CLI",
 "summary": "Use non-interactive mode with JSON or streaming JSON so other tools can read the result.",
 "who": "A developer who wants AI steps inside shell scripts, cron jobs or a CI pipeline.",
 "problem": "Interactive chat tools do not fit automated pipelines.",
 "outcome": "Machine-readable answers your script or CI job can parse.",
 "steps": [
  "Run a one-shot prompt: `gemini -p \"Explain the architecture of this codebase\"`",
  "Get structured output: `gemini -p \"Explain the architecture of this codebase\" --output-format json`",
  "Stream events for long tasks with `--output-format stream-json`",
  "Pick a model with `gemini -m gemini-2.5-flash`"
 ],
 "agent_prompt": "Write a shell script that runs google-gemini/gemini-cli headless with -p and --output-format json to <task> on this repo, parses the JSON with jq, and fails the CI step if <condition>.",
 "agents": [
  "gemini-cli"
 ],
 "difficulty": "Intermediate",
 "time": "20 minutes",
 "basis": "readme",
 "caveat": "",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "typescript",
 "requirements": [
  "Node.js (npm), Homebrew, MacPorts or conda",
  "A Gemini API key from AI Studio or a Google Cloud project for Vertex AI"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.9,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/google-gemini-gemini-cli/run-gemini-headless-in-scripts-and-ci/",
 "md": "https://dedupedai.com/use-cases/google-gemini-gemini-cli/run-gemini-headless-in-scripts-and-ci/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/google-gemini-gemini-cli--run-gemini-headless-in-scripts-and-ci.json",
 "api_version": "v1"
}
