Agent skill

Soql Lib Testing

by beyond-the-cloud-dev in beyond-the-cloud-dev/soql-lib

Writes unit tests for Salesforce Apex code that uses SOQL Lib (SOQL.cls).

MITAuto-check passedTesting & QA

Install Soql Lib Testing

skills CLI
$ npx skills add beyond-the-cloud-dev/soql-lib --skill soql-lib-testing -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install beyond-the-cloud-dev/soql-lib soql-lib-testing --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/beyond-the-cloud-dev/soql-lib.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.cursor/skills/soql-lib-testing .claude/skills/soql-lib-testing && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
soql-lib-testing
GitHub stars
154
Token cost
~2.1k tokens
SKILL.md length
261 words
Files
1
Skills in repo
3
Repo updated
First seen
Licence
MIT

At a glance

Writes unit tests for Salesforce Apex code that uses SOQL Lib (SOQL.cls).

  • Writing @IsTest classes that call SOQL Lib selectors
  • SKILL.md covers When to Use, Instructions and Examples
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Inline SOQL.of() queries

What it does

Soql Lib Testing is an agent skill from beyond-the-cloud-dev/soql-lib. Writes unit tests for Salesforce Apex code that uses SOQL Lib (SOQL.cls). Covers SOQL.mock() setup by mockId string or SObjectType, thenReturn() for records/lists/counts/aggregate results, throwException() mocking, and sequential mocks for multiple calls. Use when writing @IsTest classes that call SOQL Lib selectors or inline SOQL.of() queries, or when asked how to mock SOQL queries in Apex unit tests.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Unit testing and CRM management. It works with Salesforce. The repository describes itself as: The SOQL Lib provides functional constructs for SOQL queries in Apex. The licence is MIT.

When your agent uses it

  • Writing @IsTest classes that call SOQL Lib selectors
  • Inline SOQL.of() queries
  • Asked how to mock SOQL queries in Apex unit tests

Example prompts

  • “Use the soql-lib-testing skill to write unit tests for Salesforce Apex code that uses SOQL Lib (SOQL.cls)”
  • “/soql-lib-testing”

What it can do on your machine

Read from SKILL.md and the folder at commit cc06784. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are apex).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Soql Lib Testing loads about 2.1k tokens when it runs. Until then it costs about 106 tokens; SKILL.md has 261 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~106
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from beyond-the-cloud-dev/soql-lib at commit cc06784, republished under its MIT licence (© beyond-the-cloud-dev). 261 words, ~2,148 tokens.

Download SKILL.mdSave it as .claude/skills/soql-lib-testing/SKILL.md (or your agent's skills folder).
name
soql-lib-testing
description
Writes unit tests for Salesforce Apex code that uses SOQL Lib (SOQL.cls). Covers SOQL.mock() setup by mockId string or SObjectType, thenReturn() for records/lists/counts/aggregate results, throwException() mocking, and sequential mocks for multiple calls. Use when writing @IsTest classes that call SOQL Lib selectors or inline SOQL.of() queries, or when asked how to mock SOQL queries in Apex unit tests.

SOQL Lib — Testing & Mocking

SOQL Lib has a built-in mock mechanism — no stub frameworks needed. Mocks are registered before calling production code and consumed in registration order.

When to Use

  • Use this skill when writing @IsTest classes that test code using SOQL Lib queries
  • Use this skill when mocking SOQL.of(...) inline queries in unit tests
  • Use this skill when testing aggregate queries, exception paths, or COUNT results

Instructions

Determine the mock key

Selector classes expose @TestVisible private static final String MOCK_ID. Inline queries without a custom mockId are mocked by SObjectType:

apex
// Selector
SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(records);

// Inline SOQL.of(Account.SObjectType) — no mockId set
SOQL.mock(Account.SObjectType).thenReturn(records);

// Inline SOQL.of(Account.SObjectType).mockId('MyAccounts') — custom mock id
SOQL.mock('MyAccounts').thenReturn(records);

Always reference the MOCK_ID constant — never repeat the string literal (fragile when class is renamed).

Register mocks before calling production code

Always register mocks before Test.startTest():

apex
SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new Account(Name = 'Acme'));

