.claude/skills/ts-billing-automation/SKILL.md
Automate invoice generation, billing workflows, payment tracking, and revenue recognition for SaaS and service businesses. Use when building billing pipelines, usage-based invoicing, subscription management, payment reminders, or financial reporting. Trigger words: invoice, billing, payment, subscription, usage billing, revenue recognition, accounts receivable, payment reminder, overdue invoice, billing cycle, proration, Stripe billing.
npx skillsauth add eliferjunior/Claude billing-automationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill helps you build automated billing workflows covering invoice generation from usage data, PDF rendering, payment processing integration, dunning (payment failure handling), and financial reporting. It handles the complexity of proration, usage-based billing, multi-currency support, and tax calculation.
Determine the billing structure:
invoices (
id, customer_id, invoice_number, status,
billing_period_start, billing_period_end,
subtotal, tax_amount, total, currency,
due_date, paid_at, created_at
)
invoice_line_items (
id, invoice_id, description, quantity, unit_price,
amount, metadata_json
)
payments (
id, invoice_id, amount, currency, method,
processor_ref, status, paid_at
)
billing_events (
id, customer_id, event_type, quantity,
unit, timestamp, metadata_json
)
For each billing cycle:
1. Aggregate usage events for the billing period
2. Apply pricing rules (tiers, discounts, proration)
3. Calculate taxes based on customer location
4. Generate invoice record with line items
5. Render PDF with company branding
6. Send via email and store in customer portal
7. Initiate payment collection (auto-charge or payment link)
8. Handle payment success/failure with appropriate follow-up
Payment failed:
Day 0: Retry payment, send "payment failed" email
Day 3: Retry with updated payment method prompt
Day 7: Final retry, warn about service suspension
Day 14: Suspend service, send "account suspended" email
Day 30: Cancel subscription, final notice
User prompt:
Generate monthly invoices for our API platform. Customers are billed per API call with tiered pricing: first 10,000 calls free, 10,001-100,000 at $0.001 each, 100,001+ at $0.0005 each. Pull usage from our billing_events table and generate PDF invoices.
Agent output:
// services/InvoiceGenerator.js
class InvoiceGenerator {
constructor({ db, pdfRenderer, emailService, paymentProcessor }) {
this.db = db;
this.pdfRenderer = pdfRenderer;
this.emailService = emailService;
this.paymentProcessor = paymentProcessor;
}
async generateMonthlyInvoices(billingMonth) {
const customers = await this.db.getActiveCustomers();
const results = { generated: 0, skipped: 0, errors: [] };
for (const customer of customers) {
try {
const usage = await this.aggregateUsage(customer.id, billingMonth);
if (usage.totalCalls === 0) { results.skipped++; continue; }
const lineItems = this.calculateTieredPricing(usage.totalCalls);
const tax = await this.calculateTax(customer, lineItems);
const invoice = await this.db.createInvoice({
customerId: customer.id,
invoiceNumber: this.generateInvoiceNumber(billingMonth),
billingPeriodStart: billingMonth.start,
billingPeriodEnd: billingMonth.end,
lineItems,
subtotal: lineItems.reduce((sum, li) => sum + li.amount, 0),
taxAmount: tax.amount,
total: lineItems.reduce((sum, li) => sum + li.amount, 0) + tax.amount,
currency: 'USD',
dueDate: addDays(billingMonth.end, 30),
});
const pdf = await this.pdfRenderer.render('invoice', { invoice, customer });
await this.emailService.send(customer.email, 'invoice', { invoice, pdf });
results.generated++;
} catch (error) {
results.errors.push({ customerId: customer.id, error: error.message });
}
}
return results;
}
calculateTieredPricing(totalCalls) {
const items = [];
if (totalCalls <= 10000) {
items.push({ description: 'API calls (free tier)', quantity: totalCalls, unitPrice: 0, amount: 0 });
} else if (totalCalls <= 100000) {
items.push({ description: 'API calls (free tier)', quantity: 10000, unitPrice: 0, amount: 0 });
const paid = totalCalls - 10000;
items.push({ description: 'API calls (standard)', quantity: paid, unitPrice: 0.001, amount: paid * 0.001 });
} else {
items.push({ description: 'API calls (free tier)', quantity: 10000, unitPrice: 0, amount: 0 });
items.push({ description: 'API calls (standard)', quantity: 90000, unitPrice: 0.001, amount: 90 });
const bulk = totalCalls - 100000;
items.push({ description: 'API calls (volume)', quantity: bulk, unitPrice: 0.0005, amount: bulk * 0.0005 });
}
return items;
}
}
User prompt:
Implement a dunning workflow for failed subscription payments. Use Stripe for payment processing. Escalate from retry to email to service suspension.
Agent generates a complete dunning service with webhook handlers for invoice.payment_failed, configurable retry schedules, email templates for each escalation stage, and automatic subscription status management.
development
Expert guidance for Fireworks AI, the platform for running open-source LLMs (Llama, Mixtral, Qwen, etc.) with enterprise-grade speed and reliability. Helps developers integrate Fireworks' inference API, fine-tune models, and deploy custom model endpoints with function calling and structured output support.
development
Convert any website into clean, structured data with Firecrawl — API-first web scraping service. Use when someone asks to "turn a website into markdown", "scrape website for LLM", "Firecrawl", "extract website content as clean text", "crawl and convert to structured data", or "scrape website for RAG". Covers single-page scraping, full-site crawling, structured extraction, and LLM-ready output.
tools
Expert guidance for Firebase, Google's platform for building and scaling web and mobile applications. Helps developers set up authentication, Firestore/Realtime Database, Cloud Functions, hosting, storage, and analytics using Firebase's SDK and CLI.
development
When the user needs to build file upload functionality for a web application. Use when the user mentions "file upload," "image upload," "upload endpoint," "multipart upload," "presigned URL," "S3 upload," "file validation," "upload to cloud storage," or "accept user files." Handles upload endpoints, file validation (type, size, magic bytes), cloud storage integration, and upload status tracking. For image/video processing after upload, see media-transcoder.