Community研究与数据分析github.com

forcedotcom/querying-soql

用于 SOQL 查询的生成、优化和分析,支持 100 分评分系统。当用户需要进行 SOQL/SOSL 编写或优化时使用此技能:自然语言到查询的生成、关联查询、聚合、查询计划分析以及 Salesforce 查询的性能或安全性改进。

querying-soql 是什么?

该技能专为 Salesforce 开发者及 AI 代理设计,提供全面的 SOQL/SOSL 查询生成、优化与分析能力,并配备 100 分制评分系统。其主要功能包括:将自然语言描述自动转换为 SOQL 或 SOSL 查询、支持关联查询(如父项到子项、子项到父项)与聚合函数(COUNT、SUM、AVG 等)、进行查询计划分析(Query Plan)以识别性能瓶颈,并提供语法修正、索引使用建议等优化方案。该技能支持 `us-soql` 平台(Claude Desktop 与 Code),用户可通过 `.soql` 文件、自然语言描述或直接粘贴查询来触发。技能内部会调用诸如 `soql:queryPlan` 和 `soql:scoreQuery` 等工具进行语法验证、评分与优化。其主要工作流程包括:解析用户请求、生成或优化查询、执行评分与安全校验、格式化输出以及提供性能优化建议。适用场景包括调试慢查询、优化现有查询、构建复杂聚合查询,以及通过自然语言快速生成查询。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/forcedotcom/sf-skills/tree/main/skills/querying-soql

Installed? Explore more 研究与数据分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

querying-soql 是做什么的?

SOQL 查询生成、优化和分析,配备 100 分制评分系统。当用户需要进行 SOQL/SOSL 编写或优化时使用此技能:自然语言到查询的生成、关联查询、聚合、查询计划分析以及 Salesforce 查询的性能或安全性改进。

触发条件: 用户编写、优化或调试 SOQL/SOSL 查询、处理 .soql 文件、或询问关联查询、聚合或查询性能时。

不触发条件: 批量数据操作(请使用 handling-sf-data)、Apex DML 逻辑(请使用 generating-apex)、或报告/仪表板查询。

能力

  • 自然语言到 SOQL/SOSL 的生成 - 将日常语言描述转换为正确的查询。
  • 关联查询 - 父项到子项 (__r) 与子项到父项的子查询。
  • 聚合与分组 - GROUP BY、HAVING、聚合字段 (COUNT、SUM、AVG、MIN、MAX)。
  • 查询计划分析 - 使用 soql:queryPlan 识别性能瓶颈。
  • 评分与优化 - 在 100 分量表上对查询进行评分,并应用最佳实践优化。
  • 语法检查 - 检测错误,如字段 / 对象名称错误或无效的空值处理。
  • FORMAT() 与安全设置 - 确保使用 FORMAT() 以实现本地化,并符合 FLS/CRUD 检查。

工作流

  1. 解析用户请求 - 识别输入的 .soql 文件、自然语言描述或内联查询。
  2. 生成 / 优化查询 - 使用 AI 与 Salesforce SOQL 模式构建正确语法。
  3. 评分与校验 - 调用 soql:scoreQuery 获取 100 分制评分与改进建议。
  4. 查询计划审查 - 可选地使用 soql:queryPlan 分析性能。
  5. 输出结果 - 返回格式化查询、评分详情及优化建议。

使用示例

示例 1:自然语言到查询

用户:"查找过去 30 天创建、未结金额超过 1000 美元的商机,包含账户名称。" 技能:生成 SELECT Id, Name, Amount, Account.Name FROM Opportunity WHERE CreatedDate = LAST_N_DAYS:30 AND Amount > 1000 AND IsClosed = false

示例 2:优化现有查询

用户:粘贴 SOQL 并说"优化此查询" 技能:检查冗余过滤条件、缺失索引、FORMAT() 用法,并对查询进行评分。

示例 3:查询计划分析

用户:"解释此查询的计划" 技能:运行 soql:queryPlan 并解释索引使用与表扫描。

支持平台

  • us-soql(Claude Desktop、Claude Code)

注意:此技能依赖于 Salesforce SOQL 模式知识、查询计划 API 和评分引擎。始终使用 SOQL 参考进行验证。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

forcedotcom/building-sf-integrations

Salesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), data import/export (use handling-sf-data), or CDC channel-membership metadata such as PlatformEventChannel, PlatformEventChannelMember, or EnrichedField (use managing-cdc-enablement).

forcedotcom/building-ui-bundle-app

