
Generates, optimizes, and scores SOQL queries for Salesforce with a 100-point rubric across five categories. Handles everything from natural language to query conversion, relationship traversals, aggregates, and selectivity analysis. Knows when to use child-to-parent lookups versus subqueries, when SOSL beats SOQL, and flags anti-patterns like querying in loops or leading wildcards. The scoring system is genuinely useful: anything under 70 needs work before production, 90+ means it's optimized and ready. Delegates actual query execution to sf-data and Apex embedding to sf-apex, keeping focus purely on query shape and performance. Built by someone who clearly debugged too many slow queries.
$ npx -y skills add jaganpro/sf-skills --skill sf-soql --agent claude-codeInstalls into .claude/skills of the current project.
Use this skill when the user needs SOQL/SOSL authoring or optimization: natural-language-to-query generation, relationship queries, aggregates, query-plan analysis, and performance/safety improvements for Salesforce queries.
Use sf-soql when the work involves:
.soql filesDelegate elsewhere when the user is:
Ask for or infer:
Prefer:
| Need | Default pattern |
|---|---|
| parent data from child | child-to-parent traversal |
| child rows from parent | subquery |
| counts / rollups | aggregate query |
| records with / without related rows | semi-join / anti-join |
| text search across objects | SOSL |
Check:
If the user wants runtime verification, hand off execution to:
SELECT * style thinking; query only required fieldsWhen finishing, report in this order:
Suggested shape:
Query goal: <summary>
Query: <soql or sosl>
Design: <relationship / aggregate / filter choices>
Notes: <selectivity, limits, security, governor awareness>
Next step: <run in sf-data or embed in Apex>
| Need | Delegate to | Reason |
|---|---|---|
| run the query against an org | sf-data | execution and export |
| embed the query in services/selectors | sf-apex | implementation context |
| analyze slow-query symptoms from logs | sf-debug | runtime evidence |
| wire query-backed UI | sf-lwc | frontend integration |
| Score | Meaning |
|---|---|
| 90+ | production-optimized query |
| 80–89 | good query with minor improvements possible |
| 70–79 | functional but performance concerns remain |
| < 70 | needs revision before production use |
Sponsors