Agent skill

Usage Logging

by athola in athola/claude-night-market

Implements structured usage logging and audit trails for cost and session tracking.

MITAuto-check passedData & Analytics

Install Usage Logging

skills CLI
$ npx skills add athola/claude-night-market --skill usage-logging -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install athola/claude-night-market usage-logging --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/athola/claude-night-market.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/leyline/skills/usage-logging .claude/skills/usage-logging && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
usage-logging
GitHub stars
342
Token cost
~896 tokens
SKILL.md length
218 words
Files
3
Skills in repo
159
Repo updated
First seen
Licence
MIT

At a glance

Implements structured usage logging and audit trails for cost and session tracking.

  • Works in 3 steps: Initialize logger for your service → Log operations after completion → Query for analytics and debugging
  • Adding audit trails
  • SKILL.md covers Overview, When To Use, When NOT To Use and Core Concepts, plus 5 more sections
  • Calls jq

What it does

Usage Logging is an agent skill from athola/claude-night-market. Implements structured usage logging and audit trails for cost and session tracking. Use when adding audit trails, usage analytics, or cost tracking to a skill.

Its SKILL.md is about 900 tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files (for example `modules/log-formats.md` and `modules/session-patterns.md`).

It sits in Data & Analytics, covering Product analytics and LLM cost and token optimization. The repository describes itself as: 23 Claude Code plugins: TDD enforcement hooks, git/PR workflows, spec-driven development, code review, project lifecycle, fix-from-error, maintenance automation, context… The licence is MIT.

When your agent uses it

  • Adding audit trails
  • Usage analytics
  • Cost tracking to a skill

Example prompts

  • “Use the usage-logging skill to implement structured usage logging and audit trails for cost and session tracking”
  • “/usage-logging”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

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

What it can do on your machine

Read from SKILL.md and the folder at commit 9f3eb00. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • jq

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Usage Logging loads about 896 tokens when it runs. Until then it costs about 43 tokens; SKILL.md has 218 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~43
When it runs · the whole SKILL.md, loaded when a task matches
~896

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from athola/claude-night-market at commit 9f3eb00, republished under its MIT licence (© athola). 218 words, ~896 tokens.

Download SKILL.mdSave it as .claude/skills/usage-logging/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
usage-logging
description
Implements structured usage logging and audit trails for cost and session tracking. Use when adding audit trails, usage analytics, or cost tracking to a skill.
alwaysApply
false
category
infrastructure
tags
logging, usage, audit, metrics, sessions, analytics
provides.infrastructure
usage-logging, session-management, audit-trails
provides.patterns
structured-logging, metrics-collection, cost-tracking
usage_patterns
audit-logging, cost-tracking, usage-analytics, session-management
complexity
beginner
model_hint
fast
estimated_tokens
450
progressive_loading
true

Usage Logging

Overview

