2.4 KiB
2.4 KiB
allowed-tools: Read, Write, Edit, MultiEdit, Grep, Glob, Bash
description: Enforce logging discipline protocol - eliminate console statements and implement structured logging
argument-hint: [TARGET_DIRECTORY] [LANGUAGE] [CHECK_ONLY]
Enforce Logging Discipline
Scan TARGET_DIRECTORY for logging violations, eliminate all console statements, and implement structured logging following the discipline protocol. Save enforcement report to OUTPUT_DIRECTORY with violations found and fixes applied.
Variables:
TARGET_DIRECTORY: $1 LANGUAGE: $2 CHECK_ONLY: $3 OUTPUT_DIRECTORY: .claude/data/ PROTOCOL_FILE: ai-docs/logging-discipline.md
Instructions:
- Read
PROTOCOL_FILEto understand the complete logging discipline requirements - Scan
TARGET_DIRECTORYfor console.*, print(), and other logging violations - For
LANGUAGEJavaScript/TypeScript: configure ESLint no-console rule and implement Pino logger - For
LANGUAGEPython: configure Ruff rules and implement structlog - If
CHECK_ONLYis true, report violations without making changes - Apply all fixes following the protocol's structured logging patterns
- Generate enforcement report with before/after comparison
Workflow:
- Read
PROTOCOL_FILEto understand logging discipline requirements - Use Grep to scan
TARGET_DIRECTORYfor console.log, console.error, print() violations - Identify
LANGUAGEfrom file extensions (.js, .ts, .py) if not specified - Check existing logger configuration (ESLint, Pino, structlog)
- If
CHECK_ONLYis false, configure appropriate linting rules forLANGUAGE - Install and configure structured logging library (Pino for JS/TS, structlog for Python)
- Use MultiEdit to replace all console.* statements with structured logger calls
- Ensure stdout/stderr separation follows protocol requirements
- Add correlation IDs and redaction configuration
- Run linting validation to confirm no violations remain
- Generate enforcement report with violations count and fixes applied
- Save report to
OUTPUT_DIRECTORY/logging-discipline-report.md
Report:
Logging Discipline Enforced
File: OUTPUT_DIRECTORY/logging-discipline-report.md
Target: TARGET_DIRECTORY (LANGUAGE files)
Violations Fixed:
- Console statements eliminated: [count]
- Structured logging implemented: [yes/no]
- ESLint/Ruff rules configured: [yes/no] Protocol Compliance: [compliant/violations remaining]
Relevant Files:
- [@ai-docs/logging-discipline.md]