MUST activate when the user wants to build, create, or generate a React application, React app, web application, single-page application (SPA), or frontend application — even if no project files exist yet. MUST also activate when the project contains a uiBundles/*/src/ directory or sfdx-project.json and the prompt says create, build, construct, or generate a new app, site, or page from scratch — even if the prompt also describes visual styling. MUST also activate when the task spans more than one ui-bundle skill. Use this skill when building a complete app end-to-end. Do NOT use for Lightning Experience apps with custom objects (use generating-lightning-app). Do NOT use for single-concern edits to an existing page (use building-ui-bundle-frontend).

forcedotcom/building-ui-bundle-frontend

MUST activate before editing ANY file under uiBundles/*/src/ for visual or UI changes to an EXISTING app — pages, components, sections, layout, styling, colors, fonts, navigation, animations, or any look-and-feel change. Use this skill when modifying pages, components, layout, styling, or navigation in an existing UI bundle app. Activate when the project contains appLayout.tsx, routes.tsx, src/pages/, src/components/, or global.css. This skill contains critical project-specific conventions (appLayout.tsx shell, shadcn/ui components, Tailwind CSS, Salesforce base-path routing, module restrictions) that override general knowledge. Without this skill, generated code will use wrong imports, break routing, or ignore project structure. Do NOT use when creating a new app from scratch (use building-ui-bundle-app instead).

forcedotcom/configuring-connected-apps

Salesforce Connected Apps and External Client Apps OAuth configuration with 120-point scoring. Use this skill to configure OAuth flows, JWT bearer auth, Connected Apps, and External Client Apps in Salesforce. TRIGGER when: user configures OAuth flows, JWT bearer auth, Connected Apps, ECAs, or touches .connectedApp-meta.xml / .eca-meta.xml files. DO NOT TRIGGER when: configuring Named Credentials for callouts (use building-sf-integrations), reviewing permission policies (use deploying-metadata), or writing Apex token-handling code (use generating-apex).

forcedotcom/debugging-apex-logs

Salesforce debug log analysis and troubleshooting with 100-point scoring. TRIGGER when: user analyzes debug logs, hits governor limits, reads stack traces, or touches .log files from Salesforce orgs. DO NOT TRIGGER when: running Apex tests (use running-apex-tests), generating or fixing Apex code (use generating-apex), or Agentforce session tracing (use observing-agentforce).

forcedotcom/deploying-metadata

Salesforce DevOps automation using sf CLI v2. TRIGGER when: user deploys metadata, creates/manages scratch orgs or sandboxes, sets up CI/CD pipelines, or troubleshoots deployment errors with sf project deploy. DO NOT TRIGGER when: writing Apex code (use generating-apex), building LWC components (use generating-lwc-components), creating metadata definitions (use generating-custom-object or generating-custom-field), or querying org data (use handling-sf-data).

forcedotcom/deploying-ui-bundle