Records individual call costs and usage events. For aggregate budget enforcement, use quota-management.

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
json
{
  "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
python
from leyline.usage_logger import UsageLogger

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

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

Log Operations
python
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
python
# 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

yaml
# 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

bash
# 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

© athola, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files in plugins/leyline/skills/usage-logging of athola/claude-night-market.

  • SKILL.md
  • modules/log-formats.md
  • modules/session-patterns.md

Open the folder on GitHubat commit 9f3eb00

Compare with similar skills

Usage Logging next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Usage Logging compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Usage Logging this skillathola/claude-night-market342—~896Automated safety check: PassMIT
Cv Usagetombelieber/claude-view110—~3.1kAutomated safety check: PassMIT
Posthog Instrumentationlangfuse/langfuse36k—~3.2kAutomated safety check: PassCustom licence
Venice Billingveniceai/skills143—~3.6kAutomated safety check: PassMIT
Segment CdpbenjaminasterA/antigravity-awesome-skills3681 repos~361Automated safety check: PassMIT
Tianji Read-Only Data Queriesmsgbyte/tianji3.1k—~1.5kAutomated safety check: PassApache-2.0

Similar skills

  • Cv Usage

    tombelieber/claude-view

    A skill your agent uses when the user asks about usage analytics, statistics, token usage, or cost summary — e.g.

    110 GitHub stars~3.1k tokensUpdated 7 days ago
    Data & AnalyticsAuto-check passed
  • Posthog Instrumentation

    langfuse/langfuse

    Product analytics with posthog. An agent skill from langfuse/langfuse.

    36k GitHub stars~3.2k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • Venice Billing

    veniceai/skills

    Venice billing and usage analytics - GET /billing/balance, GET /billing/usage-history (keyset-paginated per-request ledger, JSON or CSV), and GET /billing/usage-analytics (aggregated by…

    143 GitHub stars~3.6k tokensUpdated 2 days ago
    Data & AnalyticsAuto-check passed
  • Segment Cdp

    benjaminasterA/antigravity-awesome-skills

    Expert patterns for Segment Customer Data Platform including Analytics.js, server-side tracking, tracking plans with Protocols, identity resolution, destinations configuration, and data governance ...

    368 GitHub starsUsed in 1 repo~361 tokens
    Data & AnalyticsAuto-check passed
  • Answers questions about website traffic, monitors, surveys, events and billing from a Tianji instance using read-only GET calls checked against its live OpenAPI document.

    3.1k GitHub stars~1.5k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • PostHog CLI Queries

    debugtheworldbot/keyStats

    Runs HogQL queries against this project's PostHog data from the terminal using posthog-cli, with bundled scripts for dashboard metadata the CLI itself has no command for.

    1.5k GitHub stars~1.2k tokensUpdated 5 days ago
    Data & AnalyticsAuto-check passed

More from athola/claude-night-market

All 159 skills in this repo
  • Night Market Diagnostics Toolkit

    athola/claude-night-market

    Run and interpret repo diagnostic scripts (ratchets, validators, token stats).

    342 GitHub stars~3.4k tokensUpdated 2 days ago
    Auto-check passed
  • Skills Eval

    athola/claude-night-market

    Evaluate Claude skill quality through auditing. An agent skill from athola/claude-night-market.

    342 GitHub stars~1.6k tokensUpdated 2 days ago
    Auto-check passed
  • Agent Teams

    athola/claude-night-market

    Coordinates Claude agent teams via filesystem protocol. An agent skill from athola/claude-night-market.

    342 GitHub stars~2.5k tokensUpdated 2 days ago
    Auto-check passed
  • Delegation Core

    athola/claude-night-market

    Delegates execution to eight CLIs (Gemini, Qwen, MiniMax, GLM, Muse, Codex, OpenCode, Glimmer).

    342 GitHub stars~2.5k tokensUpdated 2 days ago
    Auto-check passed
  • Elegant Code

    athola/claude-night-market

    Guide minimal code via a decision ladder with full safety, edge, and negative-case coverage.

    342 GitHub stars~2.1k tokensUpdated 2 days ago
    Auto-check passed
  • Skill Library Mission

    athola/claude-night-market

    Build a project skill library in .claude/skills/ via discovery, parallel authoring, and review.

    342 GitHub stars~1.6k tokensUpdated 2 days ago
    Auto-check passed

Questions about Usage Logging

What does Usage Logging do?

Implements structured usage logging and audit trails for cost and session tracking. Usage Logging is an agent skill from athola/claude-night-market. Implements structured usage logging and audit trails for cost and session tracking.

When should I use Usage Logging?

Usage Logging fits situations like: adding audit trails; usage analytics; cost tracking to a skill.

How do I install Usage Logging in Claude Code?

Run `npx skills add athola/claude-night-market --skill usage-logging -a claude-code`. Or copy the skill folder (plugins/leyline/skills/usage-logging in athola/claude-night-market) into .claude/skills/usage-logging in your project. Claude Code loads it when a task matches its description.

How do I install Usage Logging in Codex?

Run `npx skills add athola/claude-night-market --skill usage-logging -a codex`. Or copy the skill folder (plugins/leyline/skills/usage-logging in athola/claude-night-market) into .agents/skills/usage-logging in your project. Codex loads it when a task matches its description.

Can I use Usage Logging in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add athola/claude-night-market --skill usage-logging -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/usage-logging, .gemini/skills/usage-logging, .github/skills/usage-logging and .opencode/skills/usage-logging in your project.

What does Usage Logging need to run?

Going by SKILL.md and its folder, Usage Logging needs the command-line tools its instructions call (jq). Our summary lists: Python 3.

Does Usage Logging access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Usage Logging safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Usage Logging use?

Usage Logging is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Usage Logging use?

About 896 tokens (SKILL.md is roughly 3.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Usage Logging?

Skills that share tags, products or a category with Usage Logging: Cv Usage (tombelieber/claude-view, 110 stars), Posthog Instrumentation (langfuse/langfuse, 36k stars), Venice Billing (veniceai/skills, 143 stars) and Segment Cdp (benjaminasterA/antigravity-awesome-skills, 368 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Usage Logging?

athola (a GitHub user) maintains it in athola/claude-night-market, which has 342 GitHub stars. The repository holds 159 skills in this directory. The repository was last updated on October 6, 2026.

Source: athola/claude-night-market on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.