paulpas/agent-skill-router/salesforce-api

Claude Code and agent skill by paulpas/agent-skill-router

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Implements Salesforce API integration (REST, SOQL, Bulk API, Apex, using

Install

npx vskill@latest install paulpas/agent-skill-router/salesforce-api

SKILL.md

The same SKILL.md was published earlier as paulpas/agent-skill-router/salesforce-api.

Salesforce API Integration

Implements production-grade Salesforce integration using the simple-salesforce Python SDK and Salesforce REST API. When loaded, this skill makes the model implement CRUD operations on Salesforce objects (Accounts, Contacts, Opportunities, Leads, Cases, Custom Objects), SOQL queries, Bulk API for large datasets, Apex REST calls, and Salesforce Streaming API. All implementations follow Salesforce best practices: use SF_INSTANCE_URL, SF_USERNAME, SF_PASSWORD, SF_SECURITY_TOKEN from environment, query with query_all() for deleted/archived records, use Bulk API for >10,000 records, implement exponential backoff for rate limits, and handle Salesforce IDs (15-char vs 18-char IDs).

TL;DR Checklist

  • [ ] Use simple-salesforce SDK with credentials from environment variables
  • [ ] Use SF_INSTANCE_URL, SF_USERNAME, SF_PASSWORD, SF_SECURITY_TOKEN for auth
  • [ ] Use Salesforce() constructor with domain='test' for sandboxes
  • [ ] Use sf.query() for SOQL queries, sf.query_all() to include deleted/archived
  • [ ] Use sf.<Object>.create(), .update(), .delete(), .get() for CRUD
  • [ ] Use sf.bulk.<Object>.query(), .insert(), .update(), .delete(), .upsert() for Bulk API
  • [ ] Handle both 15-char (case-sensitive) and 18-char (case-insensitive) Salesforce IDs
  • [ ] Implement exponential backoff for REQUEST_LIMIT_EXCEEDED errors
  • [ ] Use ALL ROWS scope in SOQL for deleted/archived records
  • [ ] Never store credentials or session IDs in code or logs

When to Use

Use this skill when:

  • Querying Salesforce data using SOQL
  • Creating/updating/deleting Salesforce records
  • Processing large datasets (10k+ records) with Bulk API
  • Calling Apex REST endpoints
  • Syncing data between your app and Salesforce
  • Building integrations with Salesforce CRM
  • Importing/exporting data to/from Salesforce
  • Automating business processes in Salesforce
  • Working with custom objects and fields
  • Managing Users, Profiles, and Permissions
  • Querying Activity History and Chatter

When NOT to Use

  • For HubSpot-specific CRM — use coding-hubspot-api instead
  • For Marketo marketing automation — use coding-marketo-api instead
  • For Zendesk support tickets — use coding-zendesk-api instead
  • For simple HTTP-only use cases when simple-salesforce is overkill
  • When you need real-time streaming only (consider Salesforce Streaming API or CometD)
  • For read-only reporting (use Salesforce Reports API directly)

Core Workflow

  1. Initialize Client — Create Salesforce client using simple-salesforce:
  • Production: Salesforce(username=..., password=..., security_token=..., instance_url=...)
  • Sandbox: Salesforce(..., domain='test')
  • Or use session ID: Salesforce(instance_url=..., session_id=...)

Checkpoint: Validate connection with sf.query("SELECT Id, Name FROM Account LIMIT 1").

  1. Query Data with SOQL — Use sf.query() for standard SOQL queries:
  • sf.query("SELECT Id, Name FROM Account WHERE Industry = 'Technology'")
  • Use query_all() to include deleted/archived records
  • Use query_more() for pagination with nextRecordsUrl

Checkpoint: Queries include LIMIT for testing, use query_all() when all records needed.

  1. CRUD Operations — Perform record operations:
  • Create: sf.Contact.create({'LastName': 'Doe', 'FirstName': 'John'})
  • Read: sf.Contact.get('003...')
  • Update: sf.Contact.update('003...', {'LastName': 'Smith'})
  • Delete: sf.Contact.delete('003...')
  • Upsert: sf.Contact.upsert('003...', 'My_External_Id__c/ExternalValue', {...})

Checkpoint: CRUD operations handle both 15-char and 18-char IDs.

  1. Bulk API for Large Datasets — Use Bulk API for >10,000 records:
  • Query: sf.bulk.Account.query("SELECT Id, Name FROM Account")
  • Insert: sf.bulk.Account.insert([{'Name': 'Account 1'}, {...}])
  • Update: sf.bulk.Account.update([{'Id': '001...', 'Name': 'Updated'}])
  • Delete: sf.bulk.Account.delete([{'Id': '001...'}])
  • Upsert: sf.bulk.Account.upsert([...], 'My_External_Id__c')

Checkpoint: Bulk operations use proper external IDs for upsert.

  1. Apex REST — Call custom Apex REST endpoints:
  • sf.apexcall(method='GET', path='/services/apexrest/MyEndpoint')
  • sf.apexcall(method='POST', path='/services/apexrest/MyEndpoint', data={...})

Checkpoint: Apex calls include correct path and method.

  1. Handle Limits & Rate Limiting — Monitor API usage:
  • sf.limits() to see current limits
  • Implement exponential backoff for REQUEST_LIMIT_EXCEEDED
  • Use Sforce-Limit-Info response header

Checkpoint: Limits checked before large operations.


Implementation Patterns

Pattern 1: Salesforce Client Initialization (BAD vs GOOD)
python
"""Salesforce client initialization patterns.
Key concepts:
- simple-salesforce: Popular Python SDK for Salesforce
- Authentication: username + password + security_token (legacy)
- OAuth 2.0: More secure (session_id + instance_url)
- Domain: 'login' (production) or 'test' (sandbox)
- Instance URL: Full URL for your org (e.g., 'https://na1.salesforce.com')
Important:
- Password + Security Token = concatenated password
- 15-char IDs (case-sensitive) vs 18-char IDs (case-insensitive)
"""
from __future__ import annotations
import os
import re
import time
import logging
from typing import Any, Optional, List, Dict
from dataclasses import dataclass, field
from datetime import datetime, timedelta, timezone
logger = logging.getLogger(__name__)
# ===================================================================
# ❌ BAD — hardcoded credentials, no error handling, sandbox vs prod confusion
# ===================================================================
def bad_salesforce_init_bad() -> Any:
"""❌ BAD: Don't do any of these things."""
from simple_salesforce import Salesforce
# ❌ Hardcoded credentials! Never commit these!
sf = Salesforce(
username='admin@example.com',
password='MySecretPassword123', # ❌ HARDCODED!
security_token='ABC123xyz', # ❌ HARDCODED!
domain='login',
)
# ❌ No validation
# ❌ No error handling
# ❌ Using 'login' for sandbox (should be 'test')
# ❌ Not checking limits before query
return sf
# ===================================================================
# ✅ GOOD — env-based config, validation, proper domain handling
# ===================================================================
class SalesforceError(Exception):
"""Base exception for Salesforce integration errors."""
pass
class SalesforceAuthError(SalesforceError):
"""Authentication failed or credentials invalid."""
pass
class SalesforceLimitError(SalesforceError):
"""API limits exceeded."""
def __init__(self, message: str, retry_after: Optional[int] = None):
super().__init__(message)
self.retry_after = retry_after
@dataclass
class SalesforceConfig:
"""Salesforce configuration from environment variables.
Environment variables:
SF_INSTANCE_URL: Full instance URL (https://na1.salesforce.com)
SF_USERNAME: Salesforce username
SF_PASSWORD: Salesforce password
SF_SECURITY_TOKEN: Security token (appended to password)
SF_DOMAIN: 'login' (production) or 'test' (sandbox)
SF_SESSION_ID: OAuth session ID (alternative to password auth)
SF_CLIENT_ID: OAuth client ID (for OAuth flow)
SF_CLIENT_SECRET: OAuth client secret
"""
# Connection
instance_url: Optional[str] = None
domain: str = "login" # 'login' = production, 'test' = sandbox
# Password auth
username: Optional[str] = None
password: Optional[str] = None
security_token: Optional[str] = None
# OAuth / Session auth
session_id: Optional[str] = None
# Request config
timeout: float = 30.0
max_retries: int = 3
initial_retry_delay: float = 1.0
@classmethod
def from_env(cls) -> "SalesforceConfig":
"""Load configuration from environment variables."""
def parse_bool(env_var: str, default: bool) -> bool:
val = os.environ.get(env_var)
if val is None:
return default
return val.lower() in ("1", "true", "yes", "on")
def parse_float(env_var: str, default: float) -> float:
val = os.environ.get(env_var)
if val is None:
return default
try:
return float(val)
except ValueError:
return default
# Determine domain
domain_env = os.environ.get("SF_DOMAIN", "login").lower()
domain = "test" if domain_env == "test" else "login"
return cls(
instance_url=os.environ.get("SF_INSTANCE_URL"),
domain=domain,
username=os.environ.get("SF_USERNAME"),
password=os.environ.get("SF_PASSWORD"),
security_token=os.environ.get("SF_SECURITY_TOKEN"),
session_id=os.environ.get("SF_SESSION_ID"),
timeout=parse_float("SF_TIMEOUT", 30.0),
)
def is_enabled(self) -> bool:
"""Check if Salesforce is configured."""
# Check for session auth
if self.session_id and self.instance_url:
return True
# Check for password auth
if self.username and self.password:
return True
return False
def validate(self) -> bool:
"""Validate configuration.
Returns:
True if valid
Raises:
ValueError: If invalid when enabled
"""
if not self.is_enabled():
logger.info("Salesforce not configured")
return True
if self.session_id:
if not self.instance_url:
raise ValueError("SF_INSTANCE_URL required with SF_SESSION_ID")
else:
if not self.username:
raise ValueError("SF_USERNAME required for password auth")
if not self.password:
raise ValueError("SF_PASSWORD required for password auth")
return True
def get_full_password(self) -> str:
"""Get password + security token concatenated.
simple-salesforce expects password + token as one string.
"""
if not self.password:
raise ValueError("Password not configured")
if self.security_token:
return f"{self.password}{self.security_token}"
return self.password

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
4
7-day trend score
8

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/paulpas/agent-skill-router/salesforce-api/badge)](https://verified-skill.com/skills/paulpas/agent-skill-router/salesforce-api)

Something wrong with this skill or its page? Tell us.