/clay:searches-advancedfrom clay
Performs advanced Clay GTM searches for people/companies with filters like geography, industry, growth, employer history, audiences, and relationships. Handles query validation and quota errors.
Ships in clay. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Before using this skill, read the clay entry skill if you haven’t already this session, and follow its access guidance.
Search Clay's GTM database with advanced queries and return matching records — people or companies.
Audiences is the workspace's own people and companies — read and segment what they already have. Search is Clay's GTM database for net-new lists. This is not the tables entry-point skill (querying data already in a table) and not the workflows entry-point skill (automations). Reach for Search when the user wants to find prospects or accounts not in the workspace yet.
A search is a three-step, forward-only iterator:
searchId.hasMore
is true.There is no cursor: the iterator's position lives server-side and can't be replayed, so
each run call returns the records after the previous one.
Before authoring a query, fetch only the reference sections the query needs, once per
conversation. Start with grammar, rules, and the field catalog for your entity:
clay searches query-mode reference --sections grammar,rules,people-fields | jq -r '.reference'
| Section | Fetch when |
|---|---|
grammar, rules | Before you write the first query in a conversation: syntax, scopes, functions, and query policies. Skip them on later fetches. |
people-fields | The search returns people. |
company-fields | The search returns companies, or a people search filters on employer attributes (company.* inside experiences.any(...)). It is the largest section, so skip it when you don't need it. |
company-people-fields | A companies search filters on its employees. It lists only what differs from people-fields; add people-fields too only if you need the shared fields and their allowed values. |
job-fields | The query filters on hiring. |
examples | You want worked queries. |
workspace-resources | The query references audiences or tables. |
Every field name and allowed enum value is in the field catalogs; a value that is not listed
fails validation. Request the fewest sections that cover the query and make a second call if
you find you need another. Sections come back in a fixed order, and an unknown name fails with validation_error.
If you do need every section, omit --sections. It is too large for one tool result, so
save it to a file and never print it to stdout:
clay searches query-mode reference | jq -r '.reference' > ./clay-search-reference.md
grep -n '^##' ./clay-search-reference.md
Do not re-read sections already in your context. If a query fails validation, fix it from the
error message and the field catalog, then retry. Queries return people or companies only; job-posting criteria are nested
filters on those (jobs.exists(...), company.jobs.any(...)). Workspace audience
references are covered in the Audiences section below.
Run clay searches --help (and clay searches <cmd> --help) for flags and output shapes.
For tool access or authentication problems, read the clay entry skill before continuing.
The query language supports @audience_segment("segmentId") references; they resolve
against the workspace when the search runs. clay searches query-mode reference also
serves the Clay UI, so wherever it says to route an audience to a picker ("Resource
selection required … in the Clay Search panel"), that applies only to the UI surface.
When authoring a query here, resolve the audience yourself:
@audience_segment("ALL"), the whole Audiences dataset for the
query's entity: clay.exclude_people_identifiers(@audience_segment("ALL")) or
clay.exclude_company_identifiers(@audience_segment("ALL")). No lookup, no segment to
create. Only resolve a specific segment when the user names a particular audience.clay audiences list --entity-type people|companies returns segment ids. Contact
segments match people queries; Account segments match companies queries. Follow each
response's cursor with --cursor until it is absent before matching a name or
checking for duplicates. Write the id into @audience_segment("<segmentId>"). The
reference's "Workspace resource references" section (--sections workspace-resources) has the function signatures — e.g.
clay.exclude_people_identifiers(@audience_segment("SEGMENT_ID")) to exclude a Contact
audience, or clay.filter_to_companies(@audience_segment("SEGMENT_ID")) to target
current employers from an Account audience.audiences skill:
list segments, then ask with them as choices.Check the reference before deciding whether it can express the criteria. Do not invent a field or operator that is not in the reference.
If the query can't express a criterion, split the request into what search can do and what a routine does:
Tell the user the field isn't a native search filter and offer this search → routine path
rather than returning nothing. See the routines skill and "Next: enrich or persist the
results" below for the handoff.
Before create, if the ask is generic and large — few criteria beyond something like
industry + location (e.g. "all tech companies in NYC") — stop and suggest refining first.
Offer 2–3 concrete narrowing options search can express (company size, title/seniority,
open roles, tech stack, products and services, named companies/domains, or a small result
limit). Do not create until they confirm or narrow; continue with the broad query only if
they insist. Skip when the ask is already clearly bounded. After they insist, still apply
Warn before near-exhaustion below when relevant.
clay searches query-mode reference --sections grammar,rules,people-fields | jq -r '.reference'
clay searches query-mode create --query '<query>'
create returns { "searchId": "search_..." }.
run returns { "data": [ ... ], "hasMore": <boolean>, "periodQuota"?: { "limit", "used", "remaining", "resetsAt" } }. --limit is the page size. periodQuota appears on
successful run responses only — not on create; do not invent values.
Reuse the same searchId; each call returns the next page. Continue while hasMore is
true, but after every run that returns periodQuota, apply Warn before
near-exhaustion below before the next page. Stop when hasMore is false, or when the
quota is near exhaustion — unless the user explicitly asks to continue.
clay searches query-mode run <searchId> [--limit <n>]
Keep routine quota checks internal under the shared cost policy in workflows-discover-actions/cost-and-budget.md. Do not
announce a quota or seek approval merely because a search consumes results. The verified
near-exhaustion condition below is an exception.
When periodQuota is present, before a create or run that will consume N results (the
volume you plan to pull, not the full match set), check remaining − N. If that would
leave under 15% of limit, stop and ask first:
This search will return {{N}} results and leave {{remaining − N}} of your period quota.
Continue only if they confirm. Otherwise offer a smaller pull that keeps at least 15%
remaining, or stop. Skip when periodQuota is absent.
Example: limit 10,000, remaining 2,000, N 1,500 → 500 left (5% of cap) → warn.
If a create or run fails with quota_exceeded (exit 1, HTTP 402), the workspace has hit a
plan result cap (per-request, per-search, or period) or a credit/usage limit. Short backoff
will not help. Read the error message and choose one of:
--limit ≤ that cap (e.g. free plans often allow 50 per request).run at any --limit (including 1), and no new create to work around a per-search
cap. The report is the finished deliverable. Give the short cap account from the error
(upgrade, named period reset, or contact support). If the error’s message includes an
upgrade URL, show it once, as the last line of the reply
(Upgrade your plan now at: <url>). Keep the URL intact, including its attribution.
If the error says to contact support or an account admin, lead with that path and still
add the upgrade line when the error supplies a link, so they can self-serve if they
prefer. If no link is supplied, relay the error’s guidance without constructing a billing
URL. Also share the public search docs for follow-up questions:
https://developers.clay.com/searches#result-limits. If the user asks to upgrade their
plan and the error supplies a link, open that link for them. Pull a remainder only if they ask for it in a
later message after that report; the original request for N results is not that ask.validation_error (exit 2) means malformed input (bad flags/filters/query), not a quota.
server_error (exit 1) on query-mode create/run can be a transient upstream fault (on run,
e.g. the semantic-query embedding service timed out). On create, retry once after a short
wait. On run, retry once only when no data came back — a retry re-serves the current page
and can charge and count it again if the failure happened after billing.
rate_limited (exit 4) is a short HTTP 429 backoff and may be retried after details.retryAfter.
Search only finds records. After paging results, offer one of two plugin paths — both via
clay routines runs start. See the routines skill for sizing runs and fetching results.
Prefer Clay-managed routines for standard enrichment. Before reaching for the raw
action catalog or building a workflow, list the full, paginated routines set and check
source: managed first. Clay ships managed routines that cover most enrichment — e.g.
Work Email, Company Domain, Enrich Person, Enrich Person and Find Contact
Details, Company Job Openings. Match on each routine's input schema
(clay routines get <id>), not its name. Only fall through to the action catalog or a new
workflow when no managed or custom routine fits.
clay routines list
clay routines get function:t_abc123
After Search has results, use the routines skill to start the run: list or get
the routine schema, then clay routines runs start.
When the user wants Search hits kept in the workspace, find or create a routine whose
underlying workflow upserts with upsert-audiences-record. If none exists, build the workflow
using the workflows skill's audiences.md, then to run in bulk see the routines skill.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub clay-run/agent-plugins --plugin clay39 skills in this plugin
/ad-syncsClay ad syncs — push an audience segment to ad platforms (LinkedIn, Meta, Google, Bing, Reddit, Vibe) as a custom audience. Use to create, edit, start, pause, or map the fields of an ad sync, or to check its status, match rate, or run history./audiencesClay Audiences — the workspace's own people, companies, and deals (contacts, leads, accounts, customers). Use for any request about their records when no surface is named, including counts, fill rates, lookups ("how many people have a phone?"), saved segments, and field definitions. Also deal and pipeline questions like largest opportunities, biggest pipeline items, recent wins, closed-won, deal stage, and ACV. Also Data hub enrichment configuration, audience assignments, and parity checks. Also the calls and meetings synced onto those records, such as Gong recordings, and which accounts discussed a topic on their calls./Other plugins' skills for the same job