Help us improve
Share bugs, ideas, or general feedback.
From vanguard-frontier-agentic
Executes Apex tests against a connected sandbox org, parses results and coverage delta, identifies failures with stack traces, and suggests fixes.
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-apex-test-runner-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
T1 read-only runtime skill for Apex test execution against a connected **sandbox** org.
Runs Apex tests, analyzes coverage, and manages test-fix loops with 120-point scoring for Salesforce development.
Validates Salesforce deployment packages against sandbox orgs via dry-run, surfacing deployment issues, test failures, and metadata dependency problems without committing changes. Refuses production targets.
Set up Salesforce CI/CD pipelines with GitHub Actions, SFDX deployments, JWT auth, and Apex testing. For automating metadata validation and tests in Salesforce repos.
Share bugs, ideas, or general feedback.
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.
Use salesforce-apex-test-runner-skill when the work requires live test execution:
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 |
Before running any tests, confirm:
--target-org value from sf org list. Never accept a raw
instance URL or session token.RunLocalTests, RunAllTestsInOrg, RunSpecifiedTests).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.
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.
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
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
From the JSON output, extract:
methodName, message, stackTraceConsult references/failure-diagnosis.md for common patterns:
DML in @TestSetup restrictionsCalloutException — missing mockQueryException — data isolation issue (SeeAllData mis-use)Test.startTest / Test.stopTestApply redaction rules (see Redaction Rules section) before emitting any output. Emit the full audit envelope regardless of pass/fail outcome.
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.
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:
--code-coverage was available: -20This skill operates at T1 — read-only runtime (sandbox only).
api and refresh_token only. No full, web, sfap_api, or other scopes.View Setup and Configuration, View All Data (sandbox service account only)ModifyAllData, ViewEncryptedData, ModifyMetadata, AuthorApex, ManageConnectedAppssf apex run test command requires the View All Data
system 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.sf apex command.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.
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>"
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>"
Apply in order before emitting any output:
00D): Replace with <org_id_placeholder>.<record_id_placeholder> in output.<user_id_placeholder>.| 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 and do not continue if:
sf org display output — stop, request clarification.View Setup and Configuration — stop and escalate to org administrator.View All Data system permission required by
sf apex run test must exist only on the sandbox-only Run As service account. Separation from
any production-eligible account is mandatory.| 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 |