Clay検索 — Clay(営業・マーケティング支援プラットフォーム)の顧客開拓データベースで、高度な検索条件を使って人や企業を探し、検索結果をページ送りで閲覧します。 次のような場合に使用: ユーザーが既存のテーブルを問い合わせるのではなく、Clay内で新しい見込み客や取引先を検索したいとき
Clay search — find people or companies in Clay's GTM database with advanced queries and page through the matches. Use when the user wants to search Clay for prospects/accounts, not query an existing table.
Clay のマーケティング対象者データベース(営業・マーケティング向けの見込み客情報)を高度な検索で照会し、マッチしたレコード(人物または企業)を返します。
Audiences(ワークスペース内の人物・企業データ)は、既に保有している情報を読み取り、分類する場合に使用します。Search(Clay のマーケティング対象者データベース)は、新規リストを探す場合に使用します。これはテーブル内のデータを照会するスキルではなく、また自動化ワークフローのスキルでもありません。ワークスペースにまだ存在しない見込み客や顧客企業を探したい場合に Search を選んでください。
検索は3つのステップで、一方向のみに進む反復処理です:
searchId を受け取るhasMore が true の間、繰り返すカーソル(位置情報)はありません。反復処理の位置はサーバー側に保存され、前の状態に戻すことはできないため、呼び出すたびに前回の後のレコードが返されます。
クエリ(検索条件)を作成する前に、リファレンス(参照資料)をファイルに保存し、そこから読み込んでください。約2,000行もあり、1回のツール実行で表示できないため、標準出力に出力したり、最後まで読み込んだりしないでください:
clay searches query-mode reference | jq -r '.reference' > ./clay-search-reference.md
grep -n '^##' ./clay-search-reference.md
grep で行番号付きの全セクションが表示されます。これらセクションを行番号で読み込んでください(会話内で1回ずつ):
トピックセクション(位置情報フィルタリング、日付・経歴・最近性、企業識別、製品・サービス、企業規模・売上)は、リクエストで必要な場合のみ読んでください。Examples(例)で フィールド名またはフレーズを grep 検索して、作成済みクエリを確認してください。既にコンテキストにあるセクションを再度読まないでください。クエリは人物または企業のみを返します。求人情報の条件はそれらのネストされたフィルタ(jobs.exists(...)、company.jobs.any(...) など)です。ワークスペースの Audiences 参照については下の「Audiences」セクションで説明します。
clay searches --help(および clay searches <cmd> --help)でフラグと出力形式を確認してください。clay がパスに無い場合、または clay whoami が認証に失敗する場合は、setup スキルを実行してください。
クエリ言語は @audience_segment("segmentId") の参照をサポートしています。これらは検索実行時にワークスペースに対して解決されます。clay searches query-mode reference は Clay UI にも使われるため、「Resource selection required ... in the Clay Search panel」(リソース選択が必要...)と書かれている場合は、UI 表示にのみ適用されます。ここでクエリを作成するときは、自分で Audiences を解決してください:
@audience_segment("ALL") を使用してください。これはクエリのエンティティ全体の Audiences データセットです:clay.exclude_people_identifiers(@audience_segment("ALL")) または clay.exclude_company_identifiers(@audience_segment("ALL"))。検索や新たなセグメント作成の必要はありません。ユーザーが特定の Audiences に名前を付けた場合のみ、その特定セグメントを解決してください。clay audiences list --entity-type people|companies でセグメント ID が返されます。連絡先セグメントは人物クエリに対応し、アカウントセグメントは企業クエリに対応します。各レスポンスの cursor に --cursor を付けて続行してください。cursor が無くなるまで続けたら、名前を照合するか、重複を確認してください。ID を @audience_segment("<segmentId>") に書き込んでください。リファレンスの「Workspace resource references」(ワークスペースリソース参照)セクションに関数のシグネチャがあります — 例えば、連絡先 Audiences を除外するには clay.exclude_people_identifiers(@audience_segment("SEGMENT_ID"))、アカウント Audiences から現在の勤務先をターゲットにするには clay.filter_to_companies(@audience_segment("SEGMENT_ID")) です。条件を表現できるかどうかを判断する前に、リファレンスを確認してください。リファレンスにないフィールドまたは演算子を作り出さないでください。
クエリが条件を表現できない場合は、検索がサポートしていることと、ルーチン(定期的な処理)がサポートしていることに分割してください:
そのフィールドが検索の組み込みフィルタではないことをユーザーに伝えて、何も返さずにこの「検索 → ルーチン」パスを提案してください。routines スキルと、下の「次:結果を富化または保存する」を参照してハンドオフしてください。
create の前に、リクエストが汎用的で大規模な場合 — 業界と場所などのように条件が少ない場合(例「NYC のすべてのテック企業」)— 一旦立ち止まり、先に条件を絞ることを提案してください。検索で表現できる具体的な絞り込み方法2~3個を提案してください(企業規模、職位・職階、採用枠、技術スタック、製品・サービス、指定企業・ドメイン、または結果数の小さい上限)。確認されるか、条件が絞られるまで create を実行しないでください。必要な場合のみ広範なクエリを実行してください。リクエストが既に十分に限定されている場合はスキップしてください。その後、ユーザーが実行を主張した場合でも、下の「容量使用量が限界に近い場合の警告」が適用されるかどうかを確認してください。
clay searches query-mode reference | jq -r '.reference' > ./clay-search-reference.md
clay searches query-mode create --query '<query>'
create は { "searchId": "search_..." } を返します。
run は { "data": [ ... ], "hasMore": <boolean>, "periodQuota"?: { "limit", "used", "remaining", "resetsAt" } } を返します。--limit はページサイズです。periodQuota は run の成功時のレスポンスにのみ表示されます(create には表示されません)。値を作り出さないでください。同じ searchId を再利用してください。呼び出すたびに次のページが返されます。hasMore が true の間続行してください。ただし、periodQuota が返ってきた run の後は、次のページの前に下の「容量使用量が限界に近い場合の警告」を適用してください。hasMore が false になるか、容量が限界に近くなったら終了してください。ユーザーが明示的に続行を求めない限りは停止してください。
clay searches query-mode run <searchId> [--limit <n>]
workflows-discover-actions/cost-and-budget.md の共有費用ポリシーに基づいて、ルーチン容量チェックを内部的に続行してください。検索が結果を消費しているだけという理由で、容量を通知したり、承認を求めたりしないでください。下の「確認された容量使用量が限界に近い条件」は例外です。
periodQuota がある場合、作成または実行が N 個の結果を消費する前に(引き出す予定の容量であり、マッチセット全体ではありません)、remaining − N をチェックしてください。それが limit の15%未満を残す場合、一旦立ち止まり、確認してください:
この検索は {{N}} 個の結果を返し、期間容量の {{remaining − N}} を残します。
確認された場合のみ続行してください。そうでなければ、最低15%の残りを保持するより小さい取得を提案するか、停止してください。periodQuota がない場合はスキップしてください。
例:limit 10,000、remaining 2,000、N 1,500 → 500 残り(容量の5%)→ 警告を表示。
create または run が quota_exceeded で失敗した場合(終了コード 1、HTTP 402)、ワークスペースがプラン結果上限(リクエストあたり、検索あたり、または期間)またはクレジット・利用限度に達しています。短い待機は助になりません。エラーメッセージを読んで、以下から選択してください:
--limit で一度だけ再実行してください(例えば、無料プランは多くの場合1リクエスト50件)。--limit が何であれ run を実行しません(1 の場合を含む)。また、検索あたり上限を回避するために新しい create をしないでください。レポートが完成した成果です。エラーの短い容量アカウント説明を提供してください(アップグレード、指定期間のリセット、またはサポートに連絡)。常にプランセレクタを含めてください — エラーに URL がない場合は clay whoami | jq -r '.workspace.id' で <workspaceId> を解決して https://app.clay.com/workspaces/<workspaceId>/billing/plan-selector を使用してください(素の URL。エラーにプランセレクタ URL がある場合は、それを優先してください)。エラーにアップグレード URL またはアップグレードのコピーが含まれている場合は、そのセレクタを極めて目立つようにしてください:返答の最上部近くに、そして最後の行として再度 (このリンクでプランをアップグレード: <url>)。エラーでサポートに連絡するように指示されている場合は、そのパスから始めて、それでも自分でセルフサービスできるように1行のプランセレクタを追加してください。また、フォローアップの質問には公開検索ドキュメントも共有してください:https://developers.clay.com/searches#result-limits。ユーザーがプランをアップグレードするよう求める場合は、プランセレクタリンクを開いてください。元のリクエストで N 個の結果を求めた後の、後のメッセージでその旨を求められた場合のみ、残りを引き出してください。validation_error(終了コード 2)は、容量ではなく、不正な入力(悪いフラグ・フィルタ・クエリ)を意味します。server_error(終了コード 1)でクエリモードの作成・実行時に、短期的なアップストリーム障害が発生する可能性があります(例えば、run 時、セマンティッククエリ埋め込みサービスがタイムアウト)。create の場合、短い待機後に1回だけ再試行
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, save the reference to a file in your working directory and read it from there — it is about 2,000 lines, far larger than one tool result can hold, so never print it to stdout or read it end to end:
clay searches query-mode reference | jq -r '.reference' > ./clay-search-reference.md
grep -n '^##' ./clay-search-reference.md
The grep lists every section with its line number. Read these sections by line offset, once per conversation:
Read a topic section (Location filtering, Dates/tenure/recency, Company identification,
Products and services, Company size and revenue) only when the request needs it, and grep
Examples for a field or phrase to see a worked query. Do not re-read sections already in
your context. 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.
If clay isn't on PATH or clay whoami fails on auth, run the setup skill.
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 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.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 | jq -r '.reference' > ./clay-search-reference.md
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). Always include the plan selector —
resolve <workspaceId> with clay whoami | jq -r '.workspace.id' when the error has no
URL: https://app.clay.com/workspaces/<workspaceId>/billing/plan-selector (bare URL;
prefer a plan-selector URL from the error when present). If the error includes an upgrade
URL or upgrade copy, make that selector extremely prominent: near the top of the reply
and again as the last line (Upgrade your plan now at: <url>). If the error says to
contact support, lead with that path and still add one plan-selector line so they can
self-serve if they prefer. 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, open the plan selector 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.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。