credit-system
БесплатноБез исполняемых скриптовНе проверенAI 사용량 과금 — 크레딧 모델, idempotent UsageRecord, 한도·auto-refill, LLM 원가+마진 가격, Free Tier, immutable ledger 환불. Use when 토큰·API 호출 단위 종량제나 충전식 크레딧을 설계할 때.
от majiayu000★ 31 звезда на GitHubОб этом скилле
Credit System — AI/사용량 모네타이징
LLM 토큰·API 호출·연산 시간 등 사용량 단위로 과금하는 비즈니스 패턴. subscription-billing-flows.md §5 Metered Billing의 자연 연장이며, AI 제품에서는 정액 seat + per-token usage hybrid가 디폴트.
이 skill은 사용량 모네타이징 전용 hub. Stripe Subscription 자체는
subscription-billing.md참조. 일회성 결제는payment-integration.md. 이 문서는 잔액·차감·임계치·LLM 원가 추적의 도메인 모델과 함정에 집중.
When to Use
- AI 제품 (LLM 챗봇, 코드 어시스턴트, 이미지 생성 등) 모네타이징 설계
- API 제품 (요청/GB/CPU초 단위) 가격 모델 설계
- "월정액으로 가? 충전식으로 가? 둘 다?" 의사결정
- LLM provider 원가 변동을 사용자 가격에 어떻게 반영할지
- 무료 tier(예: 월 100만 토큰)와 유료 한도 정책 설계
- AI 호출 폭증으로 한 사용자가 월 $1,000 청구되는 사고 예방
관련 skill (cross-link):
business/subscription-billing.md— 메인 hub, 정기 빌링 인프라 (seat 부분)business/subscription-billing-flows.md§5 — Metered Billing 패턴 (idempotency/late events 원칙)business/subscription-billing-metrics.md— MRR/Cohort SQL 패턴 → usage 메트릭으로 확장business/payment-integration.md— 충전 결제 (one-time topup)business/rate-limiting.md— 토큰/RPS hard cap, threshold 결합business/notification-multichannel.md— low balance / cap 도달 알림business/audit-log.md— usage_event 감사, refund/조정 기록business/multi-tenancy.md— tenant 단위 잔액, seat × usage 결합ai/prompt-engineering.md,ai/rag-patterns.md— 토큰 효율 (원가 절감)
관련 agent: tech-lead (가격 모델 ADR), cost-analyzer (LLM provider 원가 추적)
관련 skill: /infra:postgresql-operations (ledger 파티셔닝/아카이빙), /messaging:broker-troubleshooting (usage 이벤트 큐), /infra:redis-operations (잔액 캐시)
1. 모델 결정 매트릭스
| 모델 | 적합 | 사용자 멘탈 모델 | 함정 |
|---|---|---|---|
| Prepaid Credit (충전식) | API 제품, 변동성 큰 사용량 | "지갑에 잔액" — 친숙 | 미사용 잔액 환불/만료 정책, 회계 처리(deferred revenue) |
| Postpaid Metered | 엔터프라이즈, 신뢰관계 있는 B2B | "월말 청구서" | 미수금/dunning, 사용 폭증 시 충격 청구 |
| Hybrid: Seat + Usage | AI 제품 표준 (Cursor/v0/ChatGPT Pro) | "월 $20 + 한도 초과 시 충전" | seat 가격에 usage 어디까지 포함할지 |
| Pay-as-you-go (no commit) | Indie/playground 제품 | "쓴 만큼만" | 사용자 1명이 무한 사용 → 청구 폭탄 → 환불 분쟁 |
| Tiered with Hard Cap | B2C, 청구 폭탄 회피 | "정액 + 초과 시 차단" | 비즈니스 critical 호출도 차단되는 UX |
| Tiered with Soft Overage | B2B, 매출 우선 | "정액 + 초과 시 자동 청구" | 사용자 사전 동의 + 경고 흐름 필수 |
2026 트렌드 (AI 제품 디폴트):
- **Hybrid (월 seat + per-token credit)**가 사실상 표준. ChatGPT Pro($20+사용량), Cursor($20 monthly+overage), v0(seat+credit), Anthropic Console(prepaid).
- Hard cap 기본 ON + 사용자 명시적 opt-in으로 soft overage 활성화가 신뢰 표준 (청구 폭탄 사고 방지).
- Auto-refill + Spend limit는 짝패. refill 없이 limit만 두면 운영 중단, limit 없이 refill만 두면 청구 폭탄.
모델 추상화 — subscription-billing.md SubscriptionGateway 연장
CreditGateway (interface) # subscription-billing의 SubscriptionGateway와 짝
├─ create_account(tenant) → CreditAccountId
├─ topup(account, amount, currency, idempotency_key) → TxId # 충전
├─ debit(account, units, meter, metadata, idempotency_key) → TxId # 차감
├─ get_balance(account) → Balance{available, reserved, committed}
├─ set_threshold(account, level, action: notify|block|refill)
└─ refund(tx_id, reason) → TxId # 보상 트랜잭션
Adapters:
├─ StripeMetersAdapter # postpaid usage → Stripe Subscription에 합산
├─ InternalLedgerAdapter # prepaid 자체 ledger (PostgreSQL)
└─ LagoAdapter # open-source metered billing 위임
원칙: 도메인 코드는 CreditGateway만 의존. Stripe Meters / 자체 ledger / Lago 어느 쪽이든 어댑터로 격리. subscription-billing.md Pattern과 동일.
2. 도메인 모델 (필수)
CreditAccount (1) ── (1) Tenant 또는 (1) Customer
├─ id
├─ tenant_id (multi-tenancy 결합)
├─ currency (USD/KRW/EUR — currency lock)
├─ balance_available (즉시 사용 가능 = 충전 - 차감 - 예약)
├─ balance_reserved (진행 중 요청 hold)
├─ free_tier_remaining (월간 무료 잔량, 매월 reset)
├─ low_balance_threshold (알림 임계치)
├─ auto_refill_enabled / auto_refill_amount / auto_refill_trigger
├─ spend_limit_monthly (hard cap, 사용자 설정)
└─ status: active|frozen|closed
CreditLedgerEntry (immutable, append-only)
├─ id, account_id, occurred_at
├─ entry_type: topup|debit|refund|adjustment|free_tier_grant|expiration
├─ amount (양수: 입금, 음수: 출금)
├─ balance_after (스냅샷, 빠른 조회용. 주기적 재계산으로 검증)
├─ idempotency_key (UNIQUE)
├─ source_event_id (UsageEvent.id 또는 invoice.id)
├─ metadata (JSONB) (model, prompt_tokens, completion_tokens, ...)
└─ provider (stripe|internal|lago)
UsageEvent (raw, billing 전 단계)
├─ id (UUID), tenant_id, account_id
├─ meter (llm_tokens|api_calls|gb_storage|...)
├─ quantity (예: 12500 tokens)
├─ occurred_at, recorded_at (late event 식별)
├─ idempotency_key (UNIQUE — 같은 요청 재시도 시 1회만)
├─ unit_cost (이 요청 시점의 unit price snapshot)
├─ metadata (JSONB) (request_id, model, prompt/completion 분리, latency)
└─ status: pending|priced|debited|voided
PriceBook (시간 가변, immutable version)
├─ id, effective_at
├─ meter, model
Установить credit-system в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл credit-system?
AI 사용량 과금 — 크레딧 모델, idempotent UsageRecord, 한도·auto-refill, LLM 원가+마진 가격, Free Tier, immutable ledger 환불. Use when 토큰·API 호출 단위 종량제나 충전식 크레딧을 설계할 때.
Как установить скилл credit-system?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл credit-system запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic