Tutorial: AI Agent Pipeline with Claude Code & SerpAPI

This tutorial walks you through a three-part automated AI research pipeline built on Claude Code's headless CLI, SerpAPI for structured search results, and Surf Agent for browser-based verification. You'll schedule the full loop — search, fact-check, report, and Google Form submission — to run hands-free on a daily cron job. Intermediate setup with production-ready cron configuration included.


0

Build a Three-Part AI Agent Pipeline with Claude Code, SerpAPI, and Surf Agent

The three-part Claude Code automation stack: cron for timing, headless CLI for logic, Surf Agent for browser control
The three-part Claude Code automation stack: cron for timing, headless CLI for logic, Surf Agent for browser control

By the end of this tutorial, you’ll have a fully automated research pipeline that searches Google and YouTube via SerpAPI, fact-checks sources with a browser agent, and submits a curated report to a Google Form on a daily cron schedule. The stack is three tools deep — a cron trigger, Claude Code’s headless claude -p mode, and Surf Agent for browser control — and composable enough to retarget at any research topic without structural changes.

  1. Map the five-step pipeline before touching any code. The stages are: SerpAPI search → Surf Agent verification → markdown report → Google Form submission → cleanup. Defining these boundaries upfront means any stage can be swapped or extended without cascading changes to the others.
The complete 5-step recon pipeline: SerpAPI search, Surf Agent verification, markdown report, Google Form submission, and cleanup
The complete 5-step recon pipeline: SerpAPI search, Surf Agent verification, markdown report, Google Form submission, and cleanup
  1. Obtain a SerpAPI key and locate the relevant endpoint docs. In your SerpAPI dashboard, find the documentation pages for the Google Search Engine Results API, Google News API, and YouTube Search API. Copy the full documentation for each endpoint — you’ll feed these directly into your IDE in the next step.

  2. Generate the recon skill by giving SerpAPI docs to Claude Code. Paste all three SerpAPI documentation pages into Cursor and prompt Claude Code: “Read these SerpAPI docs. Build a skill using the API key from ENV. Return context from Google Search, Google News, and YouTube based on user input.” Once Claude Code generates the skill, open SKILL.md and verify the constants block defines TOPIC, FRESHNESS, SERPAPI_BASE, the Surf Agent endpoint URL, and the timestamped report output paths.

SKILL.md constants define the topic, search depth, API endpoints, and output file paths that drive the entire recon pipeline
SKILL.md constants define the topic, search depth, API endpoints, and output file paths that drive the entire recon pipeline
  1. Run a live test query to validate the skill. Inside Claude Code, invoke: use the serp-context skill — search YouTube and Google for any news around GPT-5.5. The agent queries SerpAPI, returns structured JSON, and assembles a timestamped timeline with source URLs. Confirm the output includes dated entries and functional links before moving on.
SerpAPI returns a verified, timestamped timeline of GPT-5.5 coverage with source URLs ready for fact-checking
SerpAPI returns a verified, timestamped timeline of GPT-5.5 coverage with source URLs ready for fact-checking
  1. Set your research topic directly in the skill file. Open SKILL.md and hardcode the TOPIC constant to your target query — Hermes AI agent use cases in this example. If you want the cron job to vary the topic per run, you can instead accept it as a bash parameter passed to the claude -p invocation.

  2. Execute the full pipeline headlessly.

claude -p /recon --model claude-sonnet-4-6 --dangerously-skip-permissions

Warning: this step may differ from current official documentation — see the verified version below.

