Back to catalog

pipeline-logger

Skill from fstr21/sportsbot

  • Category: discovered
  • Tags: github, community
  • Version: 1.0.0
  • Author: walid
  • Downloads: 0
  • Updated: 2025-11-22

Download the latest version (v1.0.0) from this page.

SKILL.md

# Pipeline Logger Skill

**Purpose**: Automatically add structured logging and retry logic to sportsbot pipeline scripts.

## When Claude Should Use This Skill

Use this skill when:
- User asks to "add logging" or "improve logging" to scripts
- User wants to "make NHL/NCAAF/Soccer work like NFL" (NFL already has logging)
- Working on TODO items about extending validation/logging to other sports
- User mentions scripts aren't providing enough visibility/debugging info
- Refactoring any capture/package/derive script
- You notice a script using `print()` instead of structured logging

## What This Skill Does

1. **Analyzes** the Python script to understand its structure
2. **Adds imports** for structlog (structured logging) and tenacity (retry logic)
3. **Replaces** all `print()` statements with proper logger calls (logger.info/warning/error)
4. **Adds** `@conservative_retry` decorator to API call functions
5. **Adds** logger setup in main() function
6. **Preserves** all existing logic - no functional changes, only logging improvements
7. **Creates backup** of original file before modifying

## Critical Constraints

**MUST follow these rules** (from CLAUDE.md):
- Use Pydantic v1 syntax ONLY (user has v1.10.23)
- NO emoji in code (Windows environment - use ASCII like [OK], [FAIL])
- Use conservative retry settings (user on free tier for APIs)
- Follow existing code style in sportsbot project
- Never modify files in `artifacts/` directory (immutable by design)

## How to Use This Skill

**Example 1**: User says "add logging to NHL capture scripts"
- Claude identifies: `pipelines/nhl/capture/01_fetch_nhl_odds.py`, `02_fetch_nhl_stats.py`, `03_fetch_public_betting.py`
- Claude runs: `python .claude/skills/pipeline-logger/scripts/add_logging.py pipelines/nhl/capture/01_fetch_nhl_odds.py`
- Claude verifies: Check script still runs without errors
- Claude repeats for other scripts

**Example 2**: User says "make this script have better observability"
- Claude runs add_logging.py on the script
- Claude explains what was added (in plain English)

## Expected Outcome

After using this skill:
- Script writes structured JSON logs to `logs/{script_name}/YYYY-MM-DD.jsonl`
- API calls retry automatically on failure (conservative backoff)
- User can debug issues by reading logs instead of guessing
- User can see exactly what happened during pipeline runs

## Technical Details

The `add_logging.py` script:
- Inserts imports at top of file
- Finds API call functions and wraps with @conservative_retry
- Replaces print("message") with logger.info("message")
- Adds logger setup matching `01_fetch_nfl_odds.py` pattern
- Creates backup with .bak extension before modifying

## Success Criteria

Script is successful if:
- Original script backed up to `{script}.bak`
- Modified script has structlog imports
- Modified script has logger setup in main()
- Modified script uses logger.info/warning/error (not print)
- Modified script runs without errors
- Log file created in `logs/` directory when script runs