sf-docs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

sf-docs: Salesforce Documentation Retrieval & Grounding

sf-docs: Salesforce文档检索与溯源

Expert Salesforce documentation researcher focused on official sources. This skill exists to make documentation lookup reliable when generic web search or naive page fetching fails on Salesforce's JavaScript-heavy docs experience.
sf-docs
is a core sf-skills capability. It should always be installed with the skill suite.
专注于官方来源的专业Salesforce文档检索工具。当通用网页搜索或简单页面抓取在Salesforce基于JavaScript的文档系统中失效时,本技能可确保文档查找的可靠性。
sf-docs
sf-skills套件的核心能力。它应始终与技能套件一同安装。

Core Responsibilities

核心职责

  1. Official Docs Retrieval: Find authoritative answers from Salesforce documentation first
  2. Local-First Search: Use a local qmd index when available for speed and accuracy
  3. Salesforce-Aware Fallback: When qmd is unavailable or weak, use Salesforce-specific retrieval patterns instead of generic web fetch
  4. Source Grounding: Return answers with exact source URLs, guide names, and retrieval notes
  5. Cross-Skill Support: Serve as the documentation lookup layer for other
    sf-*
    skills

  1. 官方文档检索:优先从Salesforce文档中查找权威答案
  2. 本地优先搜索:若有可用的本地qmd索引,使用它以提升速度和准确性
  3. Salesforce专属回退方案:当qmd不可用或效果不佳时,采用Salesforce专属的检索模式而非通用网页抓取
  4. 来源溯源:返回包含精确来源URL、指南名称和检索说明的答案
  5. 跨技能支持:作为其他
    sf-*
    技能的文档查找层

Runtime Modes

运行模式

Mode A: qmd-Enabled

模式A:启用qmd

Use this mode when qmd is installed and a local Salesforce docs corpus exists.
Preferred flow:
  1. Detect qmd availability
  2. Query qmd first
  3. Evaluate result quality
  4. If results are strong, answer from local docs
  5. If results are weak or missing, fall back to Salesforce-aware scraping
当qmd已安装且存在本地Salesforce文档语料库时使用此模式。
优先流程:
  1. 检测qmd可用性
  2. 首先查询qmd
  3. 评估结果质量
  4. 若结果优质,从本地文档返回答案
  5. 若结果不佳或缺失,回退到Salesforce专属爬取

Mode B: No-qmd

模式B:未启用qmd

Use this mode when qmd is not installed or no local corpus exists.
Preferred flow:
  1. Identify the most likely Salesforce doc family
  2. Use Salesforce-aware discovery and retrieval patterns
  3. Prefer official URLs over summaries from third-party blogs
  4. Fall back to official PDFs when web pages are unstable or shell-rendered
  5. Return grounded findings with source links and any uncertainty called out
Claude Code operator shortcut: When the local
sf-docs
helper scripts are installed, prefer the built-in retrieval command over ad-hoc search-engine probing:
bash
python3 ~/.claude/skills/sf-docs/scripts/cli.py retrieve \
  --query "<user question>" \
  --mode no_qmd
For hard
help.salesforce.com
questions, this command applies the local no-qmd retrieval flow, including targeted Help article discovery and browser-based rendering.
当qmd未安装或无本地语料库时使用此模式。
优先流程:
  1. 识别最可能的Salesforce文档系列
  2. 使用Salesforce专属的发现和检索模式
  3. 优先选择官方URL而非第三方博客的摘要
  4. 当网页不稳定或仅渲染框架时,回退到官方PDF
  5. 返回带有来源链接的溯源结果,并标注任何不确定性
Claude Code操作员快捷方式: 当本地
sf-docs
辅助脚本已安装时,优先使用内置检索命令而非临时搜索引擎探测:
bash
python3 ~/.claude/skills/sf-docs/scripts/cli.py retrieve \
  --query "<用户问题>" \
  --mode no_qmd
对于复杂的
help.salesforce.com
问题,此命令会应用本地无qmd检索流程,包括定向Help文章发现和基于浏览器的渲染。

Runtime Detection

运行时检测

sf-docs
should detect qmd at runtime, not just rely on installer choices.
Use this detection order:
  1. Check whether the
    qmd
    CLI is available on
    PATH
  2. Check whether a local Salesforce docs corpus exists
  3. If qmd exists but the local corpus/index is missing or effectively empty, treat the request as no-qmd mode
  4. If qmd exists and the corpus is populated, use qmd-enabled mode
Reference: references/local-corpus-layout.md

sf-docs
应在运行时检测qmd,而非仅依赖安装选项。
检测顺序:
  1. 检查
    PATH
    中是否有
    qmd
    CLI可用
  2. 检查是否存在本地Salesforce文档语料库
  3. 若qmd存在但本地语料库/索引缺失或为空,按无qmd模式处理请求
  4. 若qmd存在且语料库已填充,使用启用qmd模式
参考:references/local-corpus-layout.md

Fallback Triggers

回退触发条件

Treat qmd results as weak and fall back when any of the following happen:
  • No results returned
  • Results are clearly from the wrong Salesforce product or guide family
  • Results lack the exact concept, API name, CLI command, or error term requested
  • Results are too fragmentary to answer confidently
  • Results appear stale and the query is obviously release-sensitive
Rule: Prefer a reliable Salesforce-specific fallback over confidently answering from a poor local hit.

当出现以下任一情况时,将qmd结果视为质量不佳并触发回退:
  • 无结果返回
  • 结果明显来自错误的Salesforce产品或指南系列
  • 结果缺少请求的精确概念、API名称、CLI命令或错误术语
  • 结果过于碎片化,无法自信地回答
  • 结果看起来过时,且查询明显与新版本相关
规则:优先选择可靠的Salesforce专属回退方案,而非基于质量不佳的本地结果勉强回答。

Salesforce Documentation Retrieval Playbook

Salesforce文档检索手册

1. Identify the Doc Family First

1. 先识别文档系列

Classify the request before searching:
FamilyTypical SourcesUse For
Developer Docs
developer.salesforce.com/docs/...
Apex, APIs, LWC, metadata, Agentforce developer docs
Salesforce Help
help.salesforce.com/...
Setup UI steps, admin guides, feature configuration
Platform Guides
developer.salesforce.com/docs/platform/...
Newer guide-style docs with cleaner URLs
Atlas / Legacy Guides
developer.salesforce.com/docs/atlas.en-us.*
Older but still official guide and reference material
Official PDFs
resources.docs.salesforce.com/...pdf/...
Large guide bundles, stable offline extraction
搜索前先对请求进行分类:
系列典型来源适用场景
开发者文档
developer.salesforce.com/docs/...
Apex、API、LWC、元数据、Agentforce开发者文档
Salesforce帮助文档
help.salesforce.com/...
配置UI步骤、管理员指南、功能配置
平台指南
developer.salesforce.com/docs/platform/...
较新的指南风格文档,URL更简洁
Atlas / 旧版指南
developer.salesforce.com/docs/atlas.en-us.*
旧版但仍为官方的指南和参考资料
官方PDF
resources.docs.salesforce.com/...pdf/...
大型指南包,稳定的离线提取

2. Prefer Exact Guide Paths Over Homepage Search

2. 优先选择精确指南路径而非首页搜索

Avoid stopping at broad pages like the docs homepage unless you are discovering guide roots.
Instead, resolve toward:
  • A specific guide root
  • A specific article or page
  • A guide PDF when page-level retrieval is unstable
除非是在发现指南根目录,否则避免停留在文档首页等宽泛页面。
相反,应定位到:
  • 特定指南根目录
  • 特定文章或页面
  • 当页面级检索不稳定时,选择指南PDF

3. Retrieval Patterns for
developer.salesforce.com

3.
developer.salesforce.com
的检索模式

Use these patterns deliberately:
  • Modern platform guide:
    developer.salesforce.com/docs/platform/...
  • Legacy Atlas guide:
    developer.salesforce.com/docs/atlas.en-us.<book>.meta/...
  • Guide PDF candidate: derive
    <book>
    and try the matching official PDF URL
When an HTML page fails because of JavaScript rendering, shell content, or soft errors, try:
  1. the guide root
  2. the legacy Atlas variant if known
  3. the official PDF
有意使用以下模式:
  • 现代平台指南
    developer.salesforce.com/docs/platform/...
  • 旧版Atlas指南
    developer.salesforce.com/docs/atlas.en-us.<book>.meta/...
  • 指南PDF候选:推导
    <book>
    并尝试匹配的官方PDF URL
当HTML页面因JavaScript渲染、框架内容或软错误而失效时,尝试:
  1. 指南根目录
  2. 已知的旧版Atlas变体
  3. 官方PDF

4. Retrieval Patterns for
help.salesforce.com

4.
help.salesforce.com
的检索模式

Help pages often fail with generic web fetch because of client-side rendering and site chrome.
Use this approach:
  • Prefer exact
    help.salesforce.com/s/articleView?id=...
    URLs or article identifiers when available
  • If you only have a product/topic query, start from a targeted official hub and discover linked Help articles from there
    • Agentforce queries: start from the Agentforce developer guide and follow linked Help articles
    • Messaging / Enhanced Web Chat queries: start from the Enhanced Web Chat docs or landing Help article, then follow one hop to child setup/security articles
  • Expect navigation shell noise and incomplete body extraction
  • Focus on retrieving the actual article body, not the rendered header/footer shell
  • Reject shell or soft-404 pages such as "We looked high and low but couldn't find that page"
  • Cross-check titles, product area, and article body before trusting a result
由于客户端渲染和站点框架,通用网页抓取通常无法获取Help页面内容。
采用以下方法:
  • 优先使用精确的
    help.salesforce.com/s/articleView?id=...
    URL或文章标识符(如果有)
  • 若仅能获取产品/主题查询,从定向官方中心开始,从那里发现关联的Help文章
    • Agentforce查询:从Agentforce开发者指南开始,跟随关联的Help文章
    • 消息/增强网页聊天查询:从增强网页聊天文档或落地Help文章开始,然后跳转到子级配置/安全文章
  • 预期会有导航框架干扰和不完整的正文提取
  • 专注于检索实际文章正文,而非渲染的页眉/页脚框架
  • 拒绝框架页面或软404页面,如“我们四处查找但未找到该页面”
  • 在信任结果前,交叉检查标题、产品领域和文章正文

5. PDFs Are a Valid Official Fallback

5. PDF是有效的官方回退方案

Use PDFs when:
  • The guide has a stable official PDF
  • HTML extraction is inconsistent
  • A long-form developer guide is easier to search locally after normalization
PDFs may be stored locally and indexed later, but should not be committed into the public repo.

在以下情况使用PDF:
  • 指南有稳定的官方PDF版本
  • HTML提取不一致
  • 标准化后,长格式开发者指南更便于本地搜索
PDF可本地存储并稍后索引,但不应提交到公共仓库。

Answer Requirements

答案要求

When using
sf-docs
, answers should include:
  1. Source type — qmd local hit, official HTML page, or official PDF
  2. Guide/article name
  3. Exact official URL
  4. Any retrieval caveat — for example, if fallback scraping was needed or if the content appeared partially rendered
If the evidence is weak, say so plainly.

使用
sf-docs
时,答案应包含:
  1. 来源类型 — qmd本地命中、官方HTML页面或官方PDF
  2. 指南/文章名称
  3. 精确官方URL
  4. 任何检索注意事项 — 例如,是否需要回退爬取,或内容是否部分渲染
若证据不足,应明确说明。

Cross-Skill Integration

跨技能集成

SkillHow
sf-docs
Helps
sf-ai-agentforce
Find Agentforce, PromptTemplate, Models API, and setup docs
sf-ai-agentscript
Find Agent Script syntax, CLI, and reasoning engine docs
sf-apex
Find Apex language and reference docs
sf-lwc
Find LWC guides, component references, and wire docs
sf-integration
Find REST, SOAP, Named Credential, and auth docs
sf-deploy
Find CLI, deployment, packaging, and metadata references
Delegation rule: If another skill needs authoritative Salesforce documentation, it should use
sf-docs
as the retrieval layer rather than improvising generic web search.

技能
sf-docs
的作用
sf-ai-agentforce
查找Agentforce、PromptTemplate、Models API和配置文档
sf-ai-agentscript
查找Agent Script语法、CLI和推理引擎文档
sf-apex
查找Apex语言和参考文档
sf-lwc
查找LWC指南、组件参考和wire文档
sf-integration
查找REST、SOAP、命名凭据和认证文档
sf-deploy
查找CLI、部署、打包和元数据参考
委托规则:若其他技能需要权威Salesforce文档,应使用
sf-docs
作为检索层,而非自行采用通用网页搜索。

Local Storage Policy

本地存储策略

  • sf-docs
    is part of the core skill suite
  • qmd remains an optional external dependency
  • Downloaded PDFs, scraped markdown, manifests, and indexes should live on the user's machine
  • Official Salesforce docs content should not be stored in this public Git repository
  • sf-docs
    是核心技能套件的一部分
  • qmd仍是可选外部依赖
  • 下载的PDF、爬取的markdown、清单和索引应存储在用户机器
  • 官方Salesforce文档内容不应存储在此公共Git仓库中

Default Local Corpus Layout

默认本地语料库布局

Use a stable local root such as:
text
~/.sf-docs/
Recommended structure:
  • ~/.sf-docs/manifest/
    — discovery manifests and fetch/index status
  • ~/.sf-docs/raw/pdf/
    — downloaded official PDFs
  • ~/.sf-docs/raw/html/
    — optional raw HTML captures
  • ~/.sf-docs/normalized/md/
    — canonical markdown corpus for qmd indexing
  • ~/.sf-docs/qmd/
    — qmd-specific config notes
  • ~/.sf-docs/logs/
    — optional diagnostics and fetch logs
Full reference: references/local-corpus-layout.md

使用稳定的本地根目录,例如:
text
~/.sf-docs/
推荐结构:
  • ~/.sf-docs/manifest/
    — 发现清单和抓取/索引状态
  • ~/.sf-docs/raw/pdf/
    — 下载的官方PDF
  • ~/.sf-docs/raw/html/
    — 可选的原始HTML捕获
  • ~/.sf-docs/normalized/md/
    — 用于qmd索引的标准markdown语料库
  • ~/.sf-docs/qmd/
    — qmd专属配置说明
  • ~/.sf-docs/logs/
    — 可选的诊断和抓取日志
完整参考:references/local-corpus-layout.md

First-Version Behavior

初始版本行为

The initial implementation should optimize for correctness and operational simplicity:
  1. qmd-first when available
  2. Sequential fallback to Salesforce-aware scraping
  3. Targeted retrieval, not broad crawling, during normal lookups
  4. Grounded responses with official source links
初始实现应优先保证正确性和操作简洁性:
  1. 可用时优先使用qmd
  2. 顺序回退到Salesforce专属爬取
  3. 正常查找时采用定向检索,而非广泛爬取
  4. 返回带有官方来源链接的溯源结果

Query-Time Runtime Flow

查询时运行流程

  1. Detect qmd and local corpus availability
  2. Run qmd lookup if available
  3. Evaluate hit quality
  4. On weak/missing results, use Salesforce-specific HTML/PDF fallback
  5. Answer with source grounding and retrieval caveats when needed
Full runtime guide: references/runtime-workflow.md
Parallel qmd + scraping can be considered later if benchmarks justify the added complexity.

  1. 检测qmd和本地语料库可用性
  2. 若可用,运行qmd查询
  3. 评估命中质量
  4. 若结果不佳/缺失,使用Salesforce专属HTML/PDF回退方案
  5. 必要时,返回带有来源溯源和检索注意事项的答案
完整运行指南:references/runtime-workflow.md
如果基准测试证明有必要,后续可考虑qmd+爬取并行执行。

Success Criteria

成功标准

sf-docs
is successful when it does the following better than generic web search:
  • Finds the right Salesforce page or PDF more often
  • Avoids failed fetches on
    help.salesforce.com
  • Reduces hallucinations by grounding on official sources
  • Improves the documentation quality available to the rest of the
    sf-*
    skills

sf-docs
在以下方面优于通用网页搜索时,即视为成功:
  • 更频繁地找到正确的Salesforce页面或PDF
  • 避免在
    help.salesforce.com
    上的抓取失败
  • 通过基于官方来源的溯源减少幻觉
  • 提升其他
    sf-*
    技能可获取的文档质量

References

参考资料

DocumentPurpose
references/local-corpus-layout.mdLocal-only corpus structure and runtime detection rules
references/discovery-manifest.mdGuide discovery manifest schema, mixed doc family handling, HTML vs PDF policy
references/qmd-integration.mdqmd collection, context, and retrieval strategy
references/runtime-workflow.mdQuery-time flow, fallback rules, sync/index separation, and local persistence policy
references/ingestion-workflow.mdTargeted HTML/PDF fetch, normalization, and qmd bootstrap workflow
references/salesforce-scraper-techniques.mdSalesforce-aware browser extraction techniques, Shadow DOM handling, and PDF fallback rationale
references/pilot-scope.mdInitial guide scope for v1 ingestion
references/benchmark-protocol.mdqmd-first and no-qmd validation protocol
references/cli-workflow.mdUnified CLI workflow for discover, sync, bootstrap, diagnose, and benchmark scoring
references/implementation-order.mdRecommended v1 execution order
references/final-architecture.mdFinal architectural recommendation
文档用途
references/local-corpus-layout.md本地语料库结构和运行时检测规则
references/discovery-manifest.md指南发现清单 schema、混合文档系列处理、HTML与PDF策略
references/qmd-integration.mdqmd收集、上下文和检索策略
references/runtime-workflow.md查询时流程、回退规则、同步/索引分离和本地持久化策略
references/ingestion-workflow.md定向HTML/PDF抓取、标准化和qmd引导流程
references/salesforce-scraper-techniques.mdSalesforce专属浏览器提取技术、Shadow DOM处理和PDF回退理由
references/pilot-scope.mdv1版本语料库的初始指南范围
references/benchmark-protocol.md优先qmd和无qmd模式的验证协议
references/cli-workflow.md用于发现、同步、引导、诊断和基准评分的统一CLI流程
references/implementation-order.md推荐的v1版本执行顺序
references/final-architecture.md最终架构建议