Triggering the recon skill headlessly: `claude -p
Triggering the recon skill headlessly: `claude -p “/recon” –model claude-sonnet-4-6 –dangerously-skip-permissions`
  1. Observe Surf Agent open YouTube tabs and read transcripts. Once SerpAPI delivers results, Surf Agent launches Chrome, opens each returned video, reads the full transcript, and scrolls the comments section for community signal — then advances to the next result without any input from you.

  2. Observe Surf Agent cross-reference sources on Hacker News and Reddit. After exhausting the YouTube results, the agent searches Hacker News via Algolia and checks Reddit threads, using community discussion to corroborate or challenge the claims it pulled from the video transcripts.

SerpAPI sweeps Hacker News for Hermes Agent use cases — 781 results in 0.011 seconds
SerpAPI sweeps Hacker News for Hermes Agent use cases — 781 results in 0.011 seconds
  1. Observe Surf Agent fill and submit the Google Form. The agent opens your pre-created form, populates all three fields — most interesting idea, source URL, and a 1–5 star rating — then clicks Submit. No selectors or scripting required; Surf Agent reads the form visually and interacts with it the same way a person would.
The Google Form the agent will fill and submit: idea summary, source URLs, and a 1–5 star self-rating
The Google Form the agent will fill and submit: idea summary, source URLs, and a 1–5 star self-rating
  1. Review the terminal summary and verify the form response. After submission, the pipeline prints every idea it surfaced — five in this run — and marks the one it selected for the form. Open Google Forms from any device to confirm the response was recorded with the correct content and rating.
Pipeline complete: 5 novel ideas surfaced, Google Form auto-submitted with a 4/5 rating, and report files written to disk
Pipeline complete: 5 novel ideas surfaced, Google Form auto-submitted with a 4/5 rating, and report files written to disk
Google Forms confirms the agent's submission: the Omi + Obsidian + Hermes ambient memory loop idea, sources included
Google Forms confirms the agent’s submission: the Omi + Obsidian + Hermes ambient memory loop idea, sources included
  1. Wrap the command in a cron job for hands-free daily execution. Add the claude -p /recon command to your crontab. A daily 9 AM trigger looks like:
0 9 * * * claude -p /recon --model claude-sonnet-4-6 --dangerously-skip-permissions

Each scheduled fire runs the full search-verify-submit loop and exits cleanly, ready to repeat the next day.

How does this compare to the official docs?

The --dangerously-skip-permissions flag and the claude -p headless invocation pattern produce real results here, but the official Claude Code documentation draws important distinctions around permission scoping that change how you’d safely deploy this in a production environment.

Here’s What the Official Docs Show

The video gives you a solid working model of this three-part pipeline. What follows adds the production-grade specifics the official documentation surfaces — particularly around SerpAPI authentication and cron environment configuration — where small details determine whether the pipeline runs once or reliably every day.

Step 1 — Map the pipeline architecture

No official documentation was found for this step — proceed using the video’s approach and verify independently.

claude.ai consumer sign-in page — not the Claude Code CLI documentation; no -p or --dangerously-allow-permissions flag reference visible
📄 claude.ai consumer sign-in page — not the Claude Code CLI documentation; no -p or –dangerously-allow-permissions flag reference visible

Step 2 — Obtain a SerpAPI key and locate endpoint docs

The video’s approach here matches the current docs exactly. SerpAPI’s Google Search API returns structured JSON — search_metadata, search_parameters, and search_information — via a GET request to https://serpapi.com/search.json. One gap: only the Google Search API endpoint is confirmed in the captured documentation. Verify the Google News and YouTube Search endpoints directly in your SerpAPI dashboard before building the skill around them.

SerpAPI Google Search API homepage showing live JSON response structure with search_metadata, search_parameters, and search_information fields
📄 SerpAPI Google Search API homepage showing live JSON response structure with search_metadata, search_parameters, and search_information fields

Step 3 — Generate the recon skill in Cursor

The video’s approach here matches the current docs exactly. Cursor’s Composer 2 Agent mode is the confirmed interface for scaffolding multi-file skills. Plan mode is also available within the same Composer 2 UI — useful for reviewing the proposed file structure before any code executes.

Cursor.com homepage showing the AI code editor desktop UI with agent task completion, file diffs, and the Composer 2 prompt interface
📄 Cursor.com homepage showing the AI code editor desktop UI with agent task completion, file diffs, and the Composer 2 prompt interface

Step 4 — Run a live test query

The video’s approach here matches the current docs exactly. Note that api_key is a required parameter on every SerpAPI request; it must be appended to the GET URL even when truncated examples in the official docs omit it.

SerpAPI 'Easy Integration' GET endpoint: https://serpapi.com/search.json with q, location, hl, gl, and google_domain parameters shown
📄 SerpAPI ‘Easy Integration’ GET endpoint: https://serpapi.com/search.json with q, location, hl, gl, and google_domain parameters shown

Step 5 — Set your research topic in SKILL.md

No official documentation was found for this step — proceed using the video’s approach and verify independently.

One useful addition: official SerpAPI SDK examples pass api_key as a hardcoded string literal. The video’s approach of reading it from an environment variable is the correct security practice for a pipeline that runs unattended — it simply isn’t the pattern depicted in official documentation.

SerpAPI multi-language SDK integration panel; Ruby example shows api_key as a literal string — environment variable loading is not depicted in the official code sample
📄 SerpAPI multi-language SDK integration panel; Ruby example shows api_key as a literal string — environment variable loading is not depicted in the official code sample

Step 6 — Execute the pipeline headlessly

As of April 27, 2026, the -p, --dangerously-skip-permissions, and --model flags shown in the video cannot be verified against official Claude Code documentation — all three captured screenshots landed on the claude.ai consumer website rather than docs.anthropic.com. Cross-reference the current CLI reference at docs.anthropic.com before using these flags in production.

claude.ai pricing page showing Free, Pro ($17/mo), and Max (from $100/mo) plans — not Claude Code CLI documentation
📄 claude.ai pricing page showing Free, Pro ($17/mo), and Max (from $100/mo) plans — not Claude Code CLI documentation

Steps 7–8 — Surf Agent browser verification

No official documentation was found for these steps — proceed using the video’s approach and verify independently.

Steps 9–10 — Google Form submission and terminal review

No official documentation was found for these steps — proceed using the video’s approach and verify independently.

Google Forms sign-in page — Google account authentication required; no form UI or autonomous submission workflow is documented here
📄 Google Forms sign-in page — Google account authentication required; no form UI or autonomous submission workflow is documented here

Step 11 — Wrap in a cron job

The video’s approach here matches the current docs exactly — cron is the right scheduling mechanism. The crontab(5) man page adds two environment constraints the video skips that will silently break an unattended pipeline:

  • SHELL: cron defaults to /bin/sh. If your pipeline uses bash-specific syntax, add SHELL=/bin/bash as the first line of your crontab.
  • PATH: cron runs with a minimal PATH, so claude will not resolve by name. Use the full absolute path to the binary. Set SERPAPI_KEY and any other required variables on their own dedicated lines above the command entry — inline comments on a cron command line are not supported.
SHELL=/bin/bash
SERPAPI_KEY=your_key_here
0 9 * * * /usr/local/bin/claude -p /recon --model claude-sonnet-4-6 --dangerously-skip-permissions
crontab(5) man page showing the five time-and-date field format and RANDOM_DELAY variable for offsetting scheduled job start times
📄 crontab(5) man page showing the five time-and-date field format and RANDOM_DELAY variable for offsetting scheduled job start times
  1. Google Search Engine Results API – SerpApi — Official SerpAPI documentation covering the Google Search JSON response structure, GET endpoint format, and multi-language SDK examples.
  2. crontab(5) – Linux manual page — Authoritative crontab syntax reference documenting SHELL, PATH, MAILTO, CRON_TZ defaults, and the five-field time format.
  3. Sign in – Claude — Claude.ai consumer entry point; the Claude Code CLI documentation is located at docs.anthropic.com, not this URL.
  4. Google Forms: Sign-in — Google Forms authentication gate; form creation and help documentation is available via support.google.com.
  5. Cursor: The best way to code with AI — Cursor AI code editor homepage confirming Composer 2 Agent mode, Plan mode, and agentic task decomposition capabilities referenced in step 3.

Like it? Share with your friends!

0

What's Your Reaction?

hate hate
0
hate
confused confused
0
confused
fail fail
0
fail
fun fun
0
fun
geeky geeky
0
geeky
love love
0
love
lol lol
0
lol
omg omg
0
omg
win win
0
win

0 Comments

Your email address will not be published. Required fields are marked *