About autumn-add-usage-tracking
autumn-add-usage-tracking is a skill for integrating Autumn feature-usage checks and tracking into applications. It guides backend enforcement, frontend usage displays, metered features, and credit systems.
Key features
- 01Check feature access before work
- 02Track usage after successful work
- 03Enforce limits on the backend
- 04Display customer usage balances
- 05Handle metered features and credit systems
- 06Use idempotency keys and batch values
Use cases
- 01Prevent actions when a customer reaches a limit
- 02Record completed API or feature usage
- 03Show remaining usage in a React interface
- 04Deduct credits for metered feature use
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ useautumn/ skills --skill autumn-add-usage-trackingAfter installing, type/autumn-add-usage-trackingin Claude Code to confirm it loaded.
Details
From the project READMEAutumn Usage Tracking
Always consult docs.useautumn.com for code examples and latest API.
Autumn tracks feature usage and enforces limits. Backend checks required for security.
Quick Reference
Core Pattern
check → work → track
Check Response
| Field | Description |
|---|---|
allowed | Can customer proceed |
balance | Units remaining |
included_usage | Total usage included in plan |
unlimited | No limit enforced |
Feature Types
| Type | Behavior |
|---|---|
boolean | Access granted or denied |
metered | Usage tracked against limit |
credit_system | Pool for multiple features |
Security Model
| Layer | Purpose | Trust |
|---|---|---|
| Frontend | UX (show/hide UI) | Untrusted |
| Backend | Enforcement | Required |
Backend Implementation
import { Autumn } from "autumn-js";
const autumn = new Autumn({ secretKey: process.env.AUTUMN_SECRET_KEY });
// 1. Check
const { data } = await autumn.check({ customer_id, feature_id: "api_calls" });
if (!data.allowed) return { error: "Limit reached" };
// 2. Work
const result = await doWork();
// 3. Track
await autumn.track({ customer_id, feature_id: "api_calls", value: 1 });
return result;
from autumn import Autumn
autumn = Autumn('am_sk_test_xxx')
response = await autumn.check(customer_id="user_123", feature_id="api_calls")
if not response.allowed:
raise HTTPException(403, "Limit reached")
result = await do_work()
await autumn.track(customer_id="user_123", feature_id="api_calls", value=1)
React Implementation
import { useCustomer } from "autumn-js/react";
const { check, refetch } = useCustomer();
const handleAction = async () => {
const { data } = await check({ featureId: "messages" });
if (!data?.allowed) {
showUpgradePrompt();
return;
}
await performAction();
await refetch();
};
Displaying Usage
const { customer } = useCustomer();
const feature = customer?.features?.api_calls;
<p>{feature?.balance} / {feature?.included_usage}</p>
Credit Systems
Track the underlying metered feature, not the credit system:
// Config: credits → api_calls (1), image_gen (10)
// Wrong
await autumn.track({ customer_id, feature_id: "credits", value: 10 });
// Right - Autumn deducts 10 credits automatically
await autumn.track({ customer_id, feature_id: "image_gen", value: 1 });
Common Gotchas
- Track after success - Only track if work completes successfully
- Backend required - Frontend checks can be bypassed
- Credit systems - Track metered features, not the credit pool
- Idempotency - Use
idempotency_keyto prevent double-counting - Batch tracking - Pass higher
valuefor bulk operations
Resources
Comments
Markdown supported