Assets & Scripts

资产与脚本

FilePurpose
assets/discovery-manifest.seed.jsonStarter guide manifest seed
assets/retrieval-benchmark.jsonExpanded core retrieval benchmark cases for exact identifiers, guide routing, and evidence grounding
assets/retrieval-benchmark.results-template.jsonTemplate for recording qmd-first and no-qmd core benchmark outcomes
assets/retrieval-benchmark.robustness.jsonNegative / wrong-guide rejection benchmark for hardening fallback behavior
assets/retrieval-benchmark.robustness.results-template.jsonTemplate for recording robustness benchmark outcomes
scripts/cli.pyUnified sf-docs CLI for discover, sync, bootstrap-qmd, status, diagnose, retrieve, and benchmarking
scripts/discover_salesforce_docs.pyEnrich guide seeds into a discovery manifest and optionally verify PDF candidates
scripts/salesforce_dom_scraper.mjsSalesforce-aware browser scraper with Shadow DOM, legacy doc container, iframe, and help-page heuristics
scripts/sync_sf_docs.pyFetch targeted HTML/PDF sources into the local corpus and normalize them into markdown
scripts/bootstrap_qmd.pyConfigure a single qmd collection over the normalized sf-docs corpus
scripts/sf_docs_runtime.pyDetect qmd/corpus readiness, build sequential lookup plans, and evaluate qmd result strength
scripts/retrieve_sf_docs.pyEnd-to-end qmd-first or no-qmd retrieval execution with Salesforce-aware fallback
scripts/run_retrieval_benchmark.pyExecute the benchmark cases through qmd-first and no-qmd retrieval modes
scripts/score_retrieval_benchmark.pyScore benchmark results for qmd-first and no-qmd modes

文件用途
assets/discovery-manifest.seed.json初始指南清单种子
assets/retrieval-benchmark.json扩展的核心检索基准案例,涵盖精确标识符、指南路由和证据溯源
assets/retrieval-benchmark.results-template.json记录优先qmd和无qmd模式核心基准结果的模板
assets/retrieval-benchmark.robustness.json用于强化回退行为的负面/错误指南拒绝基准
assets/retrieval-benchmark.robustness.results-template.json记录鲁棒性基准结果的模板
scripts/cli.py统一的sf-docs CLI,用于发现、同步、qmd引导、状态查看、诊断、检索和基准测试
scripts/discover_salesforce_docs.py将指南种子扩展为发现清单,并可选验证PDF候选
scripts/salesforce_dom_scraper.mjs带有Shadow DOM、旧版文档容器、iframe和帮助页面启发式的Salesforce专属浏览器爬取工具
scripts/sync_sf_docs.py将定向HTML/PDF源抓取到本地语料库,并将其标准化为markdown
scripts/bootstrap_qmd.py配置基于标准化sf-docs语料库的单个qmd集合
scripts/sf_docs_runtime.py检测qmd/语料库就绪状态,构建顺序查找计划,并评估qmd结果质量
scripts/retrieve_sf_docs.py端到端的优先qmd或无qmd检索执行,带有Salesforce专属回退
scripts/run_retrieval_benchmark.py通过优先qmd和无qmd检索模式执行基准案例
scripts/score_retrieval_benchmark.py为优先qmd和无qmd模式的基准结果评分

License

许可证

MIT License. See LICENSE file in the repo root. Copyright (c) 2024–2026 Jag Valaiyapathy
MIT许可证。请查看仓库根目录的LICENSE文件。 版权所有 (c) 2024–2026 Jag Valaiyapathy