DEDUPED Hot AI repos, turned into use cases Get the Monday 5

How to run Gemini headless in scripts and CI with JSON output with Gemini CLI

Use non-interactive mode with JSON or streaming JSON so other tools can read the result.

Short answer: Run a one-shot prompt: gemini -p "Explain the architecture of this codebase"; then Get structured output: gemini -p "Explain the architecture of this codebase" --output-format json; Stream events for long tasks with --output-format stream-json. All steps.

Who it is forA developer who wants AI steps inside shell scripts, cron jobs or a CI pipeline.

The problemInteractive chat tools do not fit automated pipelines.

The outcomeMachine-readable answers your script or CI job can parse.

What you need first

  • Node.js (npm), Homebrew, MacPorts or conda
  • A Gemini API key from AI Studio or a Google Cloud project for Vertex AI

Steps

  1. Run a one-shot prompt: gemini -p "Explain the architecture of this codebase"
  2. Get structured output: gemini -p "Explain the architecture of this codebase" --output-format json
  3. Stream events for long tasks with --output-format stream-json
  4. Pick a model with gemini -m gemini-2.5-flash

Prompt for your agent

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>.

Caveat.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for google-gemini/gemini-cli and "Run Gemini headless in scripts and CI with JSON output"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer