This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A Salesforce DX project demonstrating enterprise architecture patterns (fflib) with two functional packages: a GitHub Actions integration service that dispatches repository events from Salesforce, and a weather dashboard app that fetches/stores weather data via OpenWeatherMap API.
# Deploy all source to a scratch org
sf project deploy start --target-org <alias>
# Create a scratch org
sf org create scratch -f config/project-scratch-def.json -a <alias> --set-default
# Run all Apex tests
sf apex run test --target-org <alias> --wait 10 --code-coverage
# Run LWC unit tests
npm test # runs sfdx-lwc-jest
npm run test:unit:coverage # with coverage
# Lint and format
npm run lint # ESLint for LWC/Aura JS
npm run prettier # format all files (Apex, XML, LWC HTML, JS, JSON)
npm run prettier:verify # check formatting without writing| Package | Default | Contents |
|---|---|---|
apex-mocks/ |
no | fflib_ApexMocks test framework (vendored) |
apex-common/ |
no | fflib core framework: Application factory, SObjectDomain, SObjectSelector, SObjectUnitOfWork, QueryFactory (vendored) |
github-action-service/ |
yes | GitHub integration: GitHubDispatchService, GitHubAppAuthService, event classes (DataSyncEvent, DeploymentEvent, TestResultEvent), gitHubActionTrigger LWC, Named Credentials, GitHub_App_Settings__mdt custom metadata |
weather-app/ |
no | Weather demo: Application.cls factory, IWeatherService/WeatherServiceImpl, WeatherReportsSelector, WeatherReports domain, WeatherDashboardController, weatherDashboard LWC, Weather_Report__c custom object |
All business logic in weather-app follows the fflib Apex Enterprise Patterns. The central wiring point is weather-app/main/default/classes/Application.cls.
Application Factory (Application.cls) registers four factories:
Application.UnitOfWork-- wraps DML; callApplication.UnitOfWork.newInstance(), thenregisterNew/registerDirty/registerDeleted, thencommitWork()Application.Service-- mapsIWeatherService.class => WeatherServiceImpl.class; obtain via(IWeatherService) Application.Service.newInstance(IWeatherService.class)Application.Selector-- mapsWeather_Report__c.SObjectType => WeatherReportsSelector.classApplication.Domain-- mapsWeather_Report__c.SObjectType => WeatherReports.Constructor.class
Layer responsibilities:
- Service (
IWeatherService/WeatherServiceImpl): orchestrates business operations, calls selectors for queries and UoW for DML - Selector (
WeatherReportsSelector extends fflib_SObjectSelector): all SOQL viafflib_QueryFactory; providesnewInstance()static factory method - Domain (
WeatherReports extends fflib_SObjectDomain): trigger logic, field validation, in-memory filtering; uses innerConstructorclass implementingfflib_SObjectDomain.IConstructable - Controller (
WeatherDashboardController): thin@AuraEnabledmethods that delegate to Service/Selector; no direct SOQL or DML
When adding a new SObject, register it in all four factory maps in Application.cls.
Apex tests use fflib_ApexMocks for mocking:
- Mock services:
Application.Service.setMock(IWeatherService.class, mockService) - Mock UoW:
Application.UnitOfWork.setMock(mockUow)to avoid real DML - Mock selectors:
Application.Selector.setMock(mockSelector)
LWC tests use @salesforce/sfdx-lwc-jest:
- Place test files adjacent to components as
<component>.test.js lint-stagedautomatically runs related LWC tests on commit
Prettier (.prettierrc): uses prettier-plugin-apex for .cls/.trigger and @prettier/plugin-xml for XML metadata. LWC HTML uses the lwc parser. trailingComma: "none".
Husky + lint-staged: pre-commit hook runs Prettier on all supported files, ESLint on LWC/Aura JS, and sfdx-lwc-jest --findRelatedTests on changed LWC files.
- API Version: 65.0 (
sourceApiVersioninsfdx-project.json) - Scratch Org Edition: Developer (
config/project-scratch-def.json)
- Custom objects:
Snake_Case__c(e.g.,Weather_Report__c) - Custom fields:
Snake_Case__c(e.g.,City__c,Report_Date_Time__c) - Apex classes: PascalCase; selectors end in
Selector, domains are plural noun, services end inService/ServiceImpl, interfaces prefixed withI - LWC components: camelCase directory and file names (e.g.,
weatherDashboard) - Custom metadata:
Snake_Case__mdt(e.g.,GitHub_App_Settings__mdt)
GitHub Actions workflow feature-validation.yml runs on PRs to main/develop:
- Code quality job: ESLint + Prettier checks
- Validate feature job: creates scratch org, deploys all source, assigns
Weather_Dashboard_Demo_Accesspermset, runs Apex tests, validates metadata, then deletes the scratch org