nimble-agent-builder

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nimble Agent Builder

Nimble Agent Builder

Build, refine, and publish reusable extraction agents on the Nimble platform. Always finish with executed results or runnable code.
User request: $ARGUMENTS
在Nimble平台上构建、优化并发布可复用的提取agents。始终以执行结果或可运行代码收尾。
用户请求:$ARGUMENTS

Prerequisites

前提条件

Quick check:
nimble --version && echo "${NIMBLE_API_KEY:+API key: set}"
If CLI is missing or API key is not set, load
rules/setup.md
for one-time setup (CLI install, API key, MCP server).
快速检查:
nimble --version && echo "${NIMBLE_API_KEY:+API key: set}"
如果缺少CLI或未设置API密钥,请加载
rules/setup.md
进行一次性设置(CLI安装、API密钥、MCP服务器)。

Startup check — run this before anything else

启动检查 — 执行任何操作前先运行此步骤

Verify CLI is available:
bash
nimble --version && echo "${NIMBLE_API_KEY:+API key: set}"
If CLI and API key are set → proceed with the user's request normally.
If CLI is missing → check if the MCP server is connected as a fallback:
bash
claude mcp list 2>/dev/null | grep -q nimble-mcp-server && echo "MCP: connected" || echo "MCP: not connected"
  • MCP connected → proceed using MCP tools instead of CLI commands.
  • Neither CLI nor MCP available → load
    rules/setup.md
    for one-time setup (CLI install, API key). CLI is the preferred setup path.

验证CLI是否可用:
bash
nimble --version && echo "${NIMBLE_API_KEY:+API key: set}"
如果CLI和API密钥已设置 → 正常处理用户请求。
如果缺少CLI → 检查是否已连接MCP服务器作为备选方案:
bash
claude mcp list 2>/dev/null | grep -q nimble-mcp-server && echo "MCP: connected" || echo "MCP: not connected"
  • MCP已连接 → 使用MCP工具替代CLI命令继续操作。
  • CLI和MCP均不可用 → 加载
    rules/setup.md
    进行一次性设置(CLI安装、API密钥)。CLI是首选设置路径。

Skill ecosystem

技能生态系统

nimble-agent-builder and nimble-web-expert work as a pair in the Nimble toolkit:
SkillBest forKey commands
nimble-agent-builder (this skill)Build reusable agents — create, refine, and publish named extraction templates with fixed schemasCLI:
generate
,
get-generation
,
publish
nimble-web-expertReal-time data access — fetch any URL, search, map, crawl, run published agents
extract
,
search
,
map
,
crawl
,
agent run
nimble-agent-builder和nimble-web-expert是Nimble工具集中的一对配套技能:
技能适用场景核心命令
nimble-agent-builder(本技能)构建可复用agents——创建、优化并发布具有固定 schema 的命名提取模板CLI:
generate
,
get-generation
,
publish
nimble-web-expert实时数据访问——获取任意URL、搜索、映射、爬取、运行已发布的agents
extract
,
search
,
map
,
crawl
,
agent run

Stay in nimble-agent-builder for

适合使用nimble-agent-builder的场景

  • Generating a new agent for a domain
  • Refining or updating an existing agent (add fields, fix selectors, change schema)
  • Publishing an agent
  • Running a published agent via
    nimble agent run
    (CLI)
  • Validating agent output quality
  • Any task phrased as "build", "refine", "update", "add a field to", "publish"
  • 为某个领域生成新的agent
  • 优化或更新现有agent(添加字段、修复选择器、修改schema)
  • 发布agent
  • 通过
    nimble agent run
    (CLI)运行已发布的agent
  • 验证agent输出质量
  • 任何表述为“构建”、“优化”、“更新”、“为……添加字段”、“发布”的任务

When to route to nimble-web-expert

何时转向nimble-web-expert

After publishing an agent — run it directly here via
nimble agent run
(CLI). Route to nimble-web-expert only when the workflow needs tools this skill doesn't have:
  • Need a list of input URLs to feed into the agent? → Switch to nimble-web-expert, run
    nimble map --url <site>
    to crawl and generate the input list, then return here to run at scale.
  • Need to search for input params? → Switch to nimble-web-expert, run
    nimble search
    , then return here with the results.
When the task is not about building an agent:
  • One-off URL fetch, web search, site mapping, bulk crawl → nimble-web-expert
  • Tell the user: "This is a direct data access task, not an agent-building task. Use nimble-web-expert for this."
发布agent后——可在此处通过
nimble agent run
(CLI)直接运行。仅当工作流需要本技能不具备的工具时,才转向nimble-web-expert:
  • 需要输入URL列表供agent使用?→ 切换到nimble-web-expert,运行
    nimble map --url <site>
    爬取并生成输入列表,然后返回此处大规模运行。
  • 需要搜索输入参数?→ 切换到nimble-web-expert,运行
    nimble search
    ,然后将结果带回此处。
当任务与构建agent无关时:
  • 一次性URL获取、网页搜索、站点映射、批量爬取 → 使用nimble-web-expert
  • 告知用户:"这是直接数据访问任务,而非agent构建任务。请使用nimble-web-expert完成此操作。"

When agent generation needs site investigation

当agent生成需要站点调研时

If
nimble_agents_generate
or
nimble_agents_update_from_agent
cannot produce a working agent because the site's data structure is unknown (wrong selectors, missing XHR patterns, unexpected JS rendering):
Step 1 — Announce: "I can't generate a reliable agent without investigating the live page first. Spawning a site investigation..."
Step 2 — Spawn a Task agent (
Task(subagent_type="general-purpose", run_in_background=False)
):
Investigate {url} to find CSS selectors and/or XHR API endpoints needed to extract: {fields_needed}.

