Implement Clay reference architecture with best-practice project layout. Use when designing new Clay integrations, reviewing project structure, or establishing architecture standards for Clay applications. Trigger with phrases like "clay architecture", "clay best practices", "clay project structure", "how to organize clay", "clay layout".
Install with Tessl CLI
npx tessl i github:jeremylongshore/claude-code-plugins-plus-skills --skill clay-reference-architecture70
Does it follow best practices?
If you maintain this skill, you can automatically optimize it using the tessl CLI to improve its score:
npx tessl skill review --optimize ./path/to/skillValidation for skill structure
Production-ready architecture patterns for Clay integrations.
my-clay-project/
├── src/
│ ├── clay/
│ │ ├── client.ts # Singleton client wrapper
│ │ ├── config.ts # Environment configuration
│ │ ├── types.ts # TypeScript types
│ │ ├── errors.ts # Custom error classes
│ │ └── handlers/
│ │ ├── webhooks.ts # Webhook handlers
│ │ └── events.ts # Event processing
│ ├── services/
│ │ └── clay/
│ │ ├── index.ts # Service facade
│ │ ├── sync.ts # Data synchronization
│ │ └── cache.ts # Caching layer
│ ├── api/
│ │ └── clay/
│ │ └── webhook.ts # Webhook endpoint
│ └── jobs/
│ └── clay/
│ └── sync.ts # Background sync job
├── tests/
│ ├── unit/
│ │ └── clay/
│ └── integration/
│ └── clay/
├── config/
│ ├── clay.development.json
│ ├── clay.staging.json
│ └── clay.production.json
└── docs/
└── clay/
├── SETUP.md
└── RUNBOOK.md┌─────────────────────────────────────────┐
│ API Layer │
│ (Controllers, Routes, Webhooks) │
├─────────────────────────────────────────┤
│ Service Layer │
│ (Business Logic, Orchestration) │
├─────────────────────────────────────────┤
│ Clay Layer │
│ (Client, Types, Error Handling) │
├─────────────────────────────────────────┤
│ Infrastructure Layer │
│ (Cache, Queue, Monitoring) │
└─────────────────────────────────────────┘// src/clay/client.ts
export class ClayService {
private client: ClayClient;
private cache: Cache;
private monitor: Monitor;
constructor(config: ClayConfig) {
this.client = new ClayClient(config);
this.cache = new Cache(config.cacheOptions);
this.monitor = new Monitor('clay');
}
async get(id: string): Promise<Resource> {
return this.cache.getOrFetch(id, () =>
this.monitor.track('get', () => this.client.get(id))
);
}
}// src/clay/errors.ts
export class ClayServiceError extends Error {
constructor(
message: string,
public readonly code: string,
public readonly retryable: boolean,
public readonly originalError?: Error
) {
super(message);
this.name = 'ClayServiceError';
}
}
export function wrapClayError(error: unknown): ClayServiceError {
// Transform SDK errors to application errors
}// src/clay/health.ts
export async function checkClayHealth(): Promise<HealthStatus> {
try {
const start = Date.now();
await clayClient.ping();
return {
status: 'healthy',
latencyMs: Date.now() - start,
};
} catch (error) {
return { status: 'unhealthy', error: error.message };
}
}User Request
│
▼
┌─────────────┐
│ API │
│ Gateway │
└──────┬──────┘
│
▼
┌─────────────┐ ┌─────────────┐
│ Service │───▶│ Cache │
│ Layer │ │ (Redis) │
└──────┬──────┘ └─────────────┘
│
▼
┌─────────────┐
│ Clay │
│ Client │
└──────┬──────┘
│
▼
┌─────────────┐
│ Clay │
│ API │
└─────────────┘// config/clay.ts
export interface ClayConfig {
apiKey: string;
environment: 'development' | 'staging' | 'production';
timeout: number;
retries: number;
cache: {
enabled: boolean;
ttlSeconds: number;
};
}
export function loadClayConfig(): ClayConfig {
const env = process.env.NODE_ENV || 'development';
return require(`./clay.${env}.json`);
}Set up the project layout following the reference structure above.
Create the singleton client with caching and monitoring.
Implement custom error classes for Clay operations.
Add health check endpoint for Clay connectivity.
| Issue | Cause | Solution |
|---|---|---|
| Circular dependencies | Wrong layering | Separate concerns by layer |
| Config not loading | Wrong paths | Verify config file locations |
| Type errors | Missing types | Add Clay types |
| Test isolation | Shared state | Use dependency injection |
# Create reference structure
mkdir -p src/clay/{handlers} src/services/clay src/api/clay
touch src/clay/{client,config,types,errors}.ts
touch src/services/clay/{index,sync,cache}.tsFor multi-environment setup, see clay-multi-env-setup.
22fc789
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.