Nm Leyline Usage Logging

v1.0.0

Consult this skill when implementing usage logging and audit trails

0· 48·1 current·1 all-time
Security Scan
VirusTotalVirusTotal
Pending
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name and description (usage logging, audit trails) align with the provided SKILL.md and module content. The skill documents session management, log schemas, read/write patterns, and query helpers — all coherent with a logging/audit helper.
Instruction Scope
Instructions and example code stay within logging concerns: creating/updating a session.json, appending/reading JSONL log files at ~/.claude/leyline/usage/{service}.jsonl, and query helpers. There are no instructions to call external endpoints, request unrelated system state, or exfiltrate data.
Install Mechanism
No install spec and no code files to execute beyond the included examples. As an instruction-only skill, it does not download or install external artifacts.
Credentials
The skill declares no required environment variables, credentials, or config paths. Its filesystem usage (per-user home directory logs) is proportional to the described function.
Persistence & Privilege
The skill is not always-enabled and does not request elevated or cross-skill configuration. Its persistent footprint (per-user log files under ~/.claude/leyline/usage/) is appropriate for a logging tool.
Assessment
This skill appears coherent and local-only, but note it writes and reads log files under your home directory. Before using: (1) ensure logs won't contain secrets or sensitive data, (2) set appropriate file permissions on ~/.claude/leyline/usage/ to limit access, (3) implement log rotation or retention to avoid unbounded growth, and (4) if you need centralized/secure storage, adapt the examples to send logs to a secure service rather than leaving them in plaintext. If you need further assurance, ask for the actual implementation (the UsageLogger class) to review exact IO and error handling behavior.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

🦞 Clawdis
latestvk97fvbav4gjfwrrjym4bhzzdgx84tv9y
48downloads
0stars
1versions
Updated 6d ago
v1.0.0
MIT-0

Night Market Skill — ported from claude-night-market/leyline. For the full experience with agents, hooks, and commands, install the Claude Code plugin.

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

Troubleshooting

Common Issues

Command not found Ensure all dependencies are installed and in PATH

Permission errors Check file permissions and run with appropriate privileges

Unexpected behavior Enable verbose logging with --verbose flag

Comments

Loading comments...