Agent skill

Platform Apex Test Run

by forcedotcom in forcedotcom/sf-skills

Apex test execution, coverage analysis, and test-fix loops with 120-point scoring.

Apache-2.0Auto-check passedTesting & QA

Install Platform Apex Test Run

skills CLI
$ npx skills add forcedotcom/sf-skills --skill platform-apex-test-run -a claude-code

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

GitHub CLI
$ gh skill install forcedotcom/sf-skills platform-apex-test-run --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/forcedotcom/sf-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/platform-apex-test-run .claude/skills/platform-apex-test-run && 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
platform-apex-test-run
GitHub stars
1.1k
Token cost
~1.9k tokens
SKILL.md length
751 words
Files
15 (incl. scripts, references, assets)
Skills in repo
251
Repo updated
First seen
Licence
Apache-2.0

At a glance

Apex test execution, coverage analysis, and test-fix loops with 120-point scoring.

  • Works in 5 steps: Discover test scope → Run the smallest useful test set first → Analyze results → …
  • The user runs Apex tests
  • SKILL.md covers When This Skill Owns the Task, Required Context to Gather First, Recommended Workflow and High-Signal Rules, plus 5 more sections
  • Runs Python scripts from its folder; calls sf

What it does

Platform Apex Test Run is an agent skill from forcedotcom/sf-skills. Apex test execution, coverage analysis, and test-fix loops with 120-point scoring. Use when the user runs Apex tests, checks code coverage, fixes failing tests, or touches Test.cls / Test.cls files. DO NOT TRIGGER when writing Apex production code (use platform-apex-generate), Agentforce agent testing (use agentforce-test), or Jest/LWC tests (use experience-lwc-generate).

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 17 other files, including scripts, reference files and assets (for example `README.md`, `references/cli-commands.md` and `references/mocking-patterns.md`).

It sits in Testing & QA, covering Unit testing, Test coverage and Failing and flaky tests. It works with Salesforce and Jest. The repository describes itself as: Salesforce's curated collection of agent skills for building applications. Optimized for Agentforce Vibes, compatible with all AI tools. The licence is Apache-2.0.

When your agent uses it

  • The user runs Apex tests
  • Checks code coverage
  • Fixes failing tests
  • Touches Test.cls / Test.cls files

Example prompts

  • “/platform-apex-test-run”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Discover test scope
  2. Run the smallest useful test set first
  3. Analyze results
  4. Run a disciplined fix loop
  5. Improve coverage intentionally

What it can do on your machine

Read from SKILL.md and the folder at commit e5164d9. 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

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • sf

    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

Platform Apex Test Run loads about 1.9k tokens when it runs, and up to ~14k if it reads all its reference files. Until then it costs about 100 tokens; SKILL.md has 751 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~100
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~14k

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); the scripts in this folder are not scanned.

SKILL.md

The full file from forcedotcom/sf-skills at commit e5164d9, republished under its Apache-2.0 licence (© forcedotcom). 751 words, ~1,876 tokens.

