Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
athola avatar

Usage Logging

  • 95 installs
  • 325 repo stars
  • Updated August 2, 2026
  • athola/claude-night-market

Standardize JSONL usage logs for agent sessions—tokens, duration, success, and rich metadata—so you can jq-query cost and failure patterns later.

About

usage-logging (documented as log-formats in SKILL.md) is a reference skill for structured agent and service usage telemetry written as JSONL. Solo builders running Claude Night Market–style automations use it when every shell or API invocation should leave a comparable audit trail: ISO timestamps, session identifiers, operation names, token counts, boolean success, durations, and optional metadata blocks tuned for file batches or model calls. The skill is not a logger implementation—it prescribes schemas and bash/jq patterns so you can grep a day, compute success ratios, or surface expensive operations without inventing a new format per project. It pairs naturally with grow-phase analytics and operate-phase incident review when failures spike. Install it when you are about to wire hooks or scripts that emit usage.jsonl and want agents to append consistent fields rather than ad-hoc printf lines.

  • Standard JSONL entry fields: timestamp, session_id, service, operation, tokens, success, duration_seconds, metadata
  • Dedicated error entry shape with error_type and error_message when success is false
  • Metadata patterns for file ops (files_processed, total_bytes, file_types) and API ops (model, input_tokens, output_token
  • jq query recipes for time range, success rate, failures-only, high-token ops, and token sums

Usage Logging by the numbers

  • 95 all-time installs (skills.sh)
  • Ranked #4,606 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/athola/claude-night-market --skill usage-logging

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs95
repo stars325
Security audit2 / 3 scanners passed
Last updatedAugust 2, 2026
Repositoryathola/claude-night-market

What it does

Standardize JSONL usage logs for agent sessions—tokens, duration, success, and rich metadata—so you can jq-query cost and failure patterns later.

Files

SKILL.mdMarkdownGitHub ↗

Table of Contents

Usage Logging

Overview

Session-aware logging infrastructure for tracking operations across plugins. Provides structured JSONL logging with automatic session management for audit trails and analytics.

When To Use

  • Need audit trails for operations
  • Tracking costs across sessions
  • Building usage analytics
  • Debugging with operation history

When NOT To Use

  • Simple operations without logging needs

Core Concepts

Session Management

Sessions group related operations:

  • Auto-created on first operation
  • Timeout after 1 hour of inactivity
  • Unique session IDs for tracking

Log Entry Structure

{
  "timestamp": "2025-12-05T10:30:00Z",
  "session_id": "session_1733394600",
  "service": "my-service",
  "operation": "analyze_files",
  "tokens": 5000,
  "success": true,
  "duration_seconds": 2.5,
  "metadata": {}
}

Verification: Run the command with --help flag to verify availability.

Quick Start

Initialize Logger

from leyline.usage_logger import UsageLogger

logger = UsageLogger(service="my-service")

Verification: Run the command with --help flag to verify availability.

Log Operations

logger.log_usage(
    operation="analyze_files",
    tokens=5000,
    success=True,
    duration=2.5,
    metadata={"files": 10}
)

Verification: Run the command with --help flag to verify availability.

Query Usage

# Recent operations
recent = logger.get_recent_operations(hours=24)

# Usage summary
summary = logger.get_usage_summary(days=7)
print(f"Total tokens: {summary['total_tokens']}")
print(f"Total cost: ${summary['estimated_cost']:.2f}")

# Recent errors
errors = logger.get_recent_errors(count=10)

Verification: Run the command with --help flag to verify availability.

Integration Pattern

# In your skill's frontmatter
dependencies: [leyline:usage-logging]

Verification: Run the command with --help flag to verify availability.

Standard integration flow: 1. Initialize logger for your service 2. Log operations after completion 3. Query for analytics and debugging

Log Storage

Default location: ~/.claude/leyline/usage/{service}.jsonl

# View recent logs
tail -20 ~/.claude/leyline/usage/my-service.jsonl | jq .

# Query by date
grep "2025-12-05" ~/.claude/leyline/usage/my-service.jsonl

Verification: Run the command with --help flag to verify availability.

Detailed Resources

  • Session Patterns: See modules/session-patterns.md for session management
  • Log Formats: See modules/log-formats.md for structured formats

Exit Criteria

  • Operation logged with all required fields
  • Session tracked for grouping
  • Logs queryable for analytics

Related skills

FAQ

Is Usage Logging safe to install?

skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

AI & Agent Buildingmonitoringinfra

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.