home / skills / spm1001 / trousse / google-devdocs

google-devdocs skill

/skills/google-devdocs

This skill retrieves up-to-date Google developer documentation via the Developer Knowledge API, delivering Markdown and precise answers from trusted sources.

npx playbooks add skill spm1001/trousse --skill google-devdocs

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
4.9 KB
---
name: google-devdocs
description: >
  Orchestrates Google developer documentation lookups via REST API using a 2-step
  search-then-retrieve workflow (curl + jq, no MCP). BEFORE scraping or guessing at Google API
  docs, invoke FIRST — returns fresh Markdown from 11 indexed sites including docs.cloud.google.com,
  firebase.google.com, developer.android.com, and ai.google.dev. Triggers on 'check the Google
  docs', 'look up the Firebase docs', 'what do the Cloud docs say', 'Google API documentation',
  'search Google developer docs'. (user)
---

# Google Developer Docs

Search and retrieve official Google developer documentation via the Developer Knowledge REST API. Returns Markdown — no scraping, no MCP server, just `curl` + `jq`.

## Prerequisites

Set the API key as an environment variable:

```bash
export GOOGLE_DEVKNOWLEDGE_API_KEY="your-key-here"
```

To get a key:
1. Enable the [Developer Knowledge API](https://console.cloud.google.com/start/api?id=developerknowledge.googleapis.com) in a Google Cloud project
2. Create an API key on the [Credentials page](https://console.cloud.google.com/apis/credentials)
3. Restrict the key to **Developer Knowledge API** only

If the variable is missing, tell the user and stop — don't attempt calls without it.

## When to Use

- User asks about Google Cloud, Firebase, Android, Chrome, Gemini, TensorFlow, or web.dev APIs
- You need current docs for a Google API (training data may be stale)
- Troubleshooting a Google API error — search for the error message
- Comparing Google services ("Cloud Run vs Cloud Functions for X")

## When NOT to Use

- Non-Google documentation (use web search or mise fetch instead)
- Content not in the corpus (GitHub repos, blogs, YouTube, Stack Overflow)
- User already pasted the relevant docs into the conversation

## Corpus

ai.google.dev · developer.android.com · developer.chrome.com · developers.home.google.com · developers.google.com · docs.cloud.google.com · docs.apigee.com · firebase.google.com · fuchsia.dev · web.dev · www.tensorflow.org

Re-indexed within 24 hours of publication.

## Workflow

### 1. Search — find relevant chunks

```bash
curl -s "https://developerknowledge.googleapis.com/v1alpha/documents:searchDocumentChunks?query=$(python3 -c "import urllib.parse; print(urllib.parse.quote('YOUR QUERY'))")&pageSize=10&key=$GOOGLE_DEVKNOWLEDGE_API_KEY" | jq .
```

This returns up to 10 chunk snippets with `parent` document names. Read the snippets — they may answer the question directly.

**Tip:** Use natural language queries. "How to authenticate with Firebase Admin SDK" works better than keywords.

### 2. Retrieve — get full document if needed

If snippets aren't enough, fetch the full page Markdown:

```bash
curl -s "https://developerknowledge.googleapis.com/v1alpha/PARENT_VALUE?key=$GOOGLE_DEVKNOWLEDGE_API_KEY" | jq -r '.content'
```

Replace `PARENT_VALUE` with the `parent` from a search result (e.g. `documents/firebase.google.com/docs/admin/setup`).

### 3. Batch retrieve — multiple docs at once

```bash
curl -s "https://developerknowledge.googleapis.com/v1alpha/documents:batchGet?names[]=PARENT1&names[]=PARENT2&key=$GOOGLE_DEVKNOWLEDGE_API_KEY" | jq .
```

Max 20 documents per batch.

## Extracting Results with jq

```bash
# List just the parent doc names from search
... | jq -r '.results[].parent'

# Get snippet text from search
... | jq -r '.results[] | "## \(.parent)\n\(.content)\n"'

# Get full doc content as raw markdown
... | jq -r '.content'
```

## Anti-Patterns

| Pattern | Problem | Fix |
|---------|---------|-----|
| Searching without checking the env var | Cryptic 403 error | Check `$GOOGLE_DEVKNOWLEDGE_API_KEY` first |
| Fetching full docs before reading snippets | Wastes tokens on irrelevant pages | Snippets answer most questions |
| Using keywords instead of natural language | Poor search results | Ask a question: "How do I..." |
| Fetching more than 3 full docs at once | Context overload | Read snippets, fetch only the most relevant |
| Scraping the docs site instead | Fragile, may be blocked, stale | Use this API — that's what it's for |
| Adding a corpus/site filter param | Doesn't exist in the API | Scope via natural language: "Firebase authentication" not "site:firebase.google.com auth" |

## Error Handling

| HTTP Status | Meaning | Action |
|-------------|---------|--------|
| 400 | Bad request (e.g. pageSize > 20) | Check parameters |
| 403 | API key invalid or API not enabled | Verify key and project setup |
| 404 | Document not found | Check the `parent` value is correct |
| 429 | Rate limited | Wait and retry |

## Integration

- **With mise:** Use this skill for Google docs; use mise for Drive/Gmail/general web content
- **With web search:** Fall back to web search for content outside the corpus (blogs, GitHub, SO)

## Reference

See `references/api-reference.md` for full endpoint details, response schemas, and the complete corpus list.

Overview

This skill orchestrates lookups of official Google developer documentation using the Developer Knowledge REST API. It performs a two-step search-then-retrieve workflow (curl + jq) to return fresh Markdown from 11 indexed Google developer sites without scraping. Use it when you need current, authoritative docs for Cloud, Firebase, Android, TensorFlow, Gemini, and related Google developer platforms.

How this skill works

First, it issues a natural-language search query to the Developer Knowledge API to return up to 10 document chunk snippets and parent document names. Read those snippets to see if they answer the question. If more context is required, fetch the full document Markdown by retrieving the parent document or batch-getting up to 20 documents. All network calls require the GOOGLE_DEVKNOWLEDGE_API_KEY environment variable; if it’s missing the skill stops and informs the user.

When to use it

  • User asks about Google Cloud, Firebase, Android, Chrome, Gemini, TensorFlow, or web.dev APIs
  • You need up-to-date official docs because training data may be stale
  • Troubleshooting a Google API error by searching the exact error message
  • Comparing Google services (e.g., Cloud Run vs Cloud Functions)
  • When you want Markdown-formatted authoritative documentation instead of scraped HTML

Best practices

  • Always check that $GOOGLE_DEVKNOWLEDGE_API_KEY is set before making calls
  • Start with search snippets — they often answer the question and avoid unnecessary full fetches
  • Use natural-language queries (e.g., 'How to authenticate with Firebase Admin SDK') rather than terse keywords
  • Fetch full documents only for the most relevant parents and keep batch retrievals to three or fewer when possible
  • Handle 403/404/429 responses explicitly and report actionable next steps to the user

Example use cases

  • Find the current example for authenticating to Firestore with the Admin SDK
  • Search Cloud Run error text to find recommended fixes in official docs
  • Retrieve the full Markdown guide for Android background work best practices
  • Compare configuration instructions for Cloud Build vs Cloud Deploy
  • Fetch the latest Gemini developer guide section on model invocation

FAQ

What happens if the API key is missing?

The skill stops and informs you to set GOOGLE_DEVKNOWLEDGE_API_KEY; it will not attempt API calls without the key.

Can I restrict results to a single site?

The API has no site filter. Narrow results by using precise natural-language queries like 'Firebase authentication' or include site-specific terms in your query.