data-service-proxy-direct
하는 일
이 스킬은 서버 프록시를 거치거나 API에 직접 연결하는 대시보드 데이터 서비스를 AI 에이전트가 작성하도록 안내합니다. API 키를 프록시 뒤에 숨겨야 하는 경우와 직접 호출해도 되는 경우가 함께 있는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓데이터 서비스가 프록시를 거치는 방식과 직접 API 호출 방식 모두에서 작동해야 할 때.
- ✓API 키는 서버에 남아야 하지만 일부 호출은 직접 해도 될 때.
- ✓모든 서비스에 가져오기, 캐시, 재시도 동작이 있기를 원할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/data-service-proxy-direct/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 주가 패널의 데이터 서비스를 작성해 주세요. 설정에 따라 우리 프록시를 쓰거나 API를 직접 호출할 수 있어야 합니다.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 프록시를 거친 요청 경로와 직접 요청 경로 중 하나를 고르는 서비스를 만듭니다. 호출을 서킷 브레이커로 감싸고, 결과를 캐시하며, 요청이 실패하면 재시도합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Data Service Pattern
Each panel's data comes from a dedicated service module in src/services/. Services handle API calls, caching, error handling with circuit breaker pattern, and can work with both proxied and direct API calls.
Circuit Breaker
The circuit breaker prevents cascading failures when an API is down. After N consecutive failures, it enters "cooldown" mode and serves cached data instead of hitting the API.
Create src/utils/circuit-breaker.ts:
interface CircuitState {
failures: number;
cooldownUntil: number;
}
interface CacheEntry<T> {
data: T;
timestamp: number;
}
export interface CircuitBreakerOptions {
name: string;
maxFailures?: number;
cooldownMs?: number;
cacheTtlMs?: number;
}
export class CircuitBreaker<T> {
private state: CircuitState = { failures: 0, cooldownUntil: 0 };
private cache: CacheEntry<T> | null = null;
private name: string;
private maxFailures: number;
private cooldownMs: number;
private cacheTtlMs: number;
constructor(options: CircuitBreakerOptions) {
this.name = options.name;
this.maxFailures = options.maxFailures ?? 2;
this.cooldownMs = options.cooldownMs ?? 5 * 60 * 1000; // 5 minutes
this.cacheTtlMs = options.cacheTtlMs ?? 10 * 60 * 1000; // 10 minutes
}
isOnCooldown(): boolean {
if (Date.now() < this.state.cooldownUntil) return true;
if (this.state.cooldownUntil > 0) {
this.state = { failures: 0, cooldownUntil: 0 };
}
return false;
}
getCached(): T | null {
if (this.cache && Date.now() - this.cache.timestamp < this.cacheTtlMs) {
return this.cache.data;
}
return null;
}
recordSuccess(data: T): void {
this.state = { failures: 0, cooldownUntil: 0 };
this.cache = { data, timestamp: Date.now() };
}
recordFailure(error?: string): void {
this.state.failures++;
if (this.state.failures >= this.maxFailures) {
this.state.cooldownUntil = Date.now() + this.cooldownMs;
console.warn(`[${this.name}] Cooldown for ${this.cooldownMs / 1000}s`);
}
}
async execute<R extends T>(fn: () => Promise<R>, defaultValue: R): Promise<R> {
if (this.isOnCooldown()) {
const cached = this.getCached();
return (cached as R) ?? defaultValue;
}
const cached = this.getCached();
if (cached !== null) return cached as R;
try {
const result = await fn();
this.recordSuccess(result);
return result;
} catch (e) {
console.error(`[${this.name}] Failed:`, e);
this.recordFailure(String(e));
return defaultValue;
}
}
}
export function createCircuitBreaker<T>(options: CircuitBreakerOptions): CircuitBreaker<T> {
return new CircuitBreaker<T>(options);
}
Service Module Pattern
Each service is a TypeScript module that exports async data-fetching functions. Services can work with both proxied and direct API calls.
Proxied API Example
// src/services/stock-market.ts
import { createCircuitBreaker } from '../utils/circuit-breaker';
export interface StockQuote {
symbol: string;
name: string;
price: number | null;
change: number | null;
sparkline?: number[];
}
const breaker = createCircuitBreaker<StockQuote[]>({
name: 'StockMarket',
cacheTtlMs: 60_000, // 1 minute cache
});
export async function fetchStockQuotes(symbols: string[]): Promise<StockQuote[]> {
return breaker.execute(async () => {
const params = new URLSearchParams({ symbols: symbols.join(',') });
const resp = await fetch(`/api/stocks?${params}`);
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
return resp.json();
}, []);
}
Direct API Example
// src/services/weather.ts
import { createCircuitBreaker } from '../utils/circuit-breaker';
export interface WeatherData {
city: string;
temperature: number;
condition: string;
forecast: Array<{
day: string;
high: number;
low: number;
condition: string;
}>;
}
const breaker = createCircuitBreaker<WeatherData>({
name: 'WeatherAPI',
cacheTtlMs: 30_000, // 30 seconds cache
});
export async function fetchWeather(city: string): Promise<WeatherData> {
return breaker.execute(async () => {
const resp = await fetch(`https://wttr.in/${city}?format=j1`);
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
return resp.json();
}, {
city,
temperature: 0,
condition: 'Unknown',
forecast: []
});
}
Key Patterns
- **One circuit breaker
자주 묻는 질문
프록시는 언제 쓰나요?
API 키를 서버에 숨겨야 할 때 프록시를 쓰라고 스킬은 제안합니다.
서비스는 실패한 호출을 재시도하나요?
네, 스킬은 서비스가 캐싱과 함께 재시도도 처리한다고 설명합니다.
같은 패널이 두 방식을 모두 쓸 수 있나요?
네, 서비스는 프록시를 거치는 경로나 직접 경로 중 하나를 쓰도록 설정할 수 있습니다.
상세 정보
작성자의 원본 설명
Create resilient data fetching services with circuit breaker pattern, supporting both proxied and direct API calls. Services handle fetch, cache, retry, and expose typed data to panel components.
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #13049
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.