Use Playwright to probe the live page:
python3 << 'EOF'
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    page = browser.new_page()
    api_calls = []
    page.on("request", lambda req: api_calls.append(req) if req.resource_type in ("xhr","fetch") else None)
    page.goto("{url}")
    page.wait_for_timeout(5000)
    for sel in ["[data-price]",".price","h1","[data-testid*=title]","[data-testid*=price]",".product-title"]:
        el = page.query_selector(sel)
        if el: print(f"SELECTOR: {sel!r} -> {el.inner_text()[:80]!r}")
    for req in api_calls[:20]:
        print(f"XHR: {req.method} {req.url[:120]}")
    browser.close()
EOF

Also run a quick nimble extract to check raw rendered HTML:
nimble extract --url "{url}" --render --format markdown | head -100

Return a structured report:
- SELECTORS: working CSS selectors for each required field
- XHR_URLS: any relevant API endpoints found
- RENDER_REQUIRED: yes/no
- SUGGESTED_EXTRACT_COMMAND: the nimble extract command that would work
- NOTES: login walls, pagination, lazy loading, or anything unusual

Do NOT use AskUserQuestion.
Step 3 — Use the report to retry agent generation: pass the selector/XHR context and suggested extract command in the
nimble_agents_update_session
call.
Step 4 — If investigation also fails: Tell the user: "This site requires complex browser automation that can't be captured in an agent at this stage. Use nimble-web-expert's Tier 4/5 commands with
--browser-action
or
--network-capture
to access the data directly."

如果
nimble_agents_generate
nimble_agents_update_from_agent
无法生成可用的agent,因为站点的数据结构未知(选择器错误、缺少XHR模式、JS渲染不符合预期):
步骤1 — 告知用户: "在调研实际页面之前,我无法生成可靠的agent。正在启动站点调研……"
步骤2 — 启动Task agent (
Task(subagent_type="general-purpose", run_in_background=False)
):
Investigate {url} to find CSS selectors and/or XHR API endpoints needed to extract: {fields_needed}.

Use Playwright to probe the live page:
python3 << 'EOF'
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    page = browser.new_page()
    api_calls = []
    page.on("request", lambda req: api_calls.append(req) if req.resource_type in ("xhr","fetch") else None)
    page.goto("{url}")
    page.wait_for_timeout(5000)
    for sel in ["[data-price]",".price","h1","[data-testid*=title]","[data-testid*=price]",".product-title"]:
        el = page.query_selector(sel)
        if el: print(f"SELECTOR: {sel!r} -> {el.inner_text()[:80]!r}")
    for req in api_calls[:20]:
        print(f"XHR: {req.method} {req.url[:120]}")
    browser.close()
EOF

Also run a quick nimble extract to check raw rendered HTML:
nimble extract --url "{url}" --render --format markdown | head -100

Return a structured report:
- SELECTORS: working CSS selectors for each required field
- XHR_URLS: any relevant API endpoints found
- RENDER_REQUIRED: yes/no
- SUGGESTED_EXTRACT_COMMAND: the nimble extract command that would work
- NOTES: login walls, pagination, lazy loading, or anything unusual

Do NOT use AskUserQuestion.
步骤3 — 使用报告重试agent生成:在
nimble_agents_update_session
调用中传入选择器/XHR上下文和建议的extract命令。
**步骤4 — 如果调研也失败:**告知用户:"该站点需要复杂的浏览器自动化,目前无法通过agent实现。请使用nimble-web-expert的Tier 4/5命令并添加
--browser-action
--network-capture
参数直接访问数据。"

Core principles

核心原则

  • Fastest path to data. Default route: discover agent → get schema → run → display results. Planning and generation are escalation paths.
  • Always search existing agents first. Run
    nimble agent list --limit 100 --search "<domain or vertical>"
    (CLI) before considering generate. Hard rule.
  • Update over generate — always. When a close-match agent exists (same domain/type, even if missing fields or different scope), update it rather than generating from scratch. Updating preserves proven extraction logic and is faster, cheaper, and more reliable. Only generate a new agent when the
    --search
    query returns 0 matches for the target domain. Never offer "Create new agent" as the recommended option when a close match exists.
  • AskUserQuestion at every decision point in the foreground — no exceptions. Always present the standard
    AskUserQuestion
    prompts shown in each step. Never skip them, never auto-advance without asking. Never present choices as plain numbered lists. Constraints: 2–4 options, header max 12 chars, label 1–5 words. Recommended option goes first with "(Recommended)". Note: Task agents NEVER use AskUserQuestion — all decisions are pre-made before launching the Task.
  • Schema before run — always. Run
    nimble agent get --template-name <name>
    (CLI) before
    nimble agent run
    . Present input parameters and output fields in markdown tables. This applies when switching agents too.
  • Script generation (Step 2B) is ONLY for large-scale, high-volume tasks. Never generate code for normal interactive requests. Script mode requires ALL of: scale >50 items AND the user explicitly asks for code/script/CSV/batch output. Multi-source requests, dataset requests, and comparison requests do NOT automatically trigger script mode — run them interactively first. The default path is always: discover → run → display results.
  • Verify response shape before script generation. Check
    skills
    and
    entity_type
    from
    nimble agent get --template-name
    (CLI) to determine REST API response nesting. See
    references/agent-api-reference.md
    > "Response shape inference" and
    references/sdk-patterns.md
    > "Response structure verification".
  • google_search
    is not a general search tool.
    It is a SERP analysis agent for rank tracking and SEO analysis. For finding information, use
    nimble search
    (CLI). See
    references/error-recovery.md
    .
  • All web search MUST use
    nimble search
    (CLI).
    Never use
    WebSearch
    ,
    WebFetch
    ,
    curl
    , or
    wget
    . See Guardrails.
  • Agent creation/update runs in background Task agents. Generation takes 1-3 minutes — run the generate → poll → publish loop as a Task agent so the user isn't blocked. See Delegation model.
  • 最快获取数据路径。默认流程:发现agent → 获取schema → 运行 → 显示结果。规划和生成为升级路径。
  • 始终先搜索现有agents。在考虑生成之前,运行
    nimble agent list --limit 100 --search "<domain or vertical>"
    (CLI)。硬性规则。
  • 优先更新而非生成。当存在匹配度较高的agent(相同领域/类型,即使缺少字段或范围不同)时,更新它而非从头生成。更新会保留经过验证的提取逻辑,更快、更便宜、更可靠。仅当
    --search
    查询针对目标领域返回0个匹配结果时,才生成新agent。当存在匹配度较高的agent时,绝不要将“创建新agent”作为推荐选项。
  • 在每个决策点都使用AskUserQuestion——无例外。始终显示各步骤中的标准
    AskUserQuestion
    提示。绝不跳过,绝不未经询问自动推进。绝不以普通编号列表形式呈现选项。约束:2–4个选项,标题最多12个字符,标签1–5个词。推荐选项排在最前面并标注"(Recommended)"。注意:Task agents绝不使用AskUserQuestion——所有决策在启动Task前已预先确定。
  • 先确认Schema再运行。运行
    nimble agent run
    之前,先运行
    nimble agent get --template-name <name>
    (CLI)。以markdown表格形式呈现输入参数和输出字段。切换agents时同样适用。
  • 脚本生成(步骤2B)仅适用于大规模、高容量任务。绝不为普通交互式请求生成代码。脚本模式需要同时满足:规模>50条数据 用户明确要求代码/脚本/CSV/批量输出。诸如“数据集”、“对比”、“多源”或“2个源”等词汇不会触发脚本模式——先以交互式方式运行。默认路径始终是:发现 → 运行 → 显示结果。
  • 生成脚本前验证响应格式。从
    nimble agent get --template-name
    (CLI)的结果中检查
    skills
    entity_type
    ,以确定REST API响应的嵌套结构。参见**
    references/agent-api-reference.md
    ** > "Response shape inference"和**
    references/sdk-patterns.md
    ** > "Response structure verification"。
  • google_search
    不是通用搜索工具
    。它是用于排名跟踪和SEO分析的SERP分析agent。查找信息请使用
    nimble search
    (CLI)。参见**
    references/error-recovery.md
    **。
  • 所有网页搜索必须使用
    nimble search
    (CLI)
    。绝不要使用
    WebSearch
    WebFetch
    curl
    wget
    。参见Guardrails
  • agent创建/更新在后台Task agents中运行。生成需要1-3分钟——将生成→轮询→发布循环作为Task agent运行,避免用户被阻塞。参见Delegation model

Delegation model

委托模型

The foreground conversation orchestrates and presents results. Task agents handle long-running work (generation, discovery, script generation).
Foreground — direct CLI calls via Bash:
CLI commandPurposeMax calls
nimble agent list --limit 100 --search "<domain>"
Route to existing agent1 per domain
nimble agent get --template-name
Display schema before run1 per agent
nimble agent run --agent --params
Interactive execution (≤5 items)1 per item
nimble search
Web search / discoveryAs needed
Task agents — long-running operations:
PhaseTask agentForeground does
Discovery (
nimble search
+
nimble map
)
Step 1DLaunch, present report
Agent create/update (
nimble agent generate
get-generation
poll →
publish
)
Step 3Launch, present report
Script generation (write code to call existing agent)Step 2BLaunch, present script
Agent creation runs in a Task agent because generation takes 1-3 minutes (poll loop). The Task agent uses CLI commands via Bash. If CLI is unavailable, it falls back to MCP tools.
For multi-source workflows, launch Task agents sequentially (one per source/phase). Gather reports, then present the combined plan.
前台对话负责编排和呈现结果。Task agents处理长时间运行的工作(生成、发现、脚本生成)。
前台 — 通过Bash直接调用CLI:
CLI命令用途最大调用次数
nimble agent list --limit 100 --search "<domain>"
转向现有agent每个领域1次
nimble agent get --template-name
运行前显示schema每个agent1次
nimble agent run --agent --params
交互式执行(≤5条数据)每条数据1次
nimble search
网页搜索 / 发现按需调用
Task agents — 长时间运行的操作:
阶段Task agent前台操作
发现(
nimble search
+
nimble map
步骤1D启动,呈现报告
Agent创建/更新(
nimble agent generate
get-generation
轮询 →
publish
步骤3启动,呈现报告
脚本生成(编写代码调用现有agent)步骤2B启动,呈现脚本
Agent创建在Task agent中运行,因为生成需要1-3分钟(轮询循环)。 Task agent通过Bash使用CLI命令。如果CLI不可用,则回退到MCP工具。
对于多源工作流,依次启动Task agents(每个源/阶段一个)。收集报告,然后呈现合并后的计划。

CLI commands for Task agents

Task agents可用的CLI命令

All Task agent prompts should include this block so the subagent knows the available commands:
**CLI tools (use via Bash):**
- `nimble agent list --limit 100 --search "<domain or vertical>"` — search agents by domain/vertical
- `nimble agent get --template-name <name>` — get agent schema
- `nimble agent run --agent <name> --params '{...}'` — run an agent
- `nimble agent generate --agent-name <name> --prompt "<prompt>" --url "<url>"` — create/refine agent
- `nimble agent generate --agent-name <name> --from-agent <name> --prompt "<prompt>"` — iterate on existing agent
- `nimble agent get-generation --generation-id <id>` — poll generation status
- `nimble agent publish --agent-name <name> --version-id <id>` — publish agent
- `nimble search --query "<query>"` — web search (deep by default)
- `nimble map --url <url> --limit 50` — discover URL patterns on a site

**MCP fallback (only if CLI is not installed):**
| CLI command | MCP tool |
|---|---|
| `nimble agent generate` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_generate` |
| `nimble agent get-generation` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_status` |
| `nimble agent publish` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_publish` |

**CRITICAL: Prefer CLI for all operations. Use MCP only when CLI is unavailable. NEVER use WebSearch, WebFetch, curl, or wget. NEVER construct MCP endpoint URLs manually.**
所有Task agent提示应包含以下块,以便子agent了解可用命令:
**CLI工具(通过Bash使用):**
- `nimble agent list --limit 100 --search "<domain or vertical>"` — 按领域/垂直领域搜索agents
- `nimble agent get --template-name <name>` — 获取agent schema
- `nimble agent run --agent <name> --params '{...}'` — 运行agent
- `nimble agent generate --agent-name <name> --prompt "<prompt>" --url "<url>"` — 创建/优化agent
- `nimble agent generate --agent-name <name> --from-agent <name> --prompt "<prompt>"` — 基于现有agent迭代优化
- `nimble agent get-generation --generation-id <id>` — 轮询生成状态
- `nimble agent publish --agent-name <name> --version-id <id>` — 发布agent
- `nimble search --query "<query>"` — 网页搜索(默认深度搜索)
- `nimble map --url <url> --limit 50` — 发现站点上的URL模式

**MCP备选方案(仅当未安装CLI时使用):**
| CLI命令 | MCP工具 |
|---|---|
| `nimble agent generate` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_generate` |
| `nimble agent get-generation` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_status` |
| `nimble agent publish` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_publish` |

**重要提示:优先使用CLI执行所有操作。仅当CLI不可用时才使用MCP。绝不要使用WebSearch、WebFetch、curl或wget。绝不要手动构造MCP端点URL。**

Response shapes

响应格式

LayerPathShapeWhen used
CLI (
nimble agent run
) — SERP
data.parsing
list
(array)
Interactive run (Step 2A)
CLI (
nimble agent run
) — PDP
data.parsing
dict
(flat)
Interactive run (Step 2A)
REST API — ecommerce SERP
data.parsing
list
(array)
Script generation (Step 2B)
REST API — non-ecommerce SERP
data.parsing.entities.{Type}
dict
with nested arrays
Script generation (Step 2B)
REST API — PDP
data.parsing
dict
(flat)
Script generation (Step 2B)
Always check
typeof
/
isinstance
before iterating REST responses.
层级路径格式使用场景
CLI(
nimble agent run
)— SERP
data.parsing
list
(数组)
交互式运行(步骤2A)
CLI(
nimble agent run
)— PDP
data.parsing
dict
(扁平结构)
交互式运行(步骤2A)
REST API — 电商SERP
data.parsing
list
(数组)
脚本生成(步骤2B)
REST API — 非电商SERP
data.parsing.entities.{Type}
包含嵌套数组的
dict
脚本生成(步骤2B)
REST API — PDP
data.parsing
dict
(扁平结构)
脚本生成(步骤2B)
遍历REST响应前始终检查
typeof
/
isinstance

Step 1: Route

步骤1:路由

From
$ARGUMENTS
, detect 3 things:
1. Clarity
clear
(default) or
needs-planning
Only
needs-planning
when ALL of these are absent: a target URL/site/domain, clear data to extract, a single well-scoped task. Most requests are
clear
.
2. Agent match — run
nimble agent list --limit 100 --search "<domain or vertical>"
(CLI, Bash). Use the user's named domain/site as the search term (e.g.
--search "amazon"
,
--search "jobs"
,
--search "ecommerce"
). This is ALWAYS the first action. For multi-source requests (e.g., "compare Amazon and Walmart prices"), run one search per source. If no match found for a source, route it to Discovery (Step 1D).
ResultRoute
Exact matchShow schema summary +
AskUserQuestion
: "Use this agent" (Recommended) / "Create new agent" → Step 3
Close match (same domain/type, missing fields or different scope)Show schema gaps +
AskUserQuestion
: "Update this agent" (Recommended) / "Create new agent". Always recommend update — it preserves existing extraction logic and is faster than generating from scratch.
2+ plausible matchesShow table +
AskUserQuestion
with top matches + "Update closest agent" (Recommended). Pick the agent with the most field overlap.
0 matchesLaunch Discovery Task agent (Step 1D) → results inform Step 3. This is the ONLY case where generating a new agent is appropriate.
3. Execution mode
interactive
(default) or
script
Interactive is ALWAYS the default. Route to script generation (Step 2B) ONLY when BOTH conditions are met: (a) scale is explicitly >50 items or the user provides a batch input file, AND (b) the user explicitly asks for code, a script, a CSV export, or batch processing. Words like "dataset", "compare", "multi-source", or "2 sources" do NOT trigger script mode — run these interactively. Script generation writes code that calls an existing agent — it does not create new agents. If no agent exists yet, resolve that first (Step 3) before generating a script.
$ARGUMENTS
中检测3项内容:
1. 清晰度
clear
(默认)或
needs-planning
仅当以下所有内容均缺失时才为
needs-planning
:目标URL/站点/领域、明确的提取数据、单一范围明确的任务。大多数请求为
clear
2. Agent匹配 — 运行
nimble agent list --limit 100 --search "<domain or vertical>"
(CLI,Bash)。使用用户指定的领域/站点作为搜索词(例如
--search "amazon"
--search "jobs"
--search "ecommerce"
)。这始终是第一个操作。对于多源请求(例如“对比亚马逊和沃尔玛的价格”),为每个源运行一次搜索。如果某个源没有匹配结果,将其路由到发现步骤(步骤1D)。
结果路由
完全匹配显示schema摘要 +
AskUserQuestion
:"使用此agent"(推荐)/ "创建新agent" → 步骤3
匹配度较高(相同领域/类型,缺少字段或范围不同)显示schema差距 +
AskUserQuestion
:"更新此agent"(推荐)/ "创建新agent"。始终推荐更新——它保留现有提取逻辑,比从头生成更快。
2个及以上合理匹配显示表格 +
AskUserQuestion
,包含顶级匹配项 + "更新最匹配的agent"(推荐)。选择字段重叠最多的agent。
0个匹配启动发现Task agent(步骤1D)→ 结果用于步骤3。这是唯一适合生成新agent的情况。
3. 执行模式
interactive
(默认)或
script
交互式始终为默认模式。仅当同时满足以下两个条件时,才路由到脚本生成(步骤2B):(a) 规模明确>50条数据或用户提供批量输入文件, (b) 用户明确要求代码、脚本、CSV导出或批量处理。诸如“数据集”、“对比”、“多源”或“2个源”等词汇不会触发脚本模式——以交互式方式运行这些任务。脚本生成编写调用现有agent的代码——它不创建新agent。如果尚无agent存在,先解决此问题(步骤3)再生成脚本。

Step 1P: Plan mode (rare — only when
needs-planning
)

步骤1P:规划模式(罕见 — 仅当
needs-planning
时)

  1. Clarify
    AskUserQuestion
    to resolve critical unknowns (max 2 questions). Focus on: what site(s), what data fields, what output format.
  2. Explore
    nimble agent list --limit 100 --search "<domain>"
    (CLI, once per domain). For unfamiliar domains, launch Discovery Task agents (Step 1D).
  3. Present plan — gap analysis table:
#Site / Data SourceAgentStatus
1amazon.com productsamazon-product-detailsExisting
2walmart.com productsGenerate
  1. Execute — Step 2 for existing agents, Step 3 for generations (as Task agents).
  1. 澄清 — 使用
    AskUserQuestion
    解决关键未知问题(最多2个问题)。重点:哪些站点、哪些数据字段、什么输出格式。
  2. 探索
    nimble agent list --limit 100 --search "<domain>"
    (CLI,每个领域一次)。对于不熟悉的领域,启动发现Task agents(步骤1D)。
  3. 呈现计划 — 差距分析表格:
#站点 / 数据源Agent状态
1amazon.com产品amazon-product-details已存在
2walmart.com产品需生成
  1. 执行 — 现有agent使用步骤2,需生成的agent使用步骤3(作为Task agents)。

Step 1D: Discovery (Task agent — for unfamiliar domains)

步骤1D:发现(Task agent — 针对不熟悉的领域)

Launch when
nimble agent list --limit 100 --search "<domain>"
returns 0 matches for the target domain and it needs exploration. Runs as
Task(subagent_type="general-purpose", run_in_background=False)
. The foreground tells the user: "Exploring {domain} to understand available data..."
Task prompt template:
Explore {domain} for {user_intent}.

Use the Nimble CLI to discover the site structure and available data:

1. **Map the site** (understand URL patterns and sections):
   ```bash
   nimble map --url "https://{domain}" --limit 50
This reveals listing pages, detail pages, site sections, and URL patterns.
  1. Search for real examples (deep content extraction):
    bash
    nimble search --query "{domain} {keywords}" --max-results 5
    This fetches and extracts full page content from each result, giving you product listings, field structures, and example data.
Return a structured report:
  • DOMAIN: {domain}
  • ESTIMATED_ITEMS: count matching query
  • LISTING_URL_PATTERN: e.g., /category/filter?color=green
  • DETAIL_URL_PATTERN: e.g., /p/{slug}-{SKU}.html
  • AVAILABLE_FIELDS: list of extractable fields (name, price, description, materials, etc.)
  • MISSING_FIELDS: fields the user wants but the site doesn't have (e.g., ratings, reviews)
  • RECOMMENDED_APPROACH: generate custom agent / use existing agent from {alternative} / combine sources
  • SAMPLE_URLS: 2–3 example URLs for agent generation
  • LIMITATIONS: login walls, pagination limits, JS rendering, etc.
Do NOT use AskUserQuestion. Do NOT use nimble_find_search_agent, nimble_run_search_agent, or nimble_url_extract. Do NOT use WebSearch, WebFetch, or any non-Nimble-CLI search/fetch method.

On receiving the report, the foreground conversation:

1. Presents key findings to the user.
2. If data gaps exist (e.g., missing ratings), asks the user via `AskUserQuestion` how to proceed.
3. Routes to Step 3 (generate) with the discovery context, or Step 2 if existing agents cover the need.
nimble agent list --limit 100 --search "<domain>"
针对目标领域返回0个匹配结果且需要探索时启动。以
Task(subagent_type="general-purpose", run_in_background=False)
运行。前台告知用户:"正在探索{domain}以了解可用数据……"
Task提示模板:
针对{user_intent}探索{domain}。

使用Nimble CLI发现站点结构和可用数据:

1. **映射站点**(了解URL模式和板块):
   ```bash
   nimble map --url "https://{domain}" --limit 50
这会揭示列表页、详情页、站点板块和URL模式。
  1. 搜索真实示例(深度内容提取):
    bash
    nimble search --query "{domain} {keywords}" --max-results 5
    这会获取并提取每个结果的完整页面内容,提供产品列表、字段结构和示例数据。
返回结构化报告:
  • DOMAIN: {domain}
  • ESTIMATED_ITEMS: 匹配查询的数量
  • LISTING_URL_PATTERN: 例如 /category/filter?color=green
  • DETAIL_URL_PATTERN: 例如 /p/{slug}-{SKU}.html
  • AVAILABLE_FIELDS: 可提取字段列表(名称、价格、描述、材质等)
  • MISSING_FIELDS: 用户需要但站点没有的字段(例如评分、评论)
  • RECOMMENDED_APPROACH: 生成自定义agent / 使用{alternative}的现有agent / 合并数据源
  • SAMPLE_URLS: 2–3个用于agent生成的示例URL
  • LIMITATIONS: 登录墙、分页限制、JS渲染等
请勿使用AskUserQuestion。请勿使用nimble_find_search_agent、nimble_run_search_agent或nimble_url_extract。 请勿使用WebSearch、WebFetch或任何非Nimble-CLI的搜索/获取方法。

收到报告后,前台对话:

1. 向用户呈现关键发现。
2. 如果存在数据差距(例如缺少评分),通过`AskUserQuestion`询问用户如何处理。
3. 根据发现的上下文路由到步骤3(生成),或如果现有agent满足需求则路由到步骤2。

Step 2: Run existing agent

步骤2:运行现有agent

Two sub-paths based on execution mode.
根据执行模式分为两个子路径。

2A: Interactive (small scale, display output)

2A:交互式(小规模,显示输出)

2A-1. Run
nimble agent get --template-name <name>
(CLI). Present schema in markdown tables:
  • Input parameters: name, required, type, description, example
  • Output fields: key fields from
    skills
    dict
See
references/agent-api-reference.md
> "Input Parameter Mapping" for the full
input_properties
format and mapping rules.
2A-2. Always confirm before running via
AskUserQuestion
:
question: "Run {agent_name} with these parameters?"
header: "Confirm"
options:
  - label: "Run agent (Recommended)"
    description: "Execute {agent_name} with {summary of inferred parameters}"
  - label: "Change parameters"
    description: "Adjust input parameters before running"
  - label: "Create new agent"
    description: "Create a custom agent instead (Step 3)"
2A-3. Run
nimble agent run --agent <name> --params '{...}'
(CLI). Present results as markdown table. Always ask what to do next:
question: "What next?"
header: "Next step"
options:
  - label: "Done"
    description: "Finish with these results"
  - label: "Run again"
    description: "Re-run with different parameters"
Do NOT offer script generation as a next step unless the user explicitly mentions needing large-scale extraction (>50 items) or batch processing. Script generation is not a natural follow-up to interactive runs.
Bulk (2–5 URLs): Run per URL, aggregate results, handle individual failures without aborting. See
references/batch-patterns.md
> "Interactive batch extraction".
2A-1. 运行
nimble agent get --template-name <name>
(CLI)。以markdown表格形式呈现schema:
  • 输入参数: 名称、是否必填、类型、描述、示例
  • 输出字段:
    skills
    字典中的关键字段
参见**
references/agent-api-reference.md
** > "Input Parameter Mapping"获取完整的
input_properties
格式和映射规则。
2A-2. 运行前始终通过
AskUserQuestion
确认:
question: "使用这些参数运行{agent_name}?"
header: "确认"
options:
  - label: "运行agent(推荐)"
    description: "使用{推断参数摘要}执行{agent_name}"
  - label: "修改参数"
    description: "运行前调整输入参数"
  - label: "创建新agent"
    description: "改为创建自定义agent(步骤3)"
2A-3. 运行
nimble agent run --agent <name> --params '{...}'
(CLI)。以markdown表格形式呈现结果。始终询问下一步操作:
question: "下一步做什么?"
header: "下一步"
options:
  - label: "完成"
    description: "结束并保留这些结果"
  - label: "重新运行"
    description: "使用不同参数重新运行"
除非用户明确提及需要大规模提取(>50条数据)或批量处理,否则不要将脚本生成作为下一步选项。脚本生成不是交互式运行的自然后续操作。
批量处理(2–5个URL): 逐个URL运行,汇总结果,处理单个失败而不中止。参见**
references/batch-patterns.md
** > "Interactive batch extraction"。

2B: Script generation (ONLY for large-scale, high-volume tasks)

2B:脚本生成(仅适用于大规模、高容量任务)

This step is ONLY reached when the user explicitly needs to process >50 items at scale or requests batch code/script generation. Normal requests — even multi-source or "dataset" requests — are handled interactively via Step 2A. Writes a runnable script that calls an existing Nimble agent at scale via the SDK/REST API. This does NOT create new agents — the agent must already exist. Runs as a Task agent. The foreground infers language, launches the agent, and presents the generated script for confirmation.
2B-1. Infer language from project context (foreground, before launching):
Project fileLanguage
pyproject.toml
,
requirements.txt
,
*.py
Python
package.json
,
tsconfig.json
TypeScript/Node
go.mod
Go (REST API)
None of the aboveDefault to Python
2B-2. Launch script generation Task agent:
Task(subagent_type="general-purpose", run_in_background=False)
.
Task prompt template:
Write a {language} script that calls existing Nimble agent(s) at scale via SDK/REST API.

**Use the Nimble CLI to inspect agent schemas (via Bash, NOT MCP):**
```bash
nimble agent get --template-name <agent_name>
This returns the full input/output schema for the agent.
CRITICAL: Use CLI (Bash) for all Nimble operations. NEVER use WebSearch, WebFetch, curl, or wget. NEVER construct MCP endpoint URLs manually.
Existing agents to call: {agent_names} User intent: {user_prompt} Output format: {csv/json/etc} Scale: {number of items/queries}
This is SCRIPT GENERATION — writing code that calls existing agents. Do NOT create new agents (no nimble_agents_generate/update/publish). The agents listed above already exist.
Steps:
  1. Run
    nimble agent get --template-name <agent>
    (CLI) for each agent to inspect input_properties and skills.
  2. Read the reference files:
    • references/sdk-patterns.md
      (Python) or
      references/rest-api-patterns.md
      (other languages)
    • references/batch-patterns.md
      (for multi-store normalization)
  3. Write a complete, ready-to-run script with:
    • Smoke test first — validate a single query before full batch. Abort on failure.
    • Progress reporting — compact single-line status after each poll cycle.
    • Pagination handling for large result sets.
    • Multi-store field normalization (if applicable).
    • Output to {format}.
    • Incremental file writes for large pipelines (50+ jobs).
Return the complete script and a brief summary of:
  • Agent schemas used (input params, key output fields)
  • Normalization mappings (if multi-store)
  • Total estimated API calls
Do NOT use AskUserQuestion. Do NOT use nimble_find_search_agent or nimble_run_search_agent. Do NOT call nimble_agents_generate, nimble_agents_update_from_agent, nimble_agents_update_session, or nimble_agents_publish. Do NOT use WebSearch, WebFetch, bash curl, or any non-MCP search/fetch method.

**2B-3.** Present the generated script and confirm execution via `AskUserQuestion` (foreground):
question: "Run this script?" header: "Confirm" options:
  • label: "Run script (Recommended)" description: "Execute the generated script"
  • label: "Edit first" description: "Review and modify the script before running"

**No agent validation step here.** The 50-input validation flow (Step 3) is only for agent creation/update. Script generation uses an existing, already-validated agent — just write the script and run it.
仅当用户明确需要处理>50条数据或请求批量代码/脚本生成时,才进入此步骤。普通请求——即使是多源或“数据集”请求——通过步骤2A以交互式方式处理。编写可运行的脚本,通过SDK/REST API大规模调用现有的Nimble agent。此步骤不创建新agent——agent必须已存在。以Task agent运行。前台推断语言,启动agent,并呈现生成的脚本供确认。
2B-1. 根据项目上下文推断语言(前台,启动前):
项目文件语言
pyproject.toml
,
requirements.txt
,
*.py
Python
package.json
,
tsconfig.json
TypeScript/Node
go.mod
Go(REST API)
以上均无默认使用Python
2B-2. 启动脚本生成Task agent:
Task(subagent_type="general-purpose", run_in_background=False)
Task提示模板:
编写{language}脚本,通过SDK/REST API大规模调用现有的Nimble agent(s)。

**使用Nimble CLI检查agent schemas(通过Bash,而非MCP):**
```bash
nimble agent get --template-name <agent_name>
这会返回agent的完整输入/输出schema。
重要提示:使用CLI(Bash)执行所有Nimble操作。绝不要使用WebSearch、WebFetch、curl或wget。绝不要手动构造MCP端点URL。
要调用的现有agents: {agent_names} 用户意图: {user_prompt} 输出格式: {csv/json/etc} 规模: {数据/查询数量}
这是脚本生成——编写调用现有agents的代码。请勿创建新agents (不要使用nimble_agents_generate/update/publish)。上述列出的agents已存在。
步骤:
  1. 为每个agent运行
    nimble agent get --template-name <agent>
    (CLI)以检查input_properties和skills。
  2. 阅读参考文件:
    • references/sdk-patterns.md
      (Python)或
      references/rest-api-patterns.md
      (其他语言)
    • references/batch-patterns.md
      (用于多商店标准化)
  3. 编写完整的可运行脚本,包含:
    • 先进行冒烟测试——在全量批量处理前验证单个查询。失败则中止。
    • 进度报告——每个轮询周期后显示简洁的单行状态。
    • 处理大型结果集的分页。
    • 多商店字段标准化(如适用)。
    • 输出到{format}。
    • 大型管道(50+任务)的增量文件写入。
返回完整脚本和简要摘要:
  • 使用的agent schemas(输入参数、关键输出字段)
  • 标准化映射(如多商店)
  • 预估的总API调用次数
请勿使用AskUserQuestion。请勿使用nimble_find_search_agent或nimble_run_search_agent。 请勿调用nimble_agents_generate、nimble_agents_update_from_agent、nimble_agents_update_session或nimble_agents_publish。 请勿使用WebSearch、WebFetch、bash curl或任何非MCP的搜索/获取方法。

**2B-3.** 呈现生成的脚本并通过`AskUserQuestion`确认执行(前台):
question: "运行此脚本?" header: "确认" options:
  • label: "运行脚本(推荐)" description: "执行生成的脚本"
  • label: "先编辑" description: "运行前查看并修改脚本"

**此处无需agent验证步骤**。50条输入的验证流程(步骤3)仅适用于agent创建/更新。脚本生成使用已存在且已验证的agent——只需编写并运行脚本即可。

Step 3: Update existing agent or create new (on the Nimble platform)

步骤3:更新现有agent或创建新agent(在Nimble平台上)

Updates an existing agent (preferred) or creates a new one on Nimble's platform. Default to update when a close-match agent was found in Step 1 — pass the existing agent name to the Task agent so it uses
nimble_agents_update_from_agent
instead of
nimble_agents_generate
. Only create a new agent when Step 1 returned 0 matches. This is NOT code/script generation — it creates/modifies an extraction definition callable via Step 2A or 2B. ALWAYS runs as a Task agent (
run_in_background=False
).
更新现有agent(首选)或在Nimble平台上创建新agent。当步骤1中找到匹配度较高的agent时,默认选择更新——将现有agent名称传递给Task agent,使其使用
nimble_agents_update_from_agent
而非
nimble_agents_generate
。仅当步骤1返回0个匹配结果时才创建新agent。此步骤不是代码/脚本生成——它创建/修改提取定义,可通过步骤2A或2B调用。始终以Task agent运行
run_in_background=False
)。

3-1. Create a stable
session_id
(UUID v4).

3-1. 创建稳定的
session_id
(UUID v4)。

3-2. Ask the user ONCE (foreground only — agent creation/update ONLY, never for script generation):

3-2. 询问用户一次(仅前台——仅agent创建/更新,绝不用于脚本生成):

question: "Run refinement-validation before publishing?"
header: "Validate"
options:
  - label: "Yes, validate (Recommended)"
    description: "Discovery → generate → validate 50 inputs (80% pass) → publish. Auto-retries on failure."
  - label: "No, generate only"
    description: "Generate → publish immediately without validation testing"
question: "发布前运行优化验证?"
header: "验证"
options:
  - label: "是,验证(推荐)"
    description: "发现 → 生成 → 验证50条输入(通过率80%)→ 发布。失败时自动重试。"
  - label: "否,仅生成"
    description: "生成后立即发布,不进行验证测试"

3-3. Launch Task agent

3-3. 启动Task agent

Set
refine_validate
to the user's choice. Launch
Task(subagent_type="general-purpose", run_in_background=False, max_turns=50)
using the prompt template from
references/generate-update-and-publish.md
(includes MCP tool registry, lifecycle phases, and all rules). Tell the user: "Agent generation started. I'll report results when complete."
The Task agent executes a closed-loop lifecycle: Discovery → Create/Update → Poll → Validate → Publish → Report. On failure, it auto-triggers an update loop (max 2 cycles, 15-minute wall-clock timeout). See the reference file for complete details.
refine_validate
设置为用户的选择。使用**
references/generate-update-and-publish.md
**中的提示模板启动
Task(subagent_type="general-purpose", run_in_background=False, max_turns=50)
(包含MCP工具注册表、生命周期阶段和所有规则)。告知用户:"Agent生成已启动。完成后我会报告结果。"
Task agent执行闭环生命周期:发现 → 创建/更新 → 轮询 → 验证 → 发布 → 报告。失败时自动触发更新循环(最多2个周期,15分钟时钟超时)。详见参考文件。

3-4. Present report

3-4. 呈现报告

When the Task agent completes, present the report. On success, route to Step 2A or 2B. On failure after max cycles, offer:
question: "Agent validation did not reach 80% pass rate. How to proceed?"
header: "Next step"
options:
  - label: "Publish anyway"
    description: "Publish with current pass rate ({rate}%)"
  - label: "Update agent"
    description: "Provide specific instructions to refine the agent"
Task agent完成后,呈现报告。成功则路由到步骤2A或2B。达到最大周期后失败,则提供:
question: "Agent验证未达到80%通过率。如何处理?"
header: "下一步"
options:
  - label: "仍然发布"
    description: "按当前通过率({rate}%)发布"
  - label: "更新agent"
    description: "提供具体指令优化agent"

Step 4: Final response

步骤4:最终响应

End with a concise summary table:
FieldValue
Agent(s) used
agent_name
SourceExisting / Generated
Records extractedcount
OutputDisplayed /
filename.csv
Include the extraction results (or top N if large).
以简洁的摘要表格结束:
字段
使用的Agent(s)
agent_name
来源已存在 / 已生成
提取记录数数量
输出已显示 /
filename.csv
包含提取结果(如果结果较多则显示前N条)。

Additional references

附加参考文件

Load reference files only during large-scale script generation (Step 2B) or agent creation (Step 3). Do NOT load these for interactive runs (Step 2A) — MCP tool schemas are sufficient.
For script generation (Step 2B) only:
  • references/sdk-patterns.md
    — Running agents, async endpoint, batch pipelines, incremental file writes.
  • references/rest-api-patterns.md
    — REST API patterns for TypeScript, Node, curl, and other non-Python languages.
  • references/batch-patterns.md
    — Multi-store comparison, normalization, interactive batch, codegen walkthrough.
For agent creation/update (Step 3) only:
  • references/generate-update-and-publish.md
    — Full agent creation/update lifecycle: discovery, creation, polling, SDK validation (50 inputs, 80% threshold), publish, reporting, update loop.
General (any step, load as needed):
  • references/agent-api-reference.md
    — MCP tools reference plus input parameter mapping.
  • references/error-recovery.md
    — Error handling and recovery patterns.
仅在**大规模脚本生成(步骤2B)**或agent创建(步骤3)期间加载参考文件。交互式运行(步骤2A)请勿加载这些文件——MCP工具schema已足够。
仅适用于脚本生成(步骤2B):
  • references/sdk-patterns.md
    — 运行agents、异步端点、批量管道、增量文件写入。
  • references/rest-api-patterns.md
    — TypeScript、Node、curl和其他非Python语言的REST API模式。
  • references/batch-patterns.md
    — 多商店对比、标准化、交互式批量处理、代码生成演练。
仅适用于agent创建/更新(步骤3):
  • references/generate-update-and-publish.md
    — 完整的agent创建/更新生命周期:发现、创建、轮询、SDK验证(50条输入,80%阈值)、发布、报告、更新循环。
通用(任何步骤,按需加载):
  • references/agent-api-reference.md
    — MCP工具参考及输入参数映射。
  • references/error-recovery.md
    — 错误处理和恢复模式。

Guardrails

防护规则

  • Agent creation/update runs in Task agents. Generation takes 1-3 minutes — use a background Task agent for the generate → poll → publish loop. See Delegation model.
  • All operations use CLI (Bash). MCP tools are a fallback only when CLI is unavailable.
  • All web search MUST use
    nimble search
    (CLI).
    NEVER use
    WebSearch
    ,
    WebFetch
    ,
    curl
    , or
    wget
    — in foreground or Task agents.
  • Every Task agent prompt MUST include the CLI commands block (see Delegation model).
  • Never use
    nimble_find_search_agent
    ,
    nimble_run_search_agent
    , or any WSA template tools.
  • Update state machine: use
    nimble agent generate --from-agent
    to iterate on existing agents. Each iteration creates a new generation to poll.
  • Hard 429 rule. On quota errors: stop, report exhaustion. Do not retry or switch tools.
  • Published agents are automatically forked when updated. UBCT-based agents cannot be updated — generate a new one instead.
  • Never load SDK/batch references for interactive runs (Step 2A). CLI output from
    nimble agent get --template-name
    is sufficient. Load references only for Step 2B (script generation) and Step 3 (agent creation).
  • Present results in markdown tables. Never show raw JSON.
  • Agent创建/更新在Task agents中运行。生成需要1-3分钟——使用后台Task agent处理生成→轮询→发布循环。参见Delegation model
  • 所有操作使用CLI(Bash)。仅当CLI不可用时才使用MCP工具作为备选。
  • 所有网页搜索必须使用
    nimble search
    (CLI)
    。绝不要在前台或Task agents中使用
    WebSearch
    WebFetch
    curl
    wget
  • 每个Task agent提示必须包含CLI命令块(参见Delegation model)。
  • 绝不要使用
    nimble_find_search_agent
    nimble_run_search_agent
    或任何WSA模板工具。
  • 更新状态机: 使用
    nimble agent generate --from-agent
    迭代现有agents。每次迭代创建新的生成版本以供轮询。
  • 严格的429规则。遇到配额错误时:停止,报告配额耗尽。不要重试或切换工具。
  • 更新已发布的agents时会自动创建分支。基于UBCT的agents无法更新——请生成新的agent。
  • 交互式运行(步骤2A)绝不要加载SDK/批量参考文件
    nimble agent get --template-name
    的CLI输出已足够。仅在步骤2B(脚本生成)和步骤3(agent创建)期间加载参考文件。
  • 以markdown表格形式呈现结果。绝不要显示原始JSON。