platform-soql-query

Generate, optimize, and validate Salesforce SOQL and SOSL queries with selectivity scoring.

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/padjei/SF_Build --skill platform-soql-query-padjei
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: platform-soql-query
Source: https://github.com/padjei/SF_Build/tree/main/.claude/skills/platform-soql-query
Command: npx skills add https://github.com/padjei/SF_Build --skill platform-soql-query-padjei

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Writing performant Salesforce queries requires deep knowledge of selectivity rules, indexed fields, governor limits, and security modes. This Skill converts natural-language requirements into correct SOQL/SOSL and audits existing queries against a 100-point scoring rubric so slow, non-selective, or insecure queries are caught before production. ## Core Features & Use Cases - Natural Language to SOQL: Turn plain-English requests into executable queries with the right shape — relationship queries, aggregates, semi-joins, or SOSL. - Query Optimization & Scoring: Evaluate selectivity, LIMIT usage, field selection, and security clauses (WITH USER_MODE, WITH SECURITY_ENFORCED) with a 100-point score guide. - Anti-Pattern Detection: Identify SOQL-in-loops, leading wildcards, non-selective filters, and missing field coverage in Apex contexts. - Use Case: Ask for "Accounts with open Opportunities created this quarter" and receive an optimized query plus design rationale, then validate a .soql file edit via the post-write hook with static checks and live query plan analysis. ## Quick Start Ask the assistant to generate an optimized SOQL query for the records you need, naming the target object, fields, and filter criteria.

Frequently Asked Questions about platform-soql-query

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert natural language into a SOQL query?▼

Describe the target object, fields, filter criteria, and sort or limit needs in plain English. The skill selects the right query shape — child-to-parent traversal, subquery, aggregate, or SOSL — and returns the final SOQL with design rationale and optimization notes.

How do I optimize a slow or non-selective SOQL query?▼

Add filters on indexed fields such as Id, Name, OwnerId, CreatedDate, or RecordTypeId, avoid leading wildcards and negative operators, and apply a reasonable LIMIT. A query is selective when it returns under 10% of the first million records.

What are common SOQL anti-patterns to avoid in Apex?▼

The most damaging patterns are queries inside loops, non-selective WHERE clauses, leading wildcards, querying for null, selecting all fields, and unfiltered subqueries. The fix is bulkification: collect IDs first, query once with IN, and use a Map for lookups.

Can I run SOQL queries from the Salesforce CLI?▼

Yes, use sf data query with --query and --target-org flags, with JSON or CSV output formats. For large result sets over 2,000 records use sf data export bulk, and use the Tooling API plan flag for query plan analysis.

Why does my Apex code throw SObjectException for a field I queried?▼

The error occurs when code accesses a field not included in the SELECT clause, including parent relationship fields like Account.Name. Every field read in conditionals, assignments, or method calls must appear in the query, using dot notation for relationships.

When should I not use this SOQL skill?▼

Delegate bulk data import, export, or DML operations to a data management skill, and broader Apex implementation work to an Apex generation skill. This skill focuses on query authoring, optimization, and validation only.