Provides language-specific patterns for TypeScript, Python, and React including idioms, best practices, and common patterns. Use when implementing features in these languages.
View on GitHubFebruary 1, 2026
Select agents to install to:
npx add-skill https://github.com/sequenzia/claude-alchemy/blob/main/claude-tools/dev-tools/skills/language-patterns/SKILL.md -a claude-code --skill language-patternsInstallation paths:
.claude/skills/language-patterns/# Language Patterns
This skill provides language-specific patterns and best practices. Apply patterns that match the project's language and framework.
---
## TypeScript Patterns
### Type Safety
**Use strict types over `any`:**
```typescript
// Bad
function process(data: any): any {
return data.value;
}
// Good
interface DataItem {
value: string;
count: number;
}
function process(data: DataItem): string {
return data.value;
}
```
**Use discriminated unions for variants:**
```typescript
type Result<T> =
| { success: true; data: T }
| { success: false; error: Error };
function handleResult<T>(result: Result<T>) {
if (result.success) {
// TypeScript knows result.data exists
console.log(result.data);
} else {
// TypeScript knows result.error exists
console.error(result.error);
}
}
```
**Use `unknown` over `any` for external data:**
```typescript
async function fetchData(): Promise<unknown> {
const response = await fetch('/api/data');
return response.json();
}
// Then validate/parse
const data = await fetchData();
if (isValidData(data)) {
// Now safely typed
}
```
### Null Handling
**Use optional chaining and nullish coalescing:**
```typescript
// Optional chaining
const userName = user?.profile?.name;
// Nullish coalescing (only for null/undefined)
const displayName = userName ?? 'Anonymous';
// Combine them
const city = user?.address?.city ?? 'Unknown';
```
**Use type guards:**
```typescript
function isUser(obj: unknown): obj is User {
return (
typeof obj === 'object' &&
obj !== null &&
'id' in obj &&
'email' in obj
);
}
```
### Async Patterns
**Prefer async/await over raw promises:**
```typescript
// Good
async function fetchUser(id: string): Promise<User> {
const response = await fetch(`/api/users/${id}`);
if (!response.ok) {
throw new Error(`Failed to fetch user: ${response.status}`);
}
return response.json();
}
```
**Handle errors properly:**
```typescript
async function safeO