Help us improve
Share bugs, ideas, or general feedback.
From vanguard-frontier-agentic
Generates production-ready SOQL queries from natural-language requirements with selectivity analysis and governor-limit guidance. Does not execute queries.
npx claudepluginhub raishin/vanguard-frontier-agentic --plugin vanguard-frontier-agenticHow this skill is triggered — by the user, by Claude, or both
Slash command
/vanguard-frontier-agentic:salesforce-soql-generator-skillThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Pure generation skill — plain English to production-ready SOQL. This skill
Executes read-only SOQL queries against a connected Salesforce org via sf data query CLI under T1 least-privilege scope. Returns sanitized JSON with structured audit envelope. Use for live record evidence like pipeline counts, field values, or aggregate queries.
Identifies Salesforce pitfalls like SOQL N+1 queries, governor limit violations, API overuse, and SOQL injection during code reviews, onboarding, and integration audits.
Generates optimized SQL queries from natural language for BigQuery, PostgreSQL, MySQL, Snowflake, SQL Server. Reads schemas from uploaded files, diagrams, docs for reporting, analysis, exploration.
Share bugs, ideas, or general feedback.
Pure generation skill — plain English to production-ready SOQL. This skill
is a translator, not an executor. It produces ready-to-paste queries with
selectivity analysis and governor-limit guidance, then hands off to
salesforce-soql-explorer-skill for live execution.
Use salesforce-soql-generator-skill when the work requires query authoring
from a description, not live data retrieval:
Delegate elsewhere when:
| Situation | Skill to use |
|---|---|
| Query must be executed against a live org | salesforce-soql-explorer-skill |
| User needs permission-set or profile diagnostic SOQL | salesforce-permission-model-review-skill |
| Query result will drive DML or automation | Review with salesforce-metadata-review-skill first |
| Apex selector pattern needed (not raw SOQL) | querying-soql (sf-skills) |
| Report or dashboard conversion | Assess whether SOQL truly maps to Report; flag gap |
Before generating any query, confirm or infer:
Opportunity, Lead, Contact,
My_Custom_Object__c). Is this a single-object or multi-level relationship
query?If any of these are ambiguous, make a conservative assumption, state it explicitly, and offer an alternative.
Identify the root sObject and clarify whether the query is for:
State the confirmed interpretation before generating.
Apply these constraints from the start:
SELECT *Produce one canonical query first, then offer variants.
Evaluate the generated query against the selectivity rubric:
Document the selectivity assessment inline.
For every generated query, provide:
USING SCOPE or FOR REFERENCE / FOR VIEW / FOR UPDATE locking
hints applyEmit at least two variants beyond the canonical query:
Emit the structured output (see Output Format). Always include a
handoff_recommendation pointing to salesforce-soql-explorer-skill for
live execution, or to the appropriate review skill if the query surfaces a
governance concern.
Score every generated query before emitting. Threshold: 80+ acceptable for paste-ready output; 60–79 emit with caveat; below 60 revise before emitting.
| Dimension | Points | What earns full marks |
|---|---|---|
| Selectivity | 30 | WHERE uses at least one indexed field; no full-table-scan pattern on objects likely > 10k records |
| Field minimality | 20 | Only required fields; no SELECT *; field count ≤ 10 for display queries |
| LIMIT present | 15 | LIMIT applied where result set could be unbounded; aggregate queries exempt when GROUP BY guarantees few rows |
| Syntax correctness | 20 | Valid SOQL syntax; correct relationship traversal notation; correct date literal usage; no reserved word conflicts |
| Governor-limit safety | 15 | Row return estimate well below 50k ceiling; embeddable in transaction; no query-in-loop anti-pattern implied |
Scoring penalties:
SELECT * pattern: −15generated_query: |
SELECT <fields>
FROM <SObject>
WHERE <filter>
ORDER BY <field> <ASC|DESC>
LIMIT <n>
interpretation: "<what was understood from the natural-language request>"
alternate_queries:
filtered: |
SELECT <fields>
FROM <SObject>
WHERE <narrower filter>
LIMIT <n>
aggregate: |
SELECT <grouping_field>, COUNT(Id) record_count
FROM <SObject>
WHERE <filter>
GROUP BY <grouping_field>
paginated: |
SELECT <fields>
FROM <SObject>
WHERE Id > :lastId AND <filter>
ORDER BY Id ASC
LIMIT 200
selectivity_analysis:
indexed_filters_used: ["<field1>", "<field2>"]
non_indexed_filters: ["<field>"]
full_table_scan_risk: "low | medium | high"
notes: "<explanation>"
governor_limit_notes:
estimated_row_range: "<low estimate> – <high estimate>"
limit_advisory: "<why this LIMIT was chosen>"
transaction_safe: true | false
notes: "<any ceiling-proximity warnings>"
suggested_index:
- field: "<FieldApiName>"
reason: "<why an index on this field would help>"
score: <0-100>
score_breakdown:
selectivity: <0-30>
field_minimality: <0-20>
limit_present: <0-15>
syntax_correctness: <0-20>
governor_limit_safety: <0-15>
score_notes: "<what drove the score; any penalties applied>"
handoff_recommendation:
execute_live: "salesforce-soql-explorer-skill"
governance_review: "<skill if a concern surfaced, else 'none'>"
notes: "<when to execute, any pre-execution checks>"
assumptions:
- "<explicit list of assumptions made where input was ambiguous>"
| Situation | Hand off to |
|---|---|
| User wants to execute the generated query against a live org | salesforce-soql-explorer-skill |
| Query reveals a governance or access concern | salesforce-permission-model-review-skill |
| Query is a Report-equivalent but a Report likely meets the need | Note the gap; suggest the Report builder as an alternative |
| Permission diagnostic SOQL needed | salesforce-permission-model-review-skill |
| Apex selector pattern needed | querying-soql (sf-skills reference) |
These are the most frequent errors in generated SOQL. Check each before emitting the final query.
SOQL does not support SELECT *. Always enumerate fields. When fields are
unknown, use a minimal set (Id, Name, one or two distinguishing fields)
and note that the user should expand once the schema is confirmed.
Any query on a high-volume object without a LIMIT risks hitting the 50,000-row governor ceiling or causing a query timeout. Always include LIMIT unless:
Filtering on formula fields, long-text-area fields, or custom fields without
an explicit custom index is a common performance trap. Always flag these in
selectivity_analysis.non_indexed_filters and recommend that the user check
with their Salesforce admin whether a custom index exists or is needed.
Use Salesforce date literal syntax precisely:
TODAY, YESTERDAY, TOMORROWTHIS_WEEK, LAST_WEEK, NEXT_WEEKTHIS_MONTH, LAST_MONTH, NEXT_MONTHTHIS_QUARTER, LAST_QUARTER, NEXT_QUARTERTHIS_YEAR, LAST_YEAR, NEXT_YEARLAST_N_DAYS:n, NEXT_N_DAYS:nLAST_N_WEEKS:n, NEXT_N_WEEKS:nLAST_N_MONTHS:n, NEXT_N_MONTHS:nDo not mix date literals with datetime comparisons without explicit timezone handling. Salesforce date literals respect the running user's timezone.
Formula fields are not indexed and cannot use standard indexes. Including a
formula field in a WHERE clause without a companion indexed filter forces a
full table scan. Flag this in selectivity_analysis and suggest an
alternative (e.g., use the underlying source fields instead of the formula).
Querying the Who or What fields on Task / Event, or the Owner
field when it can be a User or Queue, requires a TYPEOF expression or a
Type filter. Incorrect assumptions produce incomplete results. Always
clarify whether the relationship is polymorphic and use TYPEOF where needed.
SOQL allows up to 5 levels of parent traversal and up to 1 level of child subquery nesting (for relationship queries). Beyond these limits, the query will fail at runtime. Flag any traversal depth that approaches the limit.
| File | When to read |
|---|---|
references/soql-syntax-quickref.md | Syntax reference for SELECT, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, FOR clauses |
references/common-patterns.md | Pre-built patterns for pipeline, stale records, ownership audit, junction objects |
references/governor-limits.md | Row limits, query count limits, LDV considerations, index guidance |