/claude-leverage:log-structured [path] [--lang python|typescript|go|rust|auto]from claude-leverage
Audits legacy codebases for unstructured logging patterns (print, console.log, interpolated loggers) and suggests JSON-lines spec compliant replacements. Read-only audit.
Ships in claude-leverage. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Helps retrofit a codebase to the structured-logging spec from AGENTS.md:
{"ts":"2026-05-24T12:34:56.789Z","level":"info","trace_id":"a1b2c3","span_id":"4d5e6f","service":"billing","event":"invoice_paid","attrs":{"invoice_id":"inv_789"}}
Walks a target path, finds anti-patterns, and emits a structured report with file:line citations and concrete suggested replacements. Never modifies code — the user decides per-finding.
| Pattern | Why it's a problem | Suggested fix |
|---|---|---|
print(...) in production code | No level, no context, no structure | Replace with logger call |
console.log(...) in production code | Same; not structured | Replace with structured logger |
logger.X(f"user {id} did {action}") (Python) | Values baked into message → agent can't grep event=did_action | Move values to attrs={"user_id": id, "action": action} |
logger.x(`user ${id} did ${action}`) (TS/JS) | Same | logger.info("user_action", { user_id: id, action }) |
fmt.Printf("user %d ...", id) followed by log.Print | Same | slog.Info("user_action", "user_id", id) |
Missing trace_id propagation | Can't reconstruct request flow | Wire context-aware logger (template per lang) |
Logging to stdout in a service that should log structured (e.g., print in Flask handler) | Operator tooling can't parse | Wire JSON formatter |
Resolve target. Default . (whole repo). If $ARGUMENTS has a
path, use that. If --lang <name> is given, restrict scan to that
language; else auto-detect from file extensions.
Detect language(s) by file extension. Walk only files matching:
*.py (skip tests/, *_test.py, __pycache__)*.ts, *.tsx, *.js, *.jsx (skip
node_modules/, dist/, build/, *.test.*, *.spec.*)*.go (skip *_test.go, vendor/)*.rs (skip target/, tests/)Grep for anti-patterns in the scoped files. Use Grep tool with
the patterns documented per-language in
../../templates/logging/.
For each finding, emit:
file:line — current line — suggested replacementsee templates/logging/<lang>.md for the logger initSummary at the end:
# Structured logging audit — <YYYY-MM-DD>, <root>
## Findings
### src/billing/charge.py
- **line 47**: `print(f"charged user {user_id}")` →
`logger.info("user_charged", attrs={"user_id": user_id})`
See `templates/logging/python.md` for logger setup.
- **line 89**: `logger.error(f"failed: {e}")` →
`logger.error("charge_failed", attrs={"error": str(e), "trace_id": current_trace_id()})`
### src/api/handler.ts
- **line 23**: `console.log(`req from ${req.ip}`)` →
`logger.info("request_received", { ip: req.ip, route: req.path })`
See `templates/logging/typescript.md`.
## Summary
- 2 files scanned
- 3 findings (2 print/console.log, 1 message-interpolation)
- Language templates: see `templates/logging/{python,typescript}.md`
- This audit is read-only. Apply fixes incrementally — start with the
highest-traffic event types where structured logs pay off fastest.
## Out of scope
- Already-structured logs that just use the wrong field name conventions
(e.g., `userId` vs `user_id`) — that's a separate harmonization pass.
- Logger choice / library swap — this audit assumes you'll wire a
structured logger per the template; it doesn't force a specific library.
print legitimately (CLI output).from app.logger import logger if the project doesn't
have one.--include-tests, then scan them too.--lang <name> — restrict scan to one language.--include-tests — scan test files too.--max-findings <N> — cap output (default 100; large repos can
produce thousands of findings, most are noise after the first 50).Pairs naturally with /init-repo (which can drop the language template
into a new project) and with the AIDEV-NOTE convention (anchor the
non-obvious logging decisions in code).
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Python, TypeScript, JavaScript, Go, Rust
logging, structured-logging, code-audit, legacy-codebase, anti-patterns
npx claudepluginhub filip-podstavec/claude-leverage --plugin claude-leverage16 skills in this plugin
/adr-newUSE WHEN a load-bearing architectural decision is being made in conversation (database / framework / auth model / integration choice, or explicit rejection of an alternative) — one likely to be re-litigated in 6 months without the rationale. Bootstraps a numbered MADR ADR in `docs/adr/`, asks for context + decision + alternatives, updates the index. Immutable status once accepted. See `docs/adr/README.md` for the convention; full Do/Don't list in this SKILL body.
/arch-mapUSE WHEN setting up a repo for AI-first work, after a major directory restructure, or when an agent needs structured answers like "which modules are stable?" / "what's the public surface of X?" that the prose AGENTS.md doesn't give cheaply. Bootstraps or refreshes `architecture.yml` at repo root — machine-readable module metadata (path / role / stability / public_surface / depends_on / paired_with / owners). Hand-curated; the skill drafts, the user confirms. See ADR 0005 for why this file lives at root and why YAML over JSON.
/codex-sandboxUSE WHEN setting up Codex CLI in a project, tightening sandbox for prod/CI, or when user asks about Codex permissions. Interactive helper for per-project `.codex/config.toml`: `dev` / `prod` / `custom` profiles, idempotent via markers, preserves unmanaged config below the block. Codex-only artifact.
/conventions-initUSE WHEN setting up a repo for AI-first work (after /init-repo), or when the context-surface hook should start feeding repo conventions to agents before edits. Drafts `conventions.yml` at repo root: per-kind casing (inferred from the code), a vague-name denylist seed, directory roles, and a hand-filled house-rules block. Idempotent — never overwrites a populated file; re-running prints suggested additions for manual merge. Read-only on code; never invents house rules. After writing, run /refresh-context-map so the hook picks it up.
/dynamic-checkUSE WHEN the user explicitly asks to verify that this repo's DECLARED build/test/lint commands actually run ("does the quickstart work?", "validate the commands in AGENTS.md"), typically after /repo-doctor or /repo-doctor --semantic raised suspicion. Executes only commands the repo itself declares (AGENTS.md build/test blocks, README quickstart), with preview + explicit confirmation, denylist tripwire, and timeouts. Advisory — results never enter /repo-doctor's deterministic score (ADR 0012/0013). Opt-in by invocation; never fired by hooks or other skills.
/explain-diffUSE WHEN about to open a PR, when teammate asks "what's in this diff?", or when returning to a branch and needing self-orientation. Three modes: `--for pr|review|self`. Reads `git diff HEAD` (or passed range), returns 3–5 bullet plain-English narration. Read-only — defers security/test concerns to other skills.
Other plugins' skills for the same job