Automated summary
Provides production-ready coding patterns for using the Instantly SDK in TypeScript and Python, covering client singletons, error wrappers, retries, and response validation.
Strengths
- Shows a typed client singleton plus a factory variant for multi-tenant setups
- Includes a safe call wrapper, exponential-backoff retry logic, and a Zod validation example
- Covers both TypeScript and Python, with an async context manager for client cleanup
- Ships a compact error-pattern decision table for quick scanning
Limitations
- Assumes Instantly install and auth setup is already complete
- Snippets are skeletal: actual SDK options and response types are not detailed
- Does not address API rate limiting beyond exponential backoff retries
Use it when bootstrapping an Instantly integration or when you want consistent error-handling and retry conventions across an existing codebase.
Skip it if your project does not use the Instantly SDK or your team already has established client and error-handling conventions.
Security analysis
SafeThe skill provides ordinary TypeScript and Python SDK usage patterns, including singleton clients, retry logic, and error handling. It does not instruct destructive commands, credential exfiltration, obfuscated execution, or safety bypasses; API keys are read from environment variables as expected.
No concerns found
How this analysis is madeExamples
Refactor our Instantly integration to use a single shared client singleton instead of creating a new client in every handler, TypeScript please.Wrap our Instantly API calls with a safe error-handling function and exponential backoff retries, following the instantly SDK patterns.We serve multiple tenants with different Instantly API keys — show me a factory pattern for caching a client per tenant in TypeScript.name: instantly-sdk-patterns description: | Apply production-ready Instantly SDK patterns for TypeScript and Python. Use when implementing Instantly integrations, refactoring SDK usage, or establishing team coding standards for Instantly. Trigger with phrases like "instantly SDK patterns", "instantly best practices", "instantly code patterns", "idiomatic instantly". allowed-tools: Read, Write, Edit version: 1.0.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io
Instantly SDK Patterns
Overview
Production-ready patterns for Instantly SDK usage in TypeScript and Python.
Prerequisites
- Completed
instantly-install-authsetup - Familiarity with async/await patterns
- Understanding of error handling best practices
Instructions
Step 1: Implement Singleton Pattern (Recommended)
// src/instantly/client.ts
import { InstantlyClient } from '@instantly/sdk';
let instance: InstantlyClient | null = null;
export function getInstantlyClient(): InstantlyClient {
if (!instance) {
instance = new InstantlyClient({
apiKey: process.env.INSTANTLY_API_KEY!,
// Additional options
});
}
return instance;
}
Step 2: Add Error Handling Wrapper
import { InstantlyError } from '@instantly/sdk';
async function safeInstantlyCall<T>(
operation: () => Promise<T>
): Promise<{ data: T | null; error: Error | null }> {
try {
const data = await operation();
return { data, error: null };
} catch (err) {
if (err instanceof InstantlyError) {
console.error({
code: err.code,
message: err.message,
});
}
return { data: null, error: err as Error };
}
}
Step 3: Implement Retry Logic
async function withRetry<T>(
operation: () => Promise<T>,
maxRetries = 3,
backoffMs = 1000
): Promise<T> {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
return await operation();
} catch (err) {
if (attempt === maxRetries) throw err;
const delay = backoffMs * Math.pow(2, attempt - 1);
await new Promise(r => setTimeout(r, delay));
}
}
throw new Error('Unreachable');
}
Output
- Type-safe client singleton
- Robust error handling with structured logging
- Automatic retry with exponential backoff
- Runtime validation for API responses
Error Handling
| Pattern | Use Case | Benefit | |---------|----------|---------| | Safe wrapper | All API calls | Prevents uncaught exceptions | | Retry logic | Transient failures | Improves reliability | | Type guards | Response validation | Catches API changes | | Logging | All operations | Debugging and monitoring |
Examples
Factory Pattern (Multi-tenant)
const clients = new Map<string, InstantlyClient>();
export function getClientForTenant(tenantId: string): InstantlyClient {
if (!clients.has(tenantId)) {
const apiKey = getTenantApiKey(tenantId);
clients.set(tenantId, new InstantlyClient({ apiKey }));
}
return clients.get(tenantId)!;
}
Python Context Manager
from contextlib import asynccontextmanager
from instantly import InstantlyClient
@asynccontextmanager
async def get_instantly_client():
client = InstantlyClient()
try:
yield client
finally:
await client.close()
Zod Validation
import { z } from 'zod';
const instantlyResponseSchema = z.object({
id: z.string(),
status: z.enum(['active', 'inactive']),
createdAt: z.string().datetime(),
});
Resources
Next Steps
Apply patterns in instantly-core-workflow-a for real-world usage.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/instantly-sdk-patterns-mrzxuqzq' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/instantly-sdk-patterns-mrzxuqzq/download' --output '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md.part' && mv '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md.part' '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Tools declared by the author (check availability in your agent): Read, Write, Edit
Original excerpt: Prerequisites
- Completed
instantly-install-authsetup - Familiarity with async/await patterns
- Understanding of error handling best practices
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md' && test -s '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/instantly-sdk-patterns' && cp -R '.skill-downloads/instantly-sdk-patterns-mrzxuqzq' '.claude/skills/instantly-sdk-patterns'Cursor
test -f '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md' && test -s '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/instantly-sdk-patterns' && cp -R '.skill-downloads/instantly-sdk-patterns-mrzxuqzq' '.cursor/skills/instantly-sdk-patterns'Codex
test -f '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md' && test -s '.skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/instantly-sdk-patterns' && cp -R '.skill-downloads/instantly-sdk-patterns-mrzxuqzq' '.agents/skills/instantly-sdk-patterns'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/instantly-sdk-patterns-mrzxuqzq'openskills read 'instantly-sdk-patterns-mrzxuqzq'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/instantly-sdk-patterns-mrzxuqzq/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.