Skip to content

Instantly share code, notes, and snippets.

@zats
Created August 25, 2025 01:20
Show Gist options
  • Save zats/fd4099059ec0742125e3be369aba76d6 to your computer and use it in GitHub Desktop.
Save zats/fd4099059ec0742125e3be369aba76d6 to your computer and use it in GitHub Desktop.
Teaching codex to search internet with gemini-cli

Web Search Tool

Overview

This tool uses the Gemini CLI to retrieve up-to-date information directly from the internet in a single streamed response. It is suited for requesting the model to actively search the public web for best practices and fresh knowledge beyond local context.

Usage

Explicitly instructing the model to search the internet for a focused topic:

gemini -y -p "Find best practices on applying @MainActor in swift6, search internet"

You provide a natural language instruction via -p (prompt). The response is streamed as Markdown (headings, lists, code blocks, links) which you can parse or summarize directly.

Flags

  • -p <prompt>: The full prompt string (quote it if it has spaces or special characters).
  • -y: (Assume/auto confirm) non-interactive / always yes mode so the tool runs without additional confirmations.

Response Format

The CLI streams Markdown. Typical elements you may see:

  • Headings summarizing the topic or news clusters.
  • Bullet lists of key points, dates, entities.
  • Inline source links (when available) or reference-style links at the bottom.
  • Code fences for technical examples.

There is no intermediate JSON layer; consume the Markdown directly. If you require structured data, post‑process the Markdown (e.g., extract links, headings, bullet items).

How LLMs Should Use

  • Craft a precise prompt describing the needed information and, when web freshness matters, explicitly include phrases like "search internet" or "latest".
  • Ask for structured formatting (e.g., "Provide a table", "Return a bullet list of sources with URLs") inside the prompt if you need easier parsing.
  • If additional depth on a subtopic is required, issue a follow-up prompt referencing the earlier result (no need to restate everything, just the refinement).
  • Capture streamed Markdown; optionally persist then parse for citations, entities, or summaries.

Best Practices

  • Be explicit when real-time or external lookup is required (e.g., include "search internet", "current", "latest", or a date range).
  • Request source URLs: e.g., "Include source links for each claim".
  • Ask for separation of speculative vs confirmed info when dealing with emerging stories.
  • For large scopes, constrain: "Summarize top 5 developments in over the past 7 days; list each with a one-line rationale and a source link."
  • If output may be long, you can pipe to a temp file for later filtering:
    gemini -y -p "latest developments in webgpu adoption, search internet, provide sources" > /tmp/gemini_webgpu.md

Example Advanced Prompts

gemini -y -p "Summarize the 5 most impactful iOS performance tuning techniques announced in the last 3 months, search internet, include source links, output a markdown table."

gemini -y -p "Find best practices on applying @MainActor in swift6, search internet, distinguish official guidance vs community patterns, list risks." 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment