setup-context
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesesetup-context
上下文初始化(setup-context)
Take the user from to a synced project with a starter .
pip install nao-coreRULES.mdBe brief. One batch of questions, then act. Don't ping-pong.
Scope ceiling: ≤100 tables. Above that, sync gets slow and per-table context budget gets thin. 20 is a great target.
引导用户完成从到项目同步并生成初始的全流程。
pip install nao-coreRULES.md简洁高效:一次性提出所有问题,然后执行操作,避免来回沟通。
范围上限:≤100张表:超过这个数量,同步速度会变慢,且单表上下文预算会不足。建议目标为20张表。
Step 1 — Ask everything in one round
步骤1 — 一次性收集所有信息
Send a single message asking for:
- Warehouse + auth — type (BigQuery / Snowflake / Postgres / Redshift / DuckDB / Databricks / Athena / ClickHouse / Fabric / MSSQL / MySQL / Trino), and the auth credentials they have on hand. Tell them you'll fetch the exact field names from the nao docs once they pick a type.
- Scope — which tables. Two valid shapes:
- Broad — gold/marts across multiple domains (exec / cross-functional agents).
- Deep — silver + gold for one domain (team-specific agents).
- Extra context — dbt / ETL / BI repos, Notion, internal docs. Ask for the SSH git URL of each repo (e.g. ) — sync clones them. No local paths.
git@github.com:org/repo.git - LLM — provider + model. Key comes later (Step 5).
发送一条消息,询问以下内容:
- 数据仓库及认证信息:仓库类型(BigQuery / Snowflake / Postgres / Redshift / DuckDB / Databricks / Athena / ClickHouse / Fabric / MSSQL / MySQL / Trino),以及用户手头的认证凭据。告知用户一旦选定类型,你将从nao文档中获取具体的字段名称。
- 范围:需要同步的表。有两种有效范围类型:
- 广度覆盖:跨多个领域的gold/marts层表(供高管/跨职能agent使用)。
- 深度聚焦:单个领域的silver+gold层表(供特定团队agent使用)。
- 额外上下文:dbt / ETL / BI代码仓库、Notion文档、内部文档。要求提供每个仓库的SSH git地址(例如)——同步时会克隆这些仓库。不接受本地路径。
git@github.com:org/repo.git - LLM:提供商及模型。密钥将在后续步骤(步骤5)中配置。
Step 2 — Look up warehouse fields, write nao_config.yaml
, run nao init
nao_config.yamlnao init步骤2 — 查询仓库字段,编写nao_config.yaml
,执行nao init
nao_config.yamlnao init-
Fetch the warehouse-specific config from docs.getnao.io/nao-agent/context-builder/databases. Each warehouse has its own required and optional fields (e.g. BigQuery needs+
project_id(optional); Snowflake needsdataset_id+account_id+warehouse(optional); Postgres needsschema_name+host+port+database(optional). Ask the user for any required field you don't already have.schema_name -
Writefrom the answers (skeleton in appendix below).
nao_config.yaml -
Run— it detects the existing yaml and offers to update; confirm. Folder scaffold gets created. Say "no" to optional providers (skills / MCPs / Notion / Slack); edit the yaml directly afterwards if needed.
nao init -
Print a summary ofto the user before going further. Format example:
nao_config.yamlnao_config.yaml summary • project: <name> • warehouse: BigQuery (project=<id>, dataset=<id>, auth=service-account) • scope: include=["analytics.fct_*", "analytics.dim_*"], exclude=[] • templates: [columns, preview, description] • repos: company-dbt (git@github.com:org/company-dbt.git) • llm: anthropic / claude-sonnet-4-7 (key via ${ANTHROPIC_API_KEY})Ask the user to confirm before continuing. This is the last cheap chance to catch a wrong project, a misspelled dataset, or a missing repo.
-
获取仓库专属配置:从docs.getnao.io/nao-agent/context-builder/databases获取。每个仓库都有自己的必填和可选字段(例如BigQuery需要+
project_id(可选);Snowflake需要dataset_id+account_id+warehouse(可选);Postgres需要schema_name+host+port+database(可选))。向用户索要任何你尚未获取的必填字段。schema_name -
编写:根据用户提供的信息编写(参考下方附录中的模板)。
nao_config.yaml -
执行:该命令会检测已存在的yaml文件并提供更新选项;确认更新。系统会创建文件夹结构。对可选提供商(skills / MCPs / Notion / Slack)选择“否”;如有需要,后续可直接编辑yaml文件。
nao init -
向用户展示的摘要,然后再继续操作。格式示例:
nao_config.yamlnao_config.yaml summary • project: <name> • warehouse: BigQuery (project=<id>, dataset=<id>, auth=service-account) • scope: include=["analytics.fct_*", "analytics.dim_*"], exclude=[] • templates: [columns, preview, description] • repos: company-dbt (git@github.com:org/company-dbt.git) • llm: anthropic / claude-sonnet-4-7 (key via ${ANTHROPIC_API_KEY})请用户确认后再继续。这是最后一个可以低成本发现项目错误、数据集拼写错误或仓库缺失的机会。
Database templates
field
templates数据库templates
字段
templatesPer database in the yaml, set:
yaml
templates: [columns, preview, description]That's the set this skill ships. Other values are valid per-warehouse (, , , and for ClickHouse) — see the docs link above — but stick to unless the user specifically asks otherwise.
how_to_useprofilingai_summaryindexes[columns, preview, description]Don't use — deprecated (renamed to ).
accessorstemplatesnao initnao_config.yamlRULES.md.naoignoredatabases/repos/docs/semantics/queries/tests/agent/{tools,mcps,skills}/针对yaml中的每个数据库,设置:
yaml
templates: [columns, preview, description]这是本技能默认的配置集合。根据仓库类型还可以使用其他有效值(例如ClickHouse支持、、和)——可查看上方的文档链接——但除非用户特别要求,否则请坚持使用。
how_to_useprofilingai_summaryindexes[columns, preview, description]请勿使用——已废弃(已更名为)。
accessorstemplatesnao initnao_config.yamlRULES.md.naoignoredatabases/repos/docs/semantics/queries/tests/agent/{tools,mcps,skills}/Step 3 — nao sync
nao sync步骤3 — 执行nao sync
nao syncAfter the user confirms the summary in Step 2:
bash
cd <project> # where nao_config.yaml lives — every nao command runs from here
nao syncCommon failures: auth (fix yaml), tables not found (check schema casing), permission denied (grant read access), repo missing (fix block, confirm SSH key). Don't move on until sync is clean.
repos:用户确认步骤2中的摘要后:
bash
cd <project> # 进入nao_config.yaml所在的目录——所有nao命令都需在此目录下执行
nao sync常见失败原因:认证错误(修改yaml文件)、表未找到(检查 schema 大小写)、权限不足(授予读取权限)、仓库缺失(修复块,确认SSH密钥)。必须确保同步成功后再继续。
repos:Step 4 — Generate RULES.md
(no confirmation)
RULES.md步骤4 — 生成RULES.md
(无需确认)
RULES.mdHand off directly to . Don't ask.
write-context-rules直接调用功能,无需询问用户。
write-context-rulesStep 5 — Wire up the LLM key
步骤5 — 配置LLM密钥
The key lives in . Two safe options:
nao_config.yaml- Preferred: env-var ref. Write ; tell the user to export the key in their shell.
api_key: ${ANTHROPIC_API_KEY} - If they insist on a literal: tell them to edit the yaml themselves and add it to . Never ask them to paste a key into chat.
.gitignore
Then to confirm.
nao debug密钥存储在中。有两种安全配置方式:
nao_config.yaml- 推荐方式:环境变量引用。写入;告知用户在终端中导出该密钥。
api_key: ${ANTHROPIC_API_KEY} - 若用户坚持明文存储:告知用户自行编辑yaml文件并将其添加到中。绝对不要让用户在聊天框中粘贴密钥。
.gitignore
然后执行确认配置生效。
nao debugKnown issue — AI_APICallError: Not Found
AI_APICallError: Not Found已知问题 — AI_APICallError: Not Found
AI_APICallError: Not FoundIf / / fails with that error and the URL is (no ), the parent agentic CLI (Claude Code, Cursor, Codex) is leaking into the child env. Fix:
nao chatnao debugnao testhttps://api.anthropic.com/messages/v1/ANTHROPIC_BASE_URLbash
unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY
nao chat # or debug / testRegular human terminals aren't affected.
如果 / / 执行失败并返回该错误,且请求URL为(缺少),则是父代理CLI(Claude Code、Cursor、Codex)将泄露到了子环境中。修复方法:
nao chatnao debugnao testhttps://api.anthropic.com/messages/v1/ANTHROPIC_BASE_URLbash
unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY
nao chat # 或debug / test普通终端不会出现此问题。
Step 6 — Recommend next steps
步骤6 — 推荐后续操作
- Smoke test: , ask 3-5 real questions.
nao chat - Review for wrong inferences.
RULES.md - Pick a next skill: (refine),
write-context-rules(benchmark),create-context-tests(anytime),audit-context(only after tests reveal metric-reliability gaps).add-semantic-layer
- 冒烟测试:执行,提出3-5个实际问题。
nao chat - 审查,修正错误推断。
RULES.md - 选择后续技能:(优化规则)、
write-context-rules(基准测试)、create-context-tests(随时可用)、audit-context(仅在测试发现指标可靠性问题后使用)。add-semantic-layer
Guardrails
约束规则
- into the project directory before any
cdcommand.nao - Cap at ~100 tables.
- One batch of questions. Look up warehouse-specific fields from the docs, don't keep pinging the user.
- Run non-interactively with the yaml pre-written.
nao init - Use . Don't use
templates: [columns, preview, description].accessors - Repos: SSH git URLs only. No local paths in the block.
repos: - Print the summary and get user confirmation before
nao_config.yaml.nao sync - Never have the user paste their LLM key into chat.
- Don't ask before invoking — just hand off.
write-context-rules
- 执行任何nao命令前,请先到项目目录。
cd - 表数量上限约为100张。
- 一次性提出所有问题。从文档中查询仓库专属字段,不要反复询问用户。
- 使用预编写的yaml文件非交互式执行。
nao init - 使用。请勿使用
templates: [columns, preview, description]。accessors - 仓库仅支持SSH git地址。块中不允许使用本地路径。
repos: - 打印摘要,并在执行
nao_config.yaml前获得用户确认。nao sync - 绝对不要让用户在聊天框中粘贴LLM密钥。
- 调用前无需询问——直接跳转执行。
write-context-rules
Appendix — nao_config.yaml
skeleton (BigQuery example)
nao_config.yaml附录 — nao_config.yaml
模板(BigQuery示例)
nao_config.yamlUse this shape and adapt the block per warehouse — see docs.getnao.io/nao-agent/context-builder/databases for the exact required/optional fields for Snowflake, Postgres, Redshift, Databricks, Athena, ClickHouse, Fabric, MSSQL, MySQL, Trino.
databases:yaml
project_name: <project>
databases:
- type: bigquery
name: <connection-name>
project_id: <gcp-project-id>
dataset_id: <dataset>
credentials_path: /path/to/service-account.json # or `sso: true`
include: ['<dataset_pattern>.<table_pattern>'] # e.g. "analytics.fct_*" - use '*' as multiple patterns
exclude: ['<pattern>']
templates: [columns, preview, description]
llm:
provider: anthropic # openai | bedrock | azure | gemini | mistral | ollama
api_key: ${ANTHROPIC_API_KEY}
repos:
- name: <repo-name>
url: git@github.com:<org>/<repo>.git # SSH only使用此模板,并根据仓库类型调整块——请查看docs.getnao.io/nao-agent/context-builder/databases获取Snowflake、Postgres、Redshift、Databricks、Athena、ClickHouse、Fabric、MSSQL、MySQL、Trino的确切必填/可选字段。
databases:yaml
project_name: <project>
databases:
- type: bigquery
name: <connection-name>
project_id: <gcp-project-id>
dataset_id: <dataset>
credentials_path: /path/to/service-account.json # 或`sso: true`
include: ['<dataset_pattern>.<table_pattern>'] # 例如 "analytics.fct_*" - 使用'*'匹配多个模式
exclude: ['<pattern>']
templates: [columns, preview, description]
llm:
provider: anthropic # openai | bedrock | azure | gemini | mistral | ollama
api_key: ${ANTHROPIC_API_KEY}
repos:
- name: <repo-name>
url: git@github.com:<org>/<repo>.git # 仅支持SSH