salesforce-multi-env-setup
Configure Salesforce across Developer, Sandbox, and Production environments with proper org management. Use when setting up multi-environment deployments, configuring per-environment credentials, or implementing sandbox-to-production promotion flows. Trigger with phrases like "salesforce environments", "salesforce sandbox", "salesforce dev prod", "salesforce org management", "salesforce sandbox types".
What this skill does
# Salesforce Multi-Environment Setup
## Overview
Configure Salesforce integrations across Developer, Sandbox, and Production orgs with environment-specific credentials, login URLs, and deployment promotion flows.
## Prerequisites
- Production Salesforce org (Enterprise+ for Full sandbox)
- Salesforce CLI authenticated to all environments
- Secret management solution (Vault, AWS/GCP Secrets Manager)
## Instructions
### Step 1: Salesforce Environment Types
| Environment | Org Type | Login URL | Purpose | Data |
|------------|---------|-----------|---------|------|
| Development | Developer Edition or Scratch Org | login.salesforce.com | Local dev | Sample data |
| QA | Developer Sandbox | test.salesforce.com | Testing | Subset of prod |
| Staging | Full Sandbox | test.salesforce.com | Pre-prod validation | Copy of prod |
| Production | Production Org | login.salesforce.com | Live traffic | Real data |
### Step 2: Sandbox Types
| Sandbox Type | Data | Metadata | Refresh Interval | Use Case |
|-------------|------|----------|-------------------|----------|
| Developer | None | Copy of prod | 1 day | Feature development |
| Developer Pro | None | Copy of prod | 1 day | Integration testing |
| Partial Copy | Sampled | Copy of prod | 5 days | QA with realistic data |
| Full | Full copy | Copy of prod | 29 days | Staging, UAT, load testing |
### Step 3: Environment Configuration
```typescript
// src/config/salesforce.ts
interface SalesforceEnvConfig {
loginUrl: string;
username: string;
apiVersion: string;
isSandbox: boolean;
}
const envConfigs: Record<string, SalesforceEnvConfig> = {
development: {
loginUrl: 'https://login.salesforce.com', // Or test.salesforce.com for sandbox
username: process.env.SF_USERNAME_DEV!,
apiVersion: '59.0',
isSandbox: false, // true if using a sandbox for dev
},
staging: {
loginUrl: 'https://test.salesforce.com', // ALL sandboxes use test.salesforce.com
username: process.env.SF_USERNAME_STAGING!,
apiVersion: '59.0',
isSandbox: true,
},
production: {
loginUrl: 'https://login.salesforce.com',
username: process.env.SF_USERNAME_PROD!,
apiVersion: '59.0',
isSandbox: false,
},
};
export function getSalesforceConfig(): SalesforceEnvConfig {
const env = process.env.NODE_ENV || 'development';
const config = envConfigs[env];
if (!config) throw new Error(`No Salesforce config for environment: ${env}`);
return config;
}
```
### Step 4: Authenticate to Multiple Orgs
```bash
# Authenticate to each environment with aliases
sf org login web --alias sf-dev --instance-url https://login.salesforce.com
sf org login web --alias sf-staging --instance-url https://test.salesforce.com
sf org login web --alias sf-prod --instance-url https://login.salesforce.com
# For CI — use JWT (no browser needed)
sf org login jwt \
--client-id $SF_CLIENT_ID \
--jwt-key-file server.key \
--username [email protected] \
--alias sf-staging \
--instance-url https://test.salesforce.com
# List all authenticated orgs
sf org list --all
# Set default org
sf config set target-org sf-dev
```
### Step 5: Secret Management by Environment
```bash
# Local development — .env.local (git-ignored)
SF_LOGIN_URL=https://test.salesforce.com
[email protected]
SF_PASSWORD=devpassword
SF_SECURITY_TOKEN=devtoken
# CI/CD (GitHub Actions)
# Use environment-specific secrets:
# Settings > Environments > "staging" > Add secret SF_USERNAME
# Settings > Environments > "production" > Add secret SF_USERNAME (different value)
# Production (Vault / Secrets Manager)
# AWS:
aws secretsmanager get-secret-value --secret-id salesforce/production
# GCP:
gcloud secrets versions access latest --secret=sf-prod-credentials
# HashiCorp Vault:
vault kv get -field=password secret/salesforce/production
```
### Step 6: Deployment Promotion Flow
```bash
# 1. Develop in scratch org or developer sandbox
sf project deploy start --target-org sf-dev
# 2. Run Apex tests in dev
sf apex run test --target-org sf-dev --result-format human
# 3. Deploy to staging sandbox
sf project deploy start --target-org sf-staging --test-level RunLocalTests
# 4. Run integration tests against staging
SF_LOGIN_URL=https://test.salesforce.com npm run test:integration
# 5. Deploy to production (requires test coverage)
sf project deploy start --target-org sf-prod --test-level RunLocalTests --wait 30
# Rollback if needed
sf project deploy cancel --target-org sf-prod
```
### Step 7: Environment Guards
```typescript
// Prevent destructive operations in production
function guardProductionOperation(operation: string): void {
const config = getSalesforceConfig();
if (!config.isSandbox && process.env.NODE_ENV === 'production') {
const blocked = ['deleteAllAccounts', 'truncateContacts', 'resetData'];
if (blocked.includes(operation)) {
throw new Error(`Operation '${operation}' blocked in production Salesforce org`);
}
}
}
// Prevent using production credentials in dev
function validateEnvironment(): void {
const config = getSalesforceConfig();
if (process.env.NODE_ENV === 'development' && !config.isSandbox) {
console.warn('WARNING: Development mode connected to production org!');
}
}
```
## Output
- Multi-environment Salesforce configuration
- Sandbox types selected for each environment
- Credentials stored in platform-appropriate secrets manager
- Deployment promotion flow from dev to production
- Environment guards preventing accidental destructive operations
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| `INVALID_LOGIN` in sandbox | Wrong login URL | Use `test.salesforce.com` for ALL sandboxes |
| Sandbox username format | Missing `.sandbox` suffix | Username format: `[email protected]` |
| Config merge fails | Wrong NODE_ENV | Verify environment variable |
| Production guard triggered | Destructive operation | Use sandbox for testing |
## Resources
- [Sandbox Types](https://help.salesforce.com/s/articleView?id=sf.deploy_sandboxes_intro.htm)
- [Sandbox Limitations](https://help.salesforce.com/s/articleView?id=sf.data_sandbox_environments.htm)
- [Change Sets](https://help.salesforce.com/s/articleView?id=sf.changesets.htm)
- [SFDX CLI Org Commands](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm)
## Next Steps
For observability setup, see `salesforce-observability`.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.