Test.startTest();
List<Account> result = MyService.getAccounts();
Test.stopTest();
thenReturn overloads
apex
// Single record — pass SObject directly (not a one-element list)
SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new Account(Name = 'Acme'));

// Multiple records — typed list, never List<SObject>
SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new List<Account>{
    new Account(Name = 'Acme'),
    new Account(Name = 'Globex')
});

// Empty list — test zero-result paths
SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new List<Account>());

// COUNT query
SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(42);

// Aggregate results — use List<Map<String, Object>> (AggregateResult cannot be instantiated)
SOQL.mock('leadsQuery').thenReturn(new List<Map<String, Object>>{
    new Map<String, Object>{ 'LeadSource' => 'Web',   'total' => 10 },
    new Map<String, Object>{ 'LeadSource' => 'Phone', 'total' => 5 }
});

// Single aggregate result
SOQL.mock('leadsQuery').thenReturn(new Map<String, Object>{ 'total' => 100 });
Exception mocking
apex
// Default message: 'List has no rows for assignment to SObject'
SOQL.mock(SOQL_Account.MOCK_ID).throwException();

// Custom message
SOQL.mock(SOQL_Account.MOCK_ID).throwException('No such column \'InvalidField__c\'');
Sequential mocks (multiple calls in one test)

Each SOQL.mock(...) call appends to the queue and is consumed in order:

apex
SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new Account(Name = 'First call'));
SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new Account(Name = 'Second call'));
Key rules
RuleDetail
Set mock before production callAlways before Test.startTest()
Use typed listsnew List<Account>{...} — framework strips extra fields to mirror real SOQL
Use MOCK_ID constantNever repeat the string literal
Aggregate mockingUse toAggregatedProxy() in production code; mock with List<Map<String, Object>>
Ids are auto-generatedRecords get auto-assigned Ids — no fake prefix strings needed
toObject() returns nullNo exception for 0 rows — test this path explicitly
toObject() throws for >1 rowWhen result has multiple records — test this error path too
SObjectType mockSOQL.mock(Account.SObjectType) mocks all inline queries for that type without a custom mockId

Examples

Selector — list result
apex
@IsTest
private class SOQL_Account_Test {

    @IsTest
    static void byType_returnsMatchingAccounts() {
        SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new Account(Name = 'TechCorp', Type = 'Customer'));

        Test.startTest();
        List<Account> result = SOQL_Account.query()
            .byType('Customer')
            .toList();
        Test.stopTest();

        Assert.areEqual(1, result.size(), 'Should return one account.');
        Assert.areEqual('TechCorp', result[0].Name, 'Account name should match.');
    }

    @IsTest
    static void toObject_returnsNullWhenNoRecords() {
        SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new List<Account>());

        Test.startTest();
        Account result = (Account) SOQL_Account.query().toObject();
        Test.stopTest();

        Assert.isNull(result, 'Should return null when no records found.');
    }

    @IsTest
    static void throwException_propagatesError() {
        SOQL.mock(SOQL_Account.MOCK_ID).throwException();

        Test.startTest();
        Exception caughtEx;
        try {
            SOQL_Account.query().toObject();
        } catch (Exception e) {
            caughtEx = e;
        }
        Test.stopTest();

        Assert.isNotNull(caughtEx, 'Exception should be thrown.');
    }

    @IsTest
    static void throwException_withCustomMessage() {
        String errorMessage = 'No such column \'InvalidField__c\' on entity \'Account\'.';
        SOQL.mock(SOQL_Account.MOCK_ID).throwException(errorMessage);

        Test.startTest();
        Exception caughtEx;
        try {
            SOQL_Account.query().toObject();
        } catch (Exception e) {
            caughtEx = e;
        }
        Test.stopTest();

        Assert.isNotNull(caughtEx);
        Assert.isTrue(caughtEx.getMessage().contains('InvalidField__c'));
    }
}
COUNT query
apex
@IsTest
static void count_returnsExpectedNumber() {
    SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(7);

    Test.startTest();
    Integer count = SOQL_Account.query().toInteger();
    Test.stopTest();

    Assert.areEqual(7, count, 'Count should match mock value.');
}
Aggregate query (toAggregatedProxy)
apex
// Production code
public List<SOQL.AggregateResultProxy> getLeadsBySource() {
    return SOQL.of(Lead.SObjectType)
        .with(Lead.LeadSource)
        .count(Lead.Id, 'total')
        .groupBy(Lead.LeadSource)
        .mockId('leadsBySource')
        .toAggregatedProxy();
}

