# Citation Monitor Lite: the automated version

Everything the spreadsheet does by hand, this does for you. Paste the prompt below into Claude Code and it builds a working command-line tool in one session.

You need an OpenAI API key. The tool uses a search-enabled model, which costs more than a plain chat call, roughly coffee money per weekly run on a 15-query set. That's the honest tradeoff: real cited sources instead of guessing.

---

## The prompt

```
Build a Python CLI tool called "citation-monitor" that tracks which sources
ChatGPT cites for a set of buyer queries.

Requirements:
- Read queries from queries.csv (columns: query_id, query, brand, competitors)
- For each query, call the OpenAI chat completions API with a search-enabled
  model and web search options enabled, N times (default 3, configurable).
  Note: search-preview models reject the temperature parameter entirely, so
  do not send one. Variation across samples comes from search behavior itself.
- Extract url_citation annotations from the response message annotations.
  For each citation record: query_id, sample, domain (hostname without www),
  url, title. If a sample returns no citations, record a no-citation marker
  row so hit rates stay accurate instead of silently inflating.
- Aggregate per query_id + domain: citation count, sample hit rate
  (samples containing the domain divided by total samples), one example URL.
- Make ONE batched classification call (a cheap model, temperature 0,
  JSON response format) classifying all unique domains into exactly one of:
  brand_site, competitor_site, review_platform, community, publisher,
  docs_or_other. Pass the target brand and competitor names for context.
  Batch it: one call per run regardless of how many domains came back.
- Append results to citations.csv with run_date, query_id, query, domain,
  citations, sample_hit_rate, source_type, example_url
- API key from the OPENAI_API_KEY environment variable, include a .env.example
- Async requests with rate limiting, retries with backoff, and a --dry-run flag
- Include tests for the aggregation logic
- Include a README explaining why citation frequency across samples beats a
  single check
```

---

## After it builds

Fill `queries.csv` with the same 10 to 20 buyer questions you'd put in the spreadsheet. No brand names. Ask what your buyer asks before they know you exist.

Run it weekly. Citation sources shift as models update their search behavior, so a domain that dominates this month can fade next month. One run is a snapshot. Weekly runs are a monitoring system.

## Reading the output

Sort `citations.csv` by how many distinct queries each domain appears on, not by total citation count. A domain cited twenty times on one query matters less than a domain appearing across seven different queries. Breadth is the signal that a single asset is doing structural work in your category.

Then use the "What To Do" tab in the spreadsheet to turn the pattern into a plan.

---

## Credit and sources

The methodology here follows Sara Soleymani's published citation-monitoring build (Medium, July 2026), which included both an n8n workflow and the original version of this Claude Code prompt. Worth reading directly if you want the full technical reasoning behind the sampling and classification choices.

Packaged and adapted for solo operators by The Closer Method. If you'd rather have this run for you across your whole category with a ranked fix plan attached, that's the AI Visibility Audit: closermethod.com/seo