Download SKILL.mdSave it as .claude/skills/platform-apex-test-run/SKILL.md (or your agent's skills folder). This skill also uses 14 other files; get the full folder from GitHub.
name
platform-apex-test-run
description
Apex test execution, coverage analysis, and test-fix loops with 120-point scoring. Use when the user runs Apex tests, checks code coverage, fixes failing tests, or touches *Test.cls / *_Test.cls files. DO NOT TRIGGER when writing Apex production code (use platform-apex-generate), Agentforce agent testing (use agentforce-test), or Jest/LWC tests (use experience-lwc-generate).
metadata.version
1.2
metadata.domains
Platform
metadata.relatedSkills
agentforce-test, experience-lwc-generate, platform-apex-generate, platform-apex-logs-debug, platform-data-manage, platform-metadata-deploy

platform-apex-test-run: Salesforce Test Execution & Coverage Analysis

Use this skill when the user needs Apex test execution and failure analysis: running tests, checking coverage, interpreting failures, improving coverage, and managing a disciplined test-fix loop for Salesforce code.

When This Skill Owns the Task

Use platform-apex-test-run when the work involves:

  • sf apex run test workflows
  • Apex unit-test failures
  • code coverage analysis
  • identifying uncovered lines and missing test scenarios
  • structured test-fix loops for Apex code

Delegate elsewhere when the user is:

  • writing or refactoring production Apex → platform-apex-generate skill
  • testing Agentforce agents → agentforce-test skill
  • testing LWC with Jest → experience-lwc-generate

Required Context to Gather First

Ask for or infer:

  • target org alias
  • desired test scope: single class, specific methods, suite, or local tests
  • coverage threshold expectation
  • whether the user wants diagnosis only or a test-fix loop
  • whether related test data factories already exist

1. Discover test scope

Identify:

  • existing test classes
  • target production classes
  • test data factories / setup helpers
2. Run the smallest useful test set first

Start narrow when debugging a failure; widen only after the fix is stable.

3. Analyze results

Focus on:

  • failing methods
  • exception types and stack traces
  • uncovered lines / weak coverage areas
  • whether failures indicate bad test data, brittle assertions, or broken production logic
4. Run a disciplined fix loop

When the issue is code or test quality:

  • delegate code fixes to platform-apex-generate skill when needed
  • add or improve tests
  • rerun focused tests before broader regression
5. Improve coverage intentionally

Cover:

  • positive path
  • negative / exception path
  • bulk path (251+ records where appropriate)
  • callout or async path when relevant

High-Signal Rules

RuleRationale
Default to SeeAllData=falseEnsures test isolation; prevents reliance on org-specific data
Every test must assert meaningful outcomesTests with no assertions prove nothing and give false confidence
Test bulk behavior with 251+ recordsTriggers process in batches of 200; 251 records crosses the boundary
Use factories / @TestSetup when they improve clarityConsistent data creation in one place; rolled back between test methods
Pair Test.startTest() with Test.stopTest() for asyncEnsures async operations (queueable, future) complete before assertions
Do not hide flaky org dependencies inside testsPrevents intermittent failures tied to org state

Gotchas

IssueResolution
Test passes locally but fails in CI orgCheck for SeeAllData=true or undeclared dependencies on org-specific records
Coverage drops unexpectedly after refactorRun focused class-level tests first, then widen to RunLocalTests to confirm
"Uncommitted work pending" error in callout testDML and HTTP callouts cannot be mixed in the same test context without Test.startTest() wrapping
Mock not taking effect in testEnsure Test.setMock() is called before the code that makes the callout
@TestSetup data missing in test method@TestSetup data is committed per test method — re-query it; do not store in static variables
API version 67.0 and higher without necessary access level checksCheck failing SOQL/DML stack traces for CRUD/FLS access errors, using System.runAs with an assigned permission set when user-mode behavior is intended, or documenting a justified SYSTEM_MODE path when system access is required

Show full SKILL.md (258 more words)Show less

Output Format

When finishing, report in this order:

  1. What tests were run
  2. Pass/fail summary
  3. Coverage result
  4. Root-cause findings
  5. Fix or next-run recommendation

Suggested shape:

text
Test run: <scope>
Org: <alias>
Result: <passed / partial / failed>
Coverage: <percent / key classes>
Issues: <highest-signal failures>
Next step: <fix class, add test, rerun scope, or widen regression>

Cross-Skill Integration

NeedDelegate toReason
Fix production code or author test classesplatform-apex-generate skillCode generation and repair
Create bulk / edge-case test dataplatform-data-manageRealistic test datasets
Deploy updated tests to orgplatform-metadata-deployDeployment workflows
Inspect detailed runtime logsplatform-apex-logs-debugDeeper failure analysis

Reference File Index

FileWhen to read
references/cli-commands.mdAll sf apex run test command flags, output formats, async execution, and coverage commands
references/test-patterns.mdTest class templates — basic, bulk (251+), mock callout, and data factory patterns
references/testing-best-practices.mdCore testing principles — AAA pattern, naming conventions, bulk, negative, and mock strategies
references/test-fix-loop.mdAgentic test-fix loop implementation and failure analysis decision tree
references/mocking-patterns.mdHttpCalloutMock, DML mocking, StubProvider, and selector mocking patterns
references/performance-optimization.mdTechniques to reduce test execution time — DML mocking, SOQL mocking, loop optimizations
assets/basic-test.clsTemplate: standard test class with @TestSetup, positive / negative / bulk / edge-case methods
assets/bulk-test.clsTemplate: bulk test with 251+ records that crosses the 200-record trigger batch boundary
assets/mock-callout-test.clsTemplate: HTTP callout mock using HttpCalloutMock
assets/test-data-factory.clsTemplate: reusable TestDataFactory with create and insert helpers
assets/dml-mock.clsTemplate: IDML interface + DMLMock implementation for database-free unit tests
assets/stub-provider-example.clsTemplate: StubProvider-based dependency injection stub
scripts/parse-test-results.pyPost-tool hook — parses sf apex run test JSON output and formats failures for the auto-fix loop

Score Guide

ScoreMeaning
108+strong production-grade test confidence
96–107good test suite with minor gaps
84–95acceptable but strengthen coverage / assertions
< 84below standard; revise before relying on it

© forcedotcom, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 14 other files (scripts, references, assets) in skills/platform-apex-test-run of forcedotcom/sf-skills.

  • SKILL.md
  • README.md
  • assets/basic-test.cls
  • assets/bulk-test.cls
  • assets/dml-mock.cls
  • assets/mock-callout-test.cls
  • assets/stub-provider-example.cls
  • assets/test-data-factory.cls
  • references/cli-commands.md
  • references/mocking-patterns.md
  • references/performance-optimization.md
  • references/test-fix-loop.md
  • references/test-patterns.md
  • references/testing-best-practices.md
  • scripts/parse-test-results.py

Open the folder on GitHubat commit e5164d9

Compare with similar skills

Platform Apex Test Run 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.

Platform Apex Test Run compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Platform Apex Test Run this skillforcedotcom/sf-skills1.1k—~1.9kAutomated safety check: PassApache-2.0
Sf TestingJaganpro/sf-skills424—~1.1kAutomated safety check: PassMIT
Test Guidelinesgetsentry/sentry-react-native1.8k—~1.3kAutomated safety check: PassMIT
Designing TestsCloudAI-X/claude-workflow-v21.4k1 repos~1.5kAutomated safety check: PassMIT
Caliber Testingcaliber-ai-org/ai-setup1.3k—~3.2kAutomated safety check: PassMIT
Write Testsgrafana/synthetic-monitoring-app171—~1.2kAutomated safety check: PassAGPL-3.0

Similar skills

  • Sf Testing

    Jaganpro/sf-skills

    Apex test execution, coverage analysis, and test-fix loops with 120-point scoring.

    424 GitHub stars~1.1k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed
  • Test Guidelines

    getsentry/sentry-react-native

    Official

    Enforce Sentry React Native SDK test conventions for naming, structure, mocking, and fixtures with Jest.

    1.8k GitHub stars~1.3k tokensUpdated today
    Testing & QAAuto-check passed
  • Designing Tests

    CloudAI-X/claude-workflow-v2

    Designs and implements testing strategies for any codebase. An agent skill from CloudAI-X/claude-workflow-v2.

    1.4k GitHub starsUsed in 1 repo~1.5k tokens
    Testing & QAAuto-check passed
  • Caliber Testing

    caliber-ai-org/ai-setup

    Writes Vitest tests following project patterns: tests/ directories, vi.mock() for module mocking with vi.hoisted() for test-time factories, global LLM mock from src/test/setup.ts, environment…

    1.3k GitHub stars~3.2k tokensUpdated 14 days ago
    Testing & QAAuto-check passed
  • Write Tests

    grafana/synthetic-monitoring-app

    Official

    Write Jest integration and unit tests for the Grafana Synthetic Monitoring app using React Testing Library, MSW, and src/test helpers.

    171 GitHub stars~1.2k tokensUpdated today
    Testing & QAAuto-check passed
  • Playwright Testing

    chongdashu/vibejam-starter-pack

    Plan, implement, and debug frontend tests: unit/integration/E2E/visual/a11y.

    149 GitHub stars~2.1k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed

More from forcedotcom/sf-skills

All 251 skills in this repo
  • Agentforce Architecture Analyze

    forcedotcom/sf-skills

    Declared architecture snapshot for one Agentforce agent: planner, topics, actions, flows, Apex, prompt templates, and NGA plugins.

    1.1k GitHub stars~4.5k tokensUpdated yesterday
    Auto-check passed
  • Agentforce D360 Analyze

    forcedotcom/sf-skills

    Data Cloud 360° view of a single Agentforce session. An agent skill from forcedotcom/sf-skills.

    1.1k GitHub stars~3.4k tokensUpdated yesterday
    Auto-check passed
  • Apply a Salesforce sandbox post-copy automation JSON config against a target org.

    1.1k GitHub stars~5.3k tokensUpdated yesterday
    Auto-check: notes
  • Apply a Salesforce sandbox post-copy automation JSON config against a target org.

    1.1k GitHub stars~5.4k tokensUpdated yesterday
    Auto-check: notes
  • Design Systems Slds Apply

    forcedotcom/sf-skills

    Apply SLDS-compliant UI using the correct blueprints, styling hooks, utility classes, and icons.

    1.1k GitHub stars~3.7k tokensUpdated yesterday
    Auto-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 yesterday
    Auto-check passed

Works with

Categories

Questions about Platform Apex Test Run

What does Platform Apex Test Run do?

Apex test execution, coverage analysis, and test-fix loops with 120-point scoring. Platform Apex Test Run is an agent skill from forcedotcom/sf-skills. Apex test execution, coverage analysis, and test-fix loops with 120-point scoring.

When should I use Platform Apex Test Run?

Platform Apex Test Run fits situations like: the user runs Apex tests; checks code coverage; fixes failing tests; touches Test.cls / Test.cls files.

How do I install Platform Apex Test Run in Claude Code?

Run `npx skills add forcedotcom/sf-skills --skill platform-apex-test-run -a claude-code`. Or copy the skill folder (skills/platform-apex-test-run in forcedotcom/sf-skills) into .claude/skills/platform-apex-test-run in your project. Claude Code loads it when a task matches its description.

How do I install Platform Apex Test Run in Codex?

Run `npx skills add forcedotcom/sf-skills --skill platform-apex-test-run -a codex`. Or copy the skill folder (skills/platform-apex-test-run in forcedotcom/sf-skills) into .agents/skills/platform-apex-test-run in your project. Codex loads it when a task matches its description.

Can I use Platform Apex Test Run 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 forcedotcom/sf-skills --skill platform-apex-test-run -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/platform-apex-test-run, .gemini/skills/platform-apex-test-run, .github/skills/platform-apex-test-run and .opencode/skills/platform-apex-test-run in your project.

What does Platform Apex Test Run need to run?

Going by SKILL.md and its folder, Platform Apex Test Run needs Python for the scripts in its folder and the command-line tools its instructions call (sf). Our summary lists: Python 3.

Does Platform Apex Test Run 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 Platform Apex Test Run 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. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Platform Apex Test Run use?

Platform Apex Test Run is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Platform Apex Test Run use?

About 1.9k tokens (SKILL.md is roughly 7.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 12k tokens, read only when the agent opens those files.

What are the alternatives to Platform Apex Test Run?

Skills that share tags, products or a category with Platform Apex Test Run: Sf Testing (Jaganpro/sf-skills, 424 stars), Test Guidelines (getsentry/sentry-react-native, 1.8k stars), Designing Tests (CloudAI-X/claude-workflow-v2, 1.4k stars) and Caliber Testing (caliber-ai-org/ai-setup, 1.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Platform Apex Test Run?

forcedotcom (a GitHub organization) maintains it in forcedotcom/sf-skills, which has 1,060 GitHub stars. The repository holds 251 skills in this directory. The repository was last updated on October 7, 2026.

Source: forcedotcom/sf-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.