// Test
@IsTest
static void getLeadsBySource_returnsGroupedResults() {
    SOQL.mock('leadsBySource').thenReturn(new List<Map<String, Object>>{
        new Map<String, Object>{ 'LeadSource' => 'Web',   'total' => 10 },
        new Map<String, Object>{ 'LeadSource' => 'Phone', 'total' => 3 }
    });

    Test.startTest();
    List<SOQL.AggregateResultProxy> results = new LeadService().getLeadsBySource();
    Test.stopTest();

    Assert.areEqual(2, results.size());
    Assert.areEqual(10,    (Integer) results[0].get('total'));
    Assert.areEqual('Web', (String)  results[0].get('LeadSource'));
}
Inline query — mock by SObjectType
apex
// Production code — no selector, no mockId
List<Account> accounts = SOQL.of(Account.SObjectType)
    .with(Account.Id, Account.Name)
    .toList();

// Test — mock by SObjectType
SOQL.mock(Account.SObjectType).thenReturn(new Account(Name = 'Test'));
Inline query — mock by custom mockId
apex
// Production code
List<Account> accounts = SOQL.of(Account.SObjectType)
    .mockId('MyAccounts')
    .with(Account.Id, Account.Name)
    .toList();

// Test
SOQL.mock('MyAccounts').thenReturn(new Account(Name = 'Test'));
Map result
apex
@IsTest
static void toMap_returnsAccountsKeyedById() {
    SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new Account(Name = 'Acme'));

    Test.startTest();
    Map<Id, Account> result = (Map<Id, Account>) SOQL_Account.query().toMap();
    Test.stopTest();

    Assert.areEqual(1, result.size());
}
Sequential mocks
apex
@IsTest
static void sequential_consumedInOrder() {
    SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new Account(Name = 'First'));
    SOQL.mock(SOQL_Account.MOCK_ID).thenReturn(new Account(Name = 'Second'));

    Test.startTest();
    List<Account> first  = SOQL_Account.query().toList();
    List<Account> second = SOQL_Account.query().toList();
    Test.stopTest();

    Assert.areEqual('First',  first[0].Name);
    Assert.areEqual('Second', second[0].Name);
}

© beyond-the-cloud-dev, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .cursor/skills/soql-lib-testing of beyond-the-cloud-dev/soql-lib.

Open the folder on GitHubat commit cc06784

Compare with similar skills

Soql Lib Testing next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Soql Lib Testing compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Soql Lib Testing this skillbeyond-the-cloud-dev/soql-lib154—~2.1kAutomated safety check: PassMIT
Salesforce DeveloperJeffallan/claude-skills12k—~1.9kAutomated safety check: PassMIT
Sf DataJaganpro/sf-skills424—~2.1kAutomated safety check: PassMIT
Platform Data Manageforcedotcom/sf-skills1.1k—~2.7kAutomated safety check: PassApache-2.0
Platform Apex Anonymous Runforcedotcom/sf-skills1.1k—~3kAutomated safety check: PassApache-2.0
Experience Aura Lwc Migrateforcedotcom/sf-skills1.1k—~3.5kAutomated safety check: PassApache-2.0

