Docs/Skills and code/global skill google-ai-mode

~/.claude/skills/google-ai-mode/SKILL.md

Markdown95 lines7.0 KBSkill: google-ai-mode

What the file says about itself

Use Google AI Mode through Claude in Chrome to get a sourced answer to a question, push follow-ups until the question is answered, and save the full thread as a markdown source file.

Skill header (frontmatter)

name: google-ai-mode
description: Use Google AI Mode through Claude in Chrome to get a sourced answer to a question, push follow-ups until the question is answered, and save the full thread as a markdown source file. Use when the user asks to research a topic through Google AI Mode, or to turn an AI Mode conversation into a saved source.

Google AI Mode via Claude in Chrome

Draft. Based on one probe session (GoogleSearchSkill project: sources/google-ai-mode-probe-roth-ira-2026-10-30.md). Update it after each real run.

1. Clarify the goal

Before touching the browser, confirm the user's goal. If the topic, the decision they need to make, or the time frame is missing, ask. Do not invent a persona or details. The probe used an invented persona, and AI Mode answered as if it were real.

2. Build the query

Turn the goal into one prompt that states:

Only include details the user gave you.

3. Load tools and open AI Mode

4. Submit the query

The computer tool path (click the box, type, key Return) did not land in the probe. The screenshot also timed out. Set the text through the page instead, with javascript_tool:

(async () => {
  const ta = [...document.querySelectorAll('textarea')].find(e => e.placeholder === 'Ask anything' && e.getBoundingClientRect().width > 0)
          || document.querySelector('textarea');
  ta.focus();
  const set = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value').set;
  set.call(ta, QUERY_TEXT);
  ta.dispatchEvent(new Event('input', { bubbles: true }));
  await new Promise(r => setTimeout(r, 400));
  for (const type of ['keydown', 'keyup'])
    ta.dispatchEvent(new KeyboardEvent(type, { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true }));
  return 'submitted';
})()

Replace QUERY_TEXT with the query as a JSON string. The first page has a hidden textarea with width 0. Target the visible one, and check that the text appears in the thread before reading.

5. Wait and read

6. Needle until the question is settled

Each follow-up should do one of these:

AI Mode often ends with a question about the user's personal details. Answer it only with real details from the user. If none exist, skip it.

Stop when the user's question has sourced, specific answers, or when three or four turns are going in circles. Report what is still open.

7. Save and return the path

Write one markdown file to sources/ in the current working directory (or a folder the user names), named google-ai-mode-<topic-slug>-<YYYY-MM-DD>.md, with frontmatter:

Then the body: each turn (user, then AI Mode, verbatim), the source URLs, and a "Run notes" section for anything that went wrong or was not verified. Return the full absolute path to the user.

Close any tab this session opened, unless the user wants it kept.

Known pitfalls

Learned on the 2026-10-31 run (15 answered threads, video-production research)

Show the raw text
---
name: google-ai-mode
description: Use Google AI Mode through Claude in Chrome to get a sourced answer to a question, push follow-ups until the question is answered, and save the full thread as a markdown source file. Use when the user asks to research a topic through Google AI Mode, or to turn an AI Mode conversation into a saved source.
---

# Google AI Mode via Claude in Chrome

Draft. Based on one probe session (GoogleSearchSkill project: `sources/google-ai-mode-probe-roth-ira-2026-10-30.md`). Update it after each real run.

## 1. Clarify the goal

Before touching the browser, confirm the user's goal. If the topic, the decision they need to make, or the time frame is missing, ask. Do not invent a persona or details. The probe used an invented persona, and AI Mode answered as if it were real.

## 2. Build the query

Turn the goal into one prompt that states:
- the topic and the exact question
- the specifics that matter (entities, dates, places, constraints)
- the output shape ("compare", "table", "worked example", "list the rules")
- "cite sources"

Only include details the user gave you.

## 3. Load tools and open AI Mode

- Load the Chrome tools in one ToolSearch call (see the `chrome-browser` skill).
- `tabs_context_mcp` with `createIfEmpty: true`, then `navigate` a new tab to `https://www.google.com/ai`. It redirects to `google.com/search?udm=50&aep=11`.

## 4. Submit the query

The `computer` tool path (click the box, `type`, `key Return`) did not land in the probe. The screenshot also timed out. Set the text through the page instead, with `javascript_tool`:

```js
(async () => {
  const ta = [...document.querySelectorAll('textarea')].find(e => e.placeholder === 'Ask anything' && e.getBoundingClientRect().width > 0)
          || document.querySelector('textarea');
  ta.focus();
  const set = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value').set;
  set.call(ta, QUERY_TEXT);
  ta.dispatchEvent(new Event('input', { bubbles: true }));
  await new Promise(r => setTimeout(r, 400));
  for (const type of ['keydown', 'keyup'])
    ta.dispatchEvent(new KeyboardEvent(type, { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true }));
  return 'submitted';
})()
```

Replace `QUERY_TEXT` with the query as a JSON string. The first page has a hidden textarea with width 0. Target the visible one, and check that the text appears in the thread before reading.

## 5. Wait and read

- Poll `document.body.innerText` until "is thinking" is gone. Answers took roughly 10 to 20 seconds.
- `get_page_text` returns CSS, not the answer. Read `document.body.innerText` in slices of about 1,000 characters, because tool output truncates.
- Source URLs: collect `a[href]` elements whose text is not a Google link. Query-string URLs may come back as "[BLOCKED: Cookie/query string data]". Read the path only in that case.

## 6. Needle until the question is settled

Each follow-up should do one of these:
- **Check a number.** Ask for the exact source link and the date of the figure. Compare the cited snippet with the answer's claim.
- **Test a confidence claim.** If the answer says "verified", "always", or "vastly superior", ask what it rests on, and what would change the answer.
- **Make it concrete.** Ask for a worked example with the user's real numbers, or with clearly labeled placeholder numbers.
- **Fill the gap.** Ask what the answer left out for the user's goal, such as exceptions, deadlines, or the other option.

AI Mode often ends with a question about the user's personal details. Answer it only with real details from the user. If none exist, skip it.

Stop when the user's question has sourced, specific answers, or when three or four turns are going in circles. Report what is still open.

## 7. Save and return the path

Write one markdown file to `sources/` in the current working directory (or a folder the user names), named `google-ai-mode-<topic-slug>-<YYYY-MM-DD>.md`, with frontmatter:
- title, captured date, tool, number of turns
- purpose, and whether the query was the user's real topic

Then the body: each turn (user, then AI Mode, verbatim), the source URLs, and a "Run notes" section for anything that went wrong or was not verified. Return the full absolute path to the user.

Close any tab this session opened, unless the user wants it kept.

## Known pitfalls

- AI Mode states financial, medical, and legal points with confidence it has not earned. Check each number against the cited source.
- AI Mode's footer says to consult a professional. Pass that on to the user. Do not treat the answer as advice.
- Do not enter personal data, account details, or credentials into the AI Mode box.

## Learned on the 2026-10-31 run (15 answered threads, video-production research)

- **Submitting reloads the page**, so an async script that submits and then waits dies with the page and returns `{}`. Split it: one `javascript_tool` call to submit, then wait, then a second call to read. A `browser_batch` of [navigate to `/ai`, submit, rename, `computer wait` x3, prune, `get_page_text`] did a whole thread in one round trip (about 30 s).
- **`get_page_text` returns the full answer text** (not only CSS). The real limit is `javascript_tool` output, which truncates at about 1,000 characters. Before calling `get_page_text`, prune the DOM to the last answer: find the end of your own query text with `lastIndexOf`, then replace `document.body` with a `<pre>` holding the text after it. This drops the sidebar and the earlier turns (a follow-up otherwise returns the whole thread again).
- **Done marker:** the page text contains `AI Mode response is ready` when the answer is complete; `is thinking` is present while it runs. Check once, instantly, after a `computer wait`. Do not loop with `setTimeout` for more than a few seconds: the call times out at 45 s.
- **One foreground tab at a time.** Two background tabs were throttled and then froze (`Runtime.evaluate` timed out), and tab ids changed after navigation, so re-run `tabs_context_mcp` after any error.
- **Keep tab titles short.** Every tool result lists each tab's title and URL, and AI Mode sets both to the full query. After submitting, run `history.replaceState(null, '', '/search?udm=50&aep=11'); document.title = 'T7'` to save about 1,000 tokens per call. Only do this on single-turn threads (a follow-up needs the thread URL).
- **A follow-up that challenged the previous answer ("which of these numbers are measured?") returned "no response available".** Ask the same thing as a fresh, self-contained thread instead.
- **Quality:** it contradicted itself between two questions on the same facts (stated numbers as fact, then said no primary source exists when asked), and asked to plan something specific it invented details that match nothing the user supplied. Use it for vocabulary, structure and leads; verify numbers, laws and policies on the primary page.
- **Posting from the page to a local server hangs** (the fetch to `127.0.0.1` never returned; probably a local-network permission prompt). Do not rely on it.
- No CAPTCHA appeared in about 18 queries over about an hour.

Shown as it is in the repository at build time (2026-11-03); the home directory appears as <home>. If this page and the file differ, the file is right. Back to the catalogue.