sf-tdd-workflow

Guide Salesforce Apex, LWC, triggers, and Flows through RED-GREEN-REFACTOR with CI coverage checks.

13|2|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/jiten-singh-shahi/salesforce-claude-code --skill sf-tdd-workflow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sf-tdd-workflow
Source: https://github.com/jiten-singh-shahi/salesforce-claude-code/tree/main/.cursor/skills/sf-tdd-workflow
Command: npx skills add https://github.com/jiten-singh-shahi/salesforce-claude-code --skill sf-tdd-workflow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a practical, Salesforce-focused test-driven development workflow that reduces regressions and deployment failures by guiding developers through the RED-GREEN-REFACTOR cycle for Apex classes, triggers, LWC Jest tests, async jobs, batch jobs, and Flows.

Core Features & Use Cases

  • RED-GREEN-REFACTOR Guidance: Step-by-step instructions to write compiling failing tests, implement the minimum code to pass, and refactor safely.
  • Platform Patterns: Trigger-first handler stubs, Queueable and Batch TDD patterns, Flow test triggers, and LWC Jest examples for front-end components.
  • CI and Coverage Integration: Advice for running tests in CI, interpreting test-run artifacts, and enforcing coverage thresholds and guardrails during pull requests.
  • Use Cases: Start a new Apex service with tests-first TDD, add tests and safety nets when refactoring legacy code, and validate async processing and bulk behavior before deployment.

Quick Start

Ask the assistant to run a RED-GREEN-REFACTOR session for a new Apex AccountService class by producing failing tests first, a minimal implementation to make them pass, and a refactor checklist.

Frequently Asked Questions about sf-tdd-workflow

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I start test-driven development for Salesforce Apex classes?

Salesforce Apex test-driven development begins with writing compiling but failing tests, implementing minimal code to pass them, and refactoring for bulk and async safety. This RED-GREEN-REFACTOR cycle reduces regressions before deploying Apex classes.

Can I apply TDD to Salesforce Queueable and Batch Apex jobs?

Yes, TDD supports Queueable and Batch async patterns in Salesforce. You write failing tests for async job execution first, implement minimal passing code, then refactor while validating bulk behavior and coverage thresholds before CI integration.

What is the best way to test Salesforce Flows using TDD?

Testing Salesforce Flows with TDD involves writing Flow test triggers that fail initially, implementing the Flow logic to pass tests, and refactoring safely. This ensures Flow behavior is validated before deployment through CI pipelines.

How do I enforce a 75% minimum Apex test coverage threshold in CI pipelines?

Apex test coverage thresholds are enforced in CI pipelines by running tests, interpreting test-run artifacts, and setting guardrails that block pull requests failing to meet the 75% minimum coverage requirement for Salesforce deployments.

Does TDD work with Salesforce LWC Jest tests?

Yes, TDD integrates with LWC Jest tests by providing examples for front-end components. You write failing Jest tests first, implement minimal Lightning Web Component code to pass, and refactor safely within the Salesforce development workflow.

Why should I write failing tests before implementing Apex trigger handlers?

Writing failing tests before Apex trigger handler implementation ensures the test validates expected behavior rather than matching existing code. This trigger-first TDD approach catches regressions early and supports safe refactoring of legacy Salesforce code.