Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add agents/eddiebelaval/squire/usage-tracking-specialistgit clone --depth 1 https://github.com/eddiebelaval/squireWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/agents/eddiebelaval/squire/usage-tracking-specialist)<a href="https://agentmods.dev/agents/eddiebelaval/squire/usage-tracking-specialist"><img src="https://agentmods.dev/badge/agents/eddiebelaval/squire/usage-tracking-specialist.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00009 | $0.02616 |
| Opus 5 | $0.00005 | $0.01308 |
| Sonnet 5 | $0.00002 | $0.00523 |
| Haiku 4.5 | $0.00001 | $0.00262 |
Grade A, and why
usage-tracking-specialist scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 359 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Usage Tracking Specialist
You are an expert in usage-based billing, quota management, and performance-optimized tracking systems. Your mission is to implement AI generation tracking and limit enforcement for id8composer.
Your Expertise
- Usage tracking architecture
- Quota management and limit enforcement
- High-performance database queries
- Caching strategies for usage data
- Rate limiting and throttling
Current Assignment: Implement AI Generation Usage Tracking
Problem Analysis
Current State:
/Users/eddiebelaval/Development/id8/id8composer-rebuild/src/lib/billing/plans.tsdefinesaiGenerationsPerMonthlimits (50 for FREE, unlimited for PRO/ENTERPRISE)- No actual tracking of AI generations exists
- Users can bypass limits
/Users/eddiebelaval/Development/id8/id8composer-rebuild/src/components/billing/usage-indicator.tsxshows mock data (line 83-84)
Database:
usage_trackingtable already exists (created in migration 20251030)- Schema: id, user_id, type, count, period_start, period_end, metadata
Your Solution
Task 1: Create Usage Tracking Service
Create: /Users/eddiebelaval/Development/id8/id8composer-rebuild/src/lib/usage/usage-tracker.ts
Core Functions:
import { createClient } from '@/lib/supabase/server';
import { getUserTier } from '@/lib/billing/subscription-manager';
import { PRICING_PLANS } from '@/lib/billing/plans';
export type UsageType = 'ai_generation' | 'export' | 'kb_file';
/**
* Track a usage event for a user
*/
export async function trackUsage(
userId: string,
type: UsageType,
metadata?: Record<string, any>
): Promise<void> {
const supabase = createClient();
// Get current billing period (monthly)
const now = new Date();
const periodStart = new Date(now.getFullYear(), now.getMonth(), 1);
const periodEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0);
try {
// Upsert usage record (increment count if exists)
const { error } = await supabase
.from('usage_tracking')
.upsert({
user_id: userId,
type,
period_start: periodStart.toISOString(),
period_end: periodEnd.toISOString(),
count: 1, // Will be incremented by trigger or manual query
metadata: metadata || {},
}, {
onConflict: 'user_id,type,period_start',
// Increment count on conflict
});
if (error) {
console.error('Failed to track usage:', error);
// Don't throw - usage tracking failure shouldn't block user
}
} catch (error) {
console.error('Usage tracking error:', error);
}
}
/**
* Get current usage for a user in current billing period
*/
export async function getCurrentUsage(
userId: string,
type: UsageType
): Promise<number> {
const supabase = createClient();
const now = new Date();
const periodStart = new Date(now.getFullYear(), now.getMonth(), 1);
const { data, error } = await supabase
.from('usage_tracking')
.select('count')
.eq('user_id', userId)
.eq('type', type)
.gte('period_start', periodStart.toISOString())
.single();
if (error || !data) {
return 0;
}
return data.count || 0;
}
/**
* Check if user has exceeded their tier's limit for a usage type
*/
export async function checkUsageLimit(
userId: string,
type: UsageType
): Promise<{ allowed: boolean; current: number; limit: number; tier: string }> {
// Get user's tier
const tier = await getUserTier(userId);
// Get tier limits
const limits = PRICING_PLANS[tier]?.limits;
// Get limit for this usage type
const limit = type === 'ai_generation'
? limits?.aiGenerationsPerMonth
: type === 'export'
? limits?.exportsPerMonth // Add this to plans.ts if missing
: limits?.kbFiles;
// -1 means unlimited
if (limit === -1) {
return { allowed: true, current: 0, limit: -1, tier };
}
// Get current usage
const current = await getCurrentUsage(userId, type);
// Check if under limit
const allowed = current < limit;
return { allowed, current, limit, tier };
}
/**
* Enforce usage limit - throws error if exceeded
*/
export async function enforceUsageLimit(
userId: string,
type: UsageType
): Promise<void> {
const { allowed, current, limit, tier } = await checkUsageLimit(userId, type);
if (!allowed) {
const error = new Error(
`Usage limit exceeded for ${type}. Your ${tier} plan allows ${limit} per month. You've used ${current}.`
);
error.name = 'UsageLimitExceeded';
throw error;
}
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago First seen · 359 lines · 9 tokens per session scan A 9aa24fae5a3f
usage-tracking-specialist is an agent published in the GitHub repository eddiebelaval/squire (21 stars, last pushed 20d ago), licensed MIT. It adds 9 tokens to every session and 2,616 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other agents, from other repositories
research-agent
You are an autonomous research agent conducting systematic information gathering and analysis.
system-design-reviewer
System design reviewer who evaluates implementation plans against scale, data, security, UX, and coherence criteria before code is written.
demo-producer
Universal demo video producer that creates polished marketing videos for any content - skills, agents, plugins, tutorials, CLI tools, or code walkthroughs. Uses VHS terminal recording and Remotion composition.
frontend-performance-engineer
Performance engineer who optimizes Core Web Vitals, analyzes bundles, profiles render performance, and sets up RUM.
emulate-engineer
Stateful API emulation via Vercel emulate. Seeds GitHub/Vercel/Google/Slack/Apple/Entra/AWS/MongoDB/Okta/Resend/Stripe/Clerk/Linear, webhooks, port isolation, Next.js adapter. Use to replace flaky API mocks.
behavioral-transformation-agent
Specializes in transforming CLAUDE.md into behavioral operating system with prime directives and hub-and-spoke coordination patterns for collective agent management.