Similar skills

  • Salesforce Developer

    Jeffallan/claude-skills

    Writes Apex, Lightning Web Components and SOQL for the Salesforce platform, with bulkified triggers, governor-limit checks, 90% test coverage and Salesforce DX deployment.

    12k GitHub stars~1.9k tokensUpdated 4 days ago
    DevelopmentAuto-check passed
  • Sf Data

    Jaganpro/sf-skills

    Salesforce data operations with 130-point scoring. An agent skill from Jaganpro/sf-skills.

    424 GitHub stars~2.1k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed
  • Platform Data Manage

    forcedotcom/sf-skills

    Salesforce data operations with 130-point scoring. An agent skill from forcedotcom/sf-skills.

    1.1k GitHub stars~2.7k tokensUpdated today
    Testing & QAAuto-check passed
  • Platform Apex Anonymous Run

    forcedotcom/sf-skills

    Runs anonymous Apex against the connected org (.apex file or pasted snippet), capturing the debug log, surfacing errors.

    1.1k GitHub stars~3k tokensUpdated today
    Testing & QAAuto-check passed
  • Experience Aura Lwc Migrate

    forcedotcom/sf-skills

    A skill your agent uses to analyze a Salesforce Aura component bundle (.cmp, .app, .evt, .intf, Controller.js, Helper.js, Renderer.js) and produce a framework-agnostic migration blueprint (PRD.yaml…

    1.1k GitHub stars~3.5k tokensUpdated today
    Product & Project ManagementAuto-check passed
  • Experience Lwc Generate

    forcedotcom/sf-skills

    Lightning Web Components with PICKLES methodology and 165-point scoring.

    1.1k GitHub stars~2.4k tokensUpdated today
    Testing & QAAuto-check passed

More from beyond-the-cloud-dev/soql-lib

  • Soql Lib Query Builder

    beyond-the-cloud-dev/soql-lib

    Builds Salesforce SOQL queries using the SOQL Lib fluent builder API (SOQL.cls).

    154 GitHub stars~4.3k tokensUpdated 4 days ago
    Auto-check passed
  • Soql Lib Selector

    beyond-the-cloud-dev/soql-lib

    Creates Salesforce Apex selector classes using the SOQL Lib selector pattern.

    154 GitHub stars~2k tokensUpdated 4 days ago
    Auto-check passed

Works with

Questions about Soql Lib Testing

What does Soql Lib Testing do?

Writes unit tests for Salesforce Apex code that uses SOQL Lib (SOQL.cls). Soql Lib Testing is an agent skill from beyond-the-cloud-dev/soql-lib.cls).

When should I use Soql Lib Testing?

Soql Lib Testing fits situations like: writing @IsTest classes that call SOQL Lib selectors; inline SOQL.of() queries; asked how to mock SOQL queries in Apex unit tests.

How do I install Soql Lib Testing in Claude Code?

Run `npx skills add beyond-the-cloud-dev/soql-lib --skill soql-lib-testing -a claude-code`. Or copy the skill folder (.cursor/skills/soql-lib-testing in beyond-the-cloud-dev/soql-lib) into .claude/skills/soql-lib-testing in your project. Claude Code loads it when a task matches its description.

How do I install Soql Lib Testing in Codex?

Run `npx skills add beyond-the-cloud-dev/soql-lib --skill soql-lib-testing -a codex`. Or copy the skill folder (.cursor/skills/soql-lib-testing in beyond-the-cloud-dev/soql-lib) into .agents/skills/soql-lib-testing in your project. Codex loads it when a task matches its description.

Can I use Soql Lib Testing in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add beyond-the-cloud-dev/soql-lib --skill soql-lib-testing -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/soql-lib-testing, .gemini/skills/soql-lib-testing, .github/skills/soql-lib-testing and .opencode/skills/soql-lib-testing in your project.

What does Soql Lib Testing need to run?

SKILL.md names no scripts, command-line tools or credentials: Soql Lib Testing is instructions for the agent only.

Does Soql Lib Testing access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Soql Lib Testing safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Soql Lib Testing use?

Soql Lib Testing is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Soql Lib Testing use?

About 2.1k tokens (SKILL.md is roughly 8.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Soql Lib Testing?

Skills that share tags, products or a category with Soql Lib Testing: Salesforce Developer (Jeffallan/claude-skills, 12k stars), Sf Data (Jaganpro/sf-skills, 424 stars), Platform Data Manage (forcedotcom/sf-skills, 1.1k stars) and Platform Apex Anonymous Run (forcedotcom/sf-skills, 1.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Soql Lib Testing?

beyond-the-cloud-dev (a GitHub organization) maintains it in beyond-the-cloud-dev/soql-lib, which has 154 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 3, 2026.

Source: beyond-the-cloud-dev/soql-lib on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.