VincentChuWaiChow/vanguard-frontier-agentic/skills/salesforce/salesforce-apex-test-runner-skill/SKILL.md
salesforce-apex-test-runner-skill
Executes Apex tests against a connected SANDBOX org via sf apex run test, parses results and coverage delta, identifies failures with stack traces, and suggests fixes. T1 read-only runtime (sandbox-only). Production org targets are HARD REFUSED before any API call. TRIGGER when: user wants to run Apex tests, execute a test class, check test coverage, diagnose test failures, or validate coverage before deployment. Trigger phrases: run apex tests, execute test class, test my changes, check test co
- Source repository stars
- 21
- Declared platforms
- 0
- Static risk flags
- 1
- Last source update
- 2026-08-24
- Source checked
- 2026-08-25
Decision brief
What it does: where it fits
T1 read-only runtime skill for Apex test execution against a connected sandbox org. This skill runs tests, reads coverage, and diagnoses failures — it does not write code, deploy metadata, or touch production orgs. The View All Data permission is required by sf apex run test per…
Not for
- Tasks that require unconfirmed production actions or broad system permissions.
- Environments where the pinned source and install steps cannot be inspected.
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/VincentChuWaiChow/vanguard-frontier-agentic --skill "skills/salesforce/salesforce-apex-test-runner-skill"Inspect the Agent Skill "salesforce-apex-test-runner-skill" from https://github.com/VincentChuWaiChow/vanguard-frontier-agentic/blob/5e32c1f3b9ba9e9bacae9687f55bed35b5def90f/skills/salesforce/salesforce-apex-test-runner-skill/SKILL.md at commit 5e32c1f3b9ba9e9bacae9687f55bed35b5def90f. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
Recommended Workflow
Parse output for instanceUrl and check for sandbox indicators in the domain (.sandbox., .cs, .scratch., .scratch.salesforce.com). If instanceUrl contains login.salesforce.com or .my.salesforce.com without sandbox indicators, treat as production and stop.
Pass count / fail count / skip countOverall code coverage percentage (target: = 75%)Per-class coverage — identify classes below threshold - 02
Step 1 — Verify org alias and type
Parse output for instanceUrl and check for sandbox indicators in the domain (.sandbox., .cs, .scratch., .scratch.salesforce.com). If instanceUrl contains login.salesforce.com or .my.salesforce.com without sandbox indicators, treat as production and stop.
Parse output for instanceUrl and check for sandbox indicators in the domain (.sandbox., .cs, .scratch., .scratch.salesforce.com). If instanceUrl contains login.salesforce.com or .my.salesforce.com without sandbox indica… - 03
Step 2 — Confirm Connected App allowlist
The Connected App used by the Run As service account must have the target org alias explicitly in its allowlist. If the allowlist cannot be confirmed, stop and request the Connected App administrator verify the configuration.
The Connected App used by the Run As service account must have the target org alias explicitly in its allowlist. If the allowlist cannot be confirmed, stop and request the Connected App administrator verify the configur… - 04
Step 3 — Run the targeted test set
For broader coverage checks:
For broader coverage checks: - 05
Step 4 — Retrieve results if async
If the run was async (no --wait or timeout exceeded):
If the run was async (no --wait or timeout exceeded):
Permission review
Static risk signals and limitations
Runs scripts
The documentation asks the agent to run terminal commands or scripts.
**View All Data — important note:** The `sf apex run test` command requires the `View All Data`Evidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 96/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 21 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- VincentChuWaiChow/vanguard-frontier-agentic
- Skill path
- skills/salesforce/salesforce-apex-test-runner-skill/SKILL.md
- Commit
- 5e32c1f3b9ba9e9bacae9687f55bed35b5def90f
- License
- Apache-2.0
- Collected
- 2026-08-25
- Default branch
- master
View the original SKILL.md
salesforce-apex-test-runner-skill
T1 read-only runtime skill for Apex test execution against a connected sandbox org.
This skill runs tests, reads coverage, and diagnoses failures — it does not write code,
deploy metadata, or touch production orgs. The View All Data permission is required
by sf apex run test per Salesforce platform behavior; this permission must be granted
only on the sandbox-only service account and NEVER on a production-eligible account.
When This Skill Owns the Task
Use salesforce-apex-test-runner-skill when the work requires live test execution:
- "Run the AccountServiceTest class in my sandbox"
- "Execute all local tests before deployment"
- "My test is failing with a governor limit error — run it and show me the stack trace"
- "Check code coverage for the Order trigger after my last change"
- "Run specific test methods: AccountServiceTest.testBulkSuccess"
Delegate elsewhere when:
| Situation | Skill to use |
|---|---|
| User needs test classes authored | salesforce-apex-test-generator-skill |
| User needs production Apex authored | salesforce-apex-generator-skill |
| Debug log analysis without running | salesforce-apex-log-analyzer-skill |
| Static code review of test code | salesforce-apex-lwc-code-review-skill |
| Sandbox deploy and validate | salesforce-deployment-validator-skill |
Required Context to Gather First
Before running any tests, confirm:
- Target org alias — the
--target-orgvalue fromsf org list. Never accept a raw instance URL or session token. - Org type — must be sandbox. If production, stop immediately (see HARD REFUSAL).
- Test scope — specific class names, specific method names, or test level
(
RunLocalTests,RunAllTestsInOrg,RunSpecifiedTests). - Coverage threshold — default 75% per Salesforce deployment requirement; note if higher.
- Goal — diagnosis only, or diagnosis + fix loop?
Recommended Workflow
Step 1 — Verify org alias and type
sf org display --target-org <alias>
Parse output for instanceUrl and check for sandbox indicators in the domain
(.sandbox., .cs, .scratch., .scratch.salesforce.com). If instanceUrl contains
login.salesforce.com or <companyname>.my.salesforce.com without sandbox indicators,
treat as production and stop.
Step 2 — Confirm Connected App allowlist
The Connected App used by the Run As service account must have the target org alias explicitly in its allowlist. If the allowlist cannot be confirmed, stop and request the Connected App administrator verify the configuration.
Step 3 — Run the targeted test set
sf apex run test \
--test-level RunSpecifiedTests \
--tests <TestClassName1> <TestClassName2> \
--target-org <alias> \
--result-format json \
--wait 10
For broader coverage checks:
sf apex run test \
--test-level RunLocalTests \
--target-org <alias> \
--result-format json \
--wait 30 \
--code-coverage
Step 4 — Retrieve results if async
If the run was async (no --wait or timeout exceeded):
sf apex get test \
--test-run-id <id> \
--target-org <alias> \
--result-format json \
--code-coverage
Step 5 — Parse results
From the JSON output, extract:
- Pass count / fail count / skip count
- Overall code coverage percentage (target: >= 75%)
- Per-class coverage — identify classes below threshold
- Failing test methods — extract
methodName,message,stackTrace - Governor limit hits — scan message for "Limit" patterns
Step 6 — Diagnose failures
Consult references/failure-diagnosis.md for common patterns:
DML in @TestSetuprestrictions- Governor limit errors in test context
CalloutException— missing mockQueryException— data isolation issue (SeeAllData mis-use)- Async result not visible — missing
Test.startTest/Test.stopTest
Step 7 — Emit sanitized results with audit envelope
Apply redaction rules (see Redaction Rules section) before emitting any output. Emit the full audit envelope regardless of pass/fail outcome.
Step 8 — Recommend next steps
If failures found: recommend salesforce-apex-test-generator-skill for test corrections
or salesforce-apex-log-analyzer-skill for deeper log analysis.
If coverage below threshold: identify which classes are uncovered and recommend targeted
test generation.
Quality Scoring Rubric (100-point)
Score the test run and analysis before presenting. Threshold: 80+ acceptable.
| Dimension | Points | What earns full marks |
|---|---|---|
| Test selection appropriateness | 25 | Scope matches the user's goal; RunSpecifiedTests used for targeted runs; RunLocalTests for pre-deploy coverage |
| Sandbox-only enforcement | 25 | CRITICAL gate — org type verified as sandbox before any API call; HARD REFUSAL triggered for production targets |
| Coverage analysis | 20 | Coverage percentage computed and compared to 75% threshold; per-class breakdown provided; uncovered classes named |
| Failure diagnosis quality | 20 | Failures categorized by type; stack trace excerpted; remediation suggested from failure-diagnosis reference |
| Audit envelope | 10 | All required audit fields present; timestamp accurate; org type verified field populated |
Scoring penalties:
- Sandbox check skipped: score voided (immediate HARD REFUSAL required)
- No coverage analysis when
--code-coveragewas available: -20 - Failures reported without diagnosis: -15
- Missing audit envelope: -15 (automatic caveat regardless of total)
- Org type not verified before execution: -25
T1 Least-Privilege Contract
This skill operates at T1 — read-only runtime (sandbox only).
- OAuth scopes:
apiandrefresh_tokenonly. Nofull,web,sfap_api, or other scopes. - Run As account permissions:
- REQUIRED:
View Setup and Configuration,View All Data(sandbox service account only) - DENIED:
ModifyAllData,ViewEncryptedData,ModifyMetadata,AuthorApex,ManageConnectedApps
- REQUIRED:
- View All Data — important note: The
sf apex run testcommand requires theView All Datasystem permission for the running user per Salesforce platform behavior. This is why the Run As service account for this skill must be a sandbox-only account. This permission must NEVER be granted on an account used for production org access. - No code mutation: This skill reads test results and coverage data. It does not write, deploy, modify metadata, or create records outside of test context.
- Org allowlist: Connected App enforces which aliases are reachable. Skill verifies org
type before executing any
sf apexcommand.
HARD REFUSAL — Production Org Targets
If the target org is identified as production, stop immediately and do not execute any
sf apex command.
Production refusal response:
HARD REFUSAL: Apex test execution is not permitted on production orgs via this skill.
Reason: salesforce-apex-test-runner-skill operates at T1 sandbox-only scope. The
View All Data system permission required by sf apex run test must never be granted
on a production-eligible service account. Production Apex test runs also carry risk
of long-running test locks affecting live users.
Action required:
1. Identify a sandbox org alias for this test run.
2. Verify the Connected App allowlist includes the sandbox alias.
3. Re-invoke this skill with the sandbox alias.
If a production test run is genuinely required (e.g., for a post-deployment verification),
route through the human approval path via salesforce-live-guard-agent.
Audit Envelope Schema
Every execution emits an audit envelope. Emit even on HARD REFUSAL.
audit_envelope:
matter_id: "<caller-provided-or-generated-uuid>"
skill_id: "salesforce-apex-test-runner-skill"
skill_version: "0.1.0"
target_org_alias: "<alias>"
run_as_user_id: "<user_id_placeholder>"
org_type_verified: "sandbox | production | unknown"
test_run_id: "<sf-apex-run-test-id or 'refused'>"
test_level: "<RunSpecifiedTests | RunLocalTests | RunAllTestsInOrg | refused>"
tests_requested: ["<ClassName.methodName or ClassName>"]
pass_count: <integer>
fail_count: <integer>
skip_count: <integer>
overall_coverage_pct: <float or null>
timestamp: "<ISO-8601-UTC>"
refusal_reason: "<reason if refused | null>"
Output Format
verdict: "pass | fail | refused"
quality_score: <0-100>
quality_notes: "<scoring rationale>"
test_summary:
org_alias: "<alias>"
org_type: "sandbox | production | unknown"
test_level: "<level used>"
pass_count: <integer>
fail_count: <integer>
skip_count: <integer>
overall_coverage_pct: <float>
coverage_threshold_met: true | false
failing_tests:
- test: "<ClassName.methodName>"
message: "<error message>"
stack_trace_excerpt: "<first 3-5 lines>"
diagnosis: "<category from failure-diagnosis.md>"
suggested_fix: "<specific remediation>"
coverage_gaps:
- class: "<ClassName>"
coverage_pct: <float>
suggested_action: "<add tests for X method>"
audit_envelope:
<see Audit Envelope Schema>
next_steps:
- "<if failures: salesforce-apex-test-generator-skill for test fixes>"
- "<if coverage gaps: salesforce-apex-test-generator-skill for additional tests>"
- "<if ready: salesforce-deployment-validator-skill for sandbox deploy>"
assumptions:
- "<explicit list>"
Redaction Rules
Apply in order before emitting any output:
- OAuth tokens, refresh tokens, session IDs: Never include in any output. Strip from CLI output.
- Salesforce Org IDs (18-char starting with
00D): Replace with<org_id_placeholder>. - Salesforce Record IDs (15/18-char): Replace with
<record_id_placeholder>in output. - User IDs (OwnerId, CreatedById, RunningUserId, User.Id): Replace with
<user_id_placeholder>. - Test run IDs: Retain in audit envelope (non-sensitive); redact from narrative output.
- Stack trace class names and line numbers: Retain — needed for diagnosis. Do not redact.
- Exception messages: Retain — needed for diagnosis. If message contains a Salesforce ID, replace the ID but retain the rest of the message.
- Instance URLs and API endpoints: Omit from output; reference only the org alias.
Handoff Rules
| Finding | Hand off to |
|---|---|
| Test failures needing code fixes | salesforce-apex-test-generator-skill |
| Coverage gaps needing new test methods | salesforce-apex-test-generator-skill |
| Log-level failure requiring debug analysis | salesforce-apex-log-analyzer-skill |
| All tests pass with coverage met | salesforce-deployment-validator-skill |
| Production target attempted | salesforce-live-guard-agent (human approval path) |
Stop Conditions
Stop and do not continue if:
- Org type cannot be determined from
sf org displayoutput — stop, request clarification. - Org type is production — HARD REFUSAL (see above), stop.
- The Run As account is missing
View Setup and Configuration— stop and escalate to org administrator. - The audit envelope cannot be populated (missing matter_id, org alias unresolvable) — stop.
- The user requests redaction to be skipped — stop and explain the policy.
Security Notes
- Sandbox-only: Production org targets are hard-refused before any API call. The Connected App allowlist enforces this at the platform level as a second control.
- View All Data — sandbox-only account: The
View All Datasystem permission required bysf apex run testmust exist only on the sandbox-only Run As service account. Separation from any production-eligible account is mandatory. - Read-only runtime: No DML, no metadata mutation, no code deployment, no record creation outside Apex test context (which is isolated and rolled back by the platform).
- Sanitized output: All Salesforce IDs, user IDs, and OAuth tokens redacted before emission.
- Structured audit: Every execution produces a complete audit envelope, including refusals.
- Revocable: Rotating the Run As sandbox account's refresh token immediately revokes all access.
Reference File Index
| File | When to read |
|---|---|
references/cli-commands.md | sf apex run test variants, --test-level options, --result-format, --wait, async retrieval |
references/coverage-analysis.md | Coverage percentage interpretation, 75% requirement, line vs branch coverage, per-class gap analysis |
references/failure-diagnosis.md | Common Apex test failure patterns: DML on setup, governor limits, callouts in tests, async test gotchas |
Frequently asked questions
What to verify before installation and use
What does the salesforce-apex-test-runner-skill source document cover?
T1 read-only runtime skill for Apex test execution against a connected sandbox org. This skill runs tests, reads coverage, and diagnoses failures — it does not write code, deploy metadata, or touch production orgs. The View All Data permission is required by sf apex run test per…
How do I install salesforce-apex-test-runner-skill?
The source record exposes this install command: npx skills add https://github.com/VincentChuWaiChow/vanguard-frontier-agentic --skill "skills/salesforce/salesforce-apex-test-runner-skill". Inspect the command and pinned source before running it.
Which permission-related actions were detected?
Static rules flagged exec-script in the source; the page lists the matching lines and excerpts.
Alternatives
Compare before choosing
ZaxbyHub/opencode-swarm
commit-pr
Apply when committing, pushing, opening or updating a PR, writing a pull request, creating release notes, or closing out remote CI. Enforces the opencode-swarm invariant audit, release-note fragment workflow, full validation suite, issue comment requirement, and post-PR lifecycle rules.
johnqtcg/awesome-skills
go-code-reviewer
Review Go code with a defect-first approach using repository policy (constitution.md first, then AGENTS.md fallback). Use for code review, PR review, quality checks, risk analysis, and regression detection.
oaslananka/kicad-mcp-pro
code-review
Use this skill for GitHub Copilot pull request and code reviews in oaslananka/kicad-mcp-pro. Review Python MCP server changes, KiCad adapter and tool-contract changes, tests, npm/package wrappers, Tauri/Rust desktop code, GitHub Actions, security controls, documentation, generated metadata, and compatibility/release surfaces. Use it whenever reviewing a PR or diff in this repository, especially changes under src/, tests/, packages/, src-tauri/, .github/workflows/, or public MCP metadata/configur
vasilyu1983/AI-Agents-public
qa-testing-ios
Guides iOS testing with XCTest, XCUITest, Swift Testing, simctl, and xcresult. Use when choosing destinations, controlling flakes, or parsing test artifacts for native apps.