palantir-sdk-patterns
Apply production-ready Palantir Foundry SDK patterns for Python and TypeScript. Use when implementing Foundry integrations, refactoring SDK usage, or establishing team coding standards for Foundry API calls. Trigger with phrases like "palantir SDK patterns", "foundry best practices", "palantir code patterns", "idiomatic foundry SDK".
Best use case
palantir-sdk-patterns is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Apply production-ready Palantir Foundry SDK patterns for Python and TypeScript. Use when implementing Foundry integrations, refactoring SDK usage, or establishing team coding standards for Foundry API calls. Trigger with phrases like "palantir SDK patterns", "foundry best practices", "palantir code patterns", "idiomatic foundry SDK".
Teams using palantir-sdk-patterns should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/palantir-sdk-patterns/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How palantir-sdk-patterns Compares
| Feature / Agent | palantir-sdk-patterns | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Apply production-ready Palantir Foundry SDK patterns for Python and TypeScript. Use when implementing Foundry integrations, refactoring SDK usage, or establishing team coding standards for Foundry API calls. Trigger with phrases like "palantir SDK patterns", "foundry best practices", "palantir code patterns", "idiomatic foundry SDK".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# Palantir SDK Patterns
## Overview
Production-ready patterns for Foundry Platform SDK and OSDK usage. Covers client singletons, typed error handling, pagination helpers, retry logic, and multi-tenant client factories.
## Prerequisites
- Completed `palantir-install-auth` setup
- Familiarity with async/await patterns
- `foundry-platform-sdk` or `@osdk/client` installed
## Instructions
### Step 1: Singleton Client (Python)
```python
# src/foundry_client.py
import os
import foundry
from functools import lru_cache
@lru_cache(maxsize=1)
def get_client() -> foundry.FoundryClient:
"""Thread-safe singleton — cached after first call."""
auth = foundry.ConfidentialClientAuth(
client_id=os.environ["FOUNDRY_CLIENT_ID"],
client_secret=os.environ["FOUNDRY_CLIENT_SECRET"],
hostname=os.environ["FOUNDRY_HOSTNAME"],
scopes=["api:read-data", "api:write-data"],
)
auth.sign_in_as_service_user()
return foundry.FoundryClient(auth=auth, hostname=os.environ["FOUNDRY_HOSTNAME"])
```
### Step 2: Typed Error Handling
```python
import foundry
from dataclasses import dataclass
from typing import TypeVar, Generic, Optional
T = TypeVar("T")
@dataclass
class Result(Generic[T]):
data: Optional[T] = None
error: Optional[str] = None
status_code: Optional[int] = None
def safe_call(fn, *args, **kwargs) -> Result:
"""Wrap any Foundry SDK call with structured error handling."""
try:
return Result(data=fn(*args, **kwargs))
except foundry.ApiError as e:
return Result(error=e.message, status_code=e.status_code)
except Exception as e:
return Result(error=str(e))
# Usage
result = safe_call(
get_client().ontologies.OntologyObject.list,
ontology="my-company", object_type="Employee", page_size=10,
)
if result.error:
print(f"Error {result.status_code}: {result.error}")
else:
print(f"Found {len(result.data.data)} objects")
```
### Step 3: Pagination Helper
```python
def paginate_objects(client, ontology: str, object_type: str, page_size: int = 100):
"""Iterate through all objects with automatic pagination."""
page_token = None
while True:
result = client.ontologies.OntologyObject.list(
ontology=ontology,
object_type=object_type,
page_size=page_size,
page_token=page_token,
)
yield from result.data
page_token = result.next_page_token
if not page_token:
break
# Usage
for emp in paginate_objects(get_client(), "my-company", "Employee"):
print(emp.properties["fullName"])
```
### Step 4: Retry with Exponential Backoff
```python
import time
import random
def retry_with_backoff(fn, max_retries=3, base_delay=1.0):
"""Retry on 429/5xx with jittered exponential backoff."""
for attempt in range(max_retries + 1):
try:
return fn()
except foundry.ApiError as e:
if attempt == max_retries or e.status_code not in (429, 500, 502, 503):
raise
delay = base_delay * (2 ** attempt) + random.uniform(0, 0.5)
print(f"Retry {attempt + 1}/{max_retries} in {delay:.1f}s (HTTP {e.status_code})")
time.sleep(delay)
```
### Step 5: TypeScript OSDK Patterns
```typescript
import { createClient, type Client } from "@osdk/client";
import { createConfidentialOauthClient } from "@osdk/oauth";
// Singleton with lazy initialization
let _client: Client | null = null;
export function getOsdkClient(): Client {
if (!_client) {
const oauth = createConfidentialOauthClient(
process.env.FOUNDRY_CLIENT_ID!,
process.env.FOUNDRY_CLIENT_SECRET!,
`https://${process.env.FOUNDRY_HOSTNAME}/multipass/api/oauth2/token`,
);
_client = createClient(
`https://${process.env.FOUNDRY_HOSTNAME}`,
process.env.ONTOLOGY_RID!,
oauth,
);
}
return _client;
}
```
## Output
- Thread-safe singleton client with cached auth
- Structured Result type for error handling
- Automatic pagination for large object sets
- Retry logic with jittered backoff
## Error Handling
| Pattern | Use Case | Benefit |
|---------|----------|---------|
| Singleton | All API calls | One auth flow, reused connection |
| Result wrapper | Error propagation | No uncaught exceptions |
| Pagination helper | Large datasets | Memory-safe iteration |
| Retry with backoff | Transient failures | Resilient operations |
## Examples
### Multi-Tenant Client Factory
```python
_clients: dict[str, foundry.FoundryClient] = {}
def get_client_for_tenant(tenant_id: str) -> foundry.FoundryClient:
if tenant_id not in _clients:
hostname = get_tenant_hostname(tenant_id)
token = get_tenant_token(tenant_id)
_clients[tenant_id] = foundry.FoundryClient(
auth=foundry.UserTokenAuth(hostname=hostname, token=token),
hostname=hostname,
)
return _clients[tenant_id]
```
## Resources
- [Foundry Platform SDK](https://github.com/palantir/foundry-platform-python)
- [SDK Reference](https://www.palantir.com/docs/foundry/api/general/overview/sdks)
- [OSDK Overview](https://www.palantir.com/docs/foundry/ontology-sdk/overview)
## Next Steps
Apply patterns in `palantir-core-workflow-a` for real pipeline usage.Related Skills
workhuman-sdk-patterns
Workhuman sdk patterns for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman sdk patterns".
wispr-sdk-patterns
Wispr Flow sdk patterns for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr sdk patterns".
windsurf-sdk-patterns
Apply production-ready Windsurf workspace configuration and Cascade interaction patterns. Use when configuring .windsurfrules, workspace rules, MCP servers, or establishing team coding standards for Windsurf AI. Trigger with phrases like "windsurf patterns", "windsurf best practices", "windsurf config patterns", "windsurfrules", "windsurf workspace".
windsurf-reliability-patterns
Implement reliable Cascade workflows with checkpoints, rollback, and incremental editing. Use when building fault-tolerant AI coding workflows, preventing Cascade from breaking builds, or establishing safe practices for multi-file AI edits. Trigger with phrases like "windsurf reliability", "cascade safety", "windsurf rollback", "cascade checkpoint", "safe cascade workflow".
webflow-sdk-patterns
Apply production-ready Webflow SDK patterns — singleton client, typed error handling, pagination helpers, and raw response access for the webflow-api package. Use when implementing Webflow integrations, refactoring SDK usage, or establishing team coding standards. Trigger with phrases like "webflow SDK patterns", "webflow best practices", "webflow code patterns", "idiomatic webflow", "webflow typescript".
vercel-sdk-patterns
Production-ready Vercel REST API patterns with typed fetch wrappers and error handling. Use when integrating with the Vercel API programmatically, building deployment tools, or establishing team coding standards for Vercel API calls. Trigger with phrases like "vercel SDK patterns", "vercel API wrapper", "vercel REST API client", "vercel best practices", "idiomatic vercel API".
vercel-reliability-patterns
Implement reliability patterns for Vercel deployments including circuit breakers, retry logic, and graceful degradation. Use when building fault-tolerant serverless functions, implementing retry strategies, or adding resilience to production Vercel services. Trigger with phrases like "vercel reliability", "vercel circuit breaker", "vercel resilience", "vercel fallback", "vercel graceful degradation".
veeva-sdk-patterns
Veeva Vault sdk patterns for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva sdk patterns".
vastai-sdk-patterns
Apply production-ready Vast.ai SDK patterns for Python and REST API. Use when implementing Vast.ai integrations, refactoring SDK usage, or establishing coding standards for GPU cloud operations. Trigger with phrases like "vastai SDK patterns", "vastai best practices", "vastai code patterns", "idiomatic vastai".
twinmind-sdk-patterns
Apply production-ready TwinMind SDK patterns for TypeScript and Python. Use when implementing TwinMind integrations, refactoring API usage, or establishing team coding standards for meeting AI integration. Trigger with phrases like "twinmind SDK patterns", "twinmind best practices", "twinmind code patterns", "idiomatic twinmind".
together-sdk-patterns
Together AI sdk patterns for inference, fine-tuning, and model deployment. Use when working with Together AI's OpenAI-compatible API. Trigger: "together sdk patterns".
techsmith-sdk-patterns
TechSmith sdk patterns for Snagit COM API and Camtasia automation. Use when working with TechSmith screen capture and video editing automation. Trigger: "techsmith sdk patterns".