MUST activate when the project contains a uiBundles/*/src/ directory or sfdx-project.json and the task involves deploying, pushing to an org, or post-deploy setup. Use this skill when deploying a UI bundle app to a Salesforce org. Covers the full deployment sequence: org authentication, pre-deploy build, metadata deployment, permission set assignment, data import, GraphQL schema fetch, and codegen. Activate when files like *.uibundle-meta.xml or sfdx-project.json exist and the user mentions deploying, pushing, org setup, or post-deploy tasks.

forcedotcom/developing-agentforce

Build, modify, debug, and deploy agents with Agentforce Agent Script. TRIGGER when: user creates, modifies, or asks about .agent files or aiAuthoringBundle metadata; changes agent behavior, responses, or conversation logic; designs agent actions, tools, subagents, or flow control; writes or reviews an Agent Spec; previews, debugs, deploys, publishes, or tests agents; uses Agent Script CLI commands (sf agent generate/preview/publish/test). DO NOT TRIGGER when: Apex development, Flow building, Prompt Template authoring, Experience Cloud configuration, or general Salesforce CLI tasks unrelated to Agent Script.

forcedotcom/fetching-salesforce-docs

Official Salesforce documentation retrieval skill. Use when you need authoritative Salesforce docs from developer.salesforce.com, help.salesforce.com, architect.salesforce.com, admin.salesforce.com, or lightningdesignsystem.com, especially when pages are JS-heavy, shell-rendered, or hard to extract with naive fetching. Use to ground answers in official Salesforce sources instead of third-party blogs or summaries. TRIGGER when: user asks for official Salesforce documentation, Apex or API reference, LWC docs, Agentforce docs, setup or help articles, or any doc from a Salesforce-owned domain. DO NOT TRIGGER when: user is asking for a code change, deployment task, or anything not requiring documentation retrieval — use the appropriate sf-* skill instead.

forcedotcom/generating-apex

Primary Apex authoring skill for class generation, refactoring, and review. ALWAYS ACTIVATE when the user mentions Apex, .cls, triggers, or asks to create/refactor a class (service, selector, domain, batch, queueable, schedulable, invocable, DTO, utility, interface, abstract, exception, REST resource). Use this skill for requests involving SObject CRUD, mapping collections, fetching related records, scheduled jobs, batch jobs, trigger design, @AuraEnabled controllers, @RestResource endpoints, custom REST APIs, or code review of existing Apex.

forcedotcom/generating-apex-test

Generate and validate Apex test classes with TestDataFactory patterns, bulk testing (251+ records), mocking strategies, assertion best practices, and disciplined test-fix loops. Use this skill when creating new Apex test classes, improving test coverage, debugging and fixing failing Apex tests, running test execution and coverage analysis, or implementing testing patterns for triggers, services, controllers, batch jobs, queueables, and integrations. Triggers on *Test.cls, *_Test.cls files, sf apex run test workflows, coverage reports, test-fix loops. Do NOT trigger for production Apex code (use generating-apex) or Jest/LWC tests.

forcedotcom/generating-custom-application

Use this skill when users need to create or configure tab-based Salesforce Custom Applications with navigation, branding, and action overrides. Trigger when users mention custom apps, application metadata, app navigation, or organizing tabs into applications. Use when users want to create app containers for tabs and pages. Do NOT use when the goal is hosting a React UI bundle in the App Launcher — use generating-ui-bundle-custom-app for that case.

forcedotcom/generating-custom-field

Use this skill when users need to create, generate, or validate Salesforce Custom Field metadata. Trigger when users mention custom fields, field types, Roll-up Summary fields, Master-Detail relationships, Lookup relationships, formula fields, picklists, or field metadata. Also use when users encounter field deployment errors, especially around Roll-up Summary format, Master-Detail constraints, or formula issues. Always use this skill for any custom field metadata work, field generation, or field troubleshooting.

forcedotcom/generating-custom-lightning-type

Use this skill when users need to create Custom Lightning Types (CLTs) for Einstein Agent actions or structured input/output schemas. Trigger when users mention CLT, Custom Lightning Types, Custom Lightning Types (CLTs) with widget/mosaic/fragment rendition/renderer, JSON schemas for agents, type definitions, lightning__objectType, or editor/renderer configurations. When widget renditions are requested, you MUST first read the widget-rendition.md reference file in this skill's references/ directory and follow its complete workflow. This is complex - always use this skill for CLT work.

forcedotcom/generating-custom-object

Use this skill when users need to create, generate, or validate Salesforce Custom Object metadata. Trigger when users mention custom objects, creating objects, object metadata, .object files, sharing models, name fields, or validation rules on objects. Also use when users say things like "create a custom object", "generate object metadata", "set up an object for...", or when they're troubleshooting object deployment errors especially around sharing models and Master-Detail relationships. Always use this skill for any custom object metadata work.

forcedotcom/generating-custom-tab

Use this skill when users need to create or configure Salesforce Custom Tabs. Trigger when users mention tabs, navigation tabs, object tabs, web tabs, Visualforce tabs, Lightning component tabs, app page tabs, or tab configuration. Also use when users want to add navigation to custom objects, create tabs for external content, or set up Lightning page tabs. Always use this skill for any custom tab work.

forcedotcom/generating-flexipage

Use this skill when users need to create, generate, modify, or validate Salesforce Lightning pages (FlexiPages). Trigger when users mention RecordPage, AppPage, HomePage, Lightning pages, page layouts, adding components to pages, or page customization. Also use when users say things like 'create a Lightning page', 'add a component to a page', 'customize the record page', 'generate a FlexiPage', or when they're working with FlexiPage XML files and need help with components, regions, or deployment errors. Always use this skill for any FlexiPage-related work, even if they just mention 'page' in the context of Salesforce.

forcedotcom/generating-flow

Generate Salesforce Flows using the MCP tool execute_metadata_action. Use when the user asks to create, build, or generate a flow — including Screen, Autolaunched, Record-Triggered (before/after-save), Scheduled. Also trigger for flow-like requests such as "when a record is created", "trigger daily at", "send an email when", "update the field when", "automate", "workflow", or "flow XML/metadata". This is the only skill for Salesforce Flow generation.

forcedotcom/generating-lightning-app

Build complete Salesforce Lightning Experience applications from natural language descriptions. Use this skill when a user requests a "complete app", "Lightning app", "business solution", "management system", or describes a scenario requiring multiple interconnected Salesforce components (objects, fields, pages, tabs, security). Orchestrates all required metadata types in proper dependency order to produce a deployable application.

forcedotcom/generating-list-view

Use this skill when users need to create, generate, or validate Salesforce List View metadata. Trigger when users mention list views, filtered record lists, creating views, setting up record columns, filtering records by criteria, or ask about list view visibility. Also use when users say things like "I need a view that shows...", "filter records by...", "create a list view for...", or when they're working with ListView XML files and need validation or troubleshooting.

相关技能