Skip to content

feat(plugin): add structured debug logging and skill progress reporting#179

Merged
onlycastle merged 8 commits intomainfrom
feat/plugin-debug-logging-20260320
Mar 21, 2026
Merged

feat(plugin): add structured debug logging and skill progress reporting#179
onlycastle merged 8 commits intomainfrom
feat/plugin-debug-logging-20260320

Conversation

@onlycastle
Copy link
Owner

Summary

  • Add environment-gated debug logger (BETTERPROMPT_DEBUG=1) that writes to stderr, preserving JSON-RPC on stdout
  • Instrument hooks, debounce state machine, config, native deps, and MCP server with structured debug/info/error calls
  • Standardize [bp] progress status lines across all 14 analysis skills
  • Enhance wrapToolExecution with tool-name tracking and duration metrics

Changes

  1. feat(plugin): add structured debug logger utility — new lib/logger.ts
  2. feat(plugin): instrument hooks and core libs with debug logging — hooks, config, debounce, native-deps
  3. feat(plugin): instrument MCP server with debug logging — server.ts, server-entry.ts
  4. feat(plugin): add progress reporting to analysis skills — 14 SKILL.md files
  5. chore(plugin): rebuild dist

Test Plan

  • TypeScript type-check passes (npx tsc --noEmit)
  • All 452 tests pass (npm test)
  • Build succeeds (npx tsup)
  • Manual: set BETTERPROMPT_DEBUG=1 and verify stderr logging output
  • Manual: run /bp-analyze and verify [bp] progress lines appear

Generated with Claude Code using /ship-it

onlycastle and others added 5 commits March 20, 2026 19:54
Environment-gated logging (BETTERPROMPT_DEBUG=1) that writes to stderr
to avoid interfering with JSON-RPC on stdout. Error-level logs always emit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add debug/info/error calls to session hooks, config resolution, debounce
state machine transitions, and native dependency installation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add tool-name and duration tracking to wrapToolExecution, plus startup
and shutdown lifecycle logs to the MCP server bootstrap.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Standardize [bp] status lines across all 14 analysis skills so users
see step-by-step progress during the analysis pipeline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@onlycastle
Copy link
Owner Author

Code Review

Found 2 issues:

  1. info() is gated identically to debug() — the 3-tier severity model is broken
    info and debug both no-op unless BETTERPROMPT_DEBUG=1, but info is used for operationally important events: server lifecycle (start/connected/shutdown), native dep installation, and bootstrap milestones. The logger establishes a debug < info < error hierarchy where only error is always-on, making the debug/info distinction meaningless. Consider making info always-on like error, or rename all info calls to debug to match actual behavior.
    https://github.com/onlycastle/BetterPrompt/blob/ec9b0ab/packages/plugin/lib/logger.ts#L25-L28

  2. New file and pipeline changes not documented in docs/agent/
    CLAUDE.md requires: "When you add new files, change directory structure, modify the pipeline... update the relevant docs/agent/ doc in the same change." A new shared module lib/logger.ts was added and the plugin pipeline was instrumented with debug logging, but docs/agent/PLUGIN.md and docs/agent/ARCHITECTURE.md were not updated to document BETTERPROMPT_DEBUG or the logger module.
    https://github.com/onlycastle/BetterPrompt/blob/ec9b0ab/packages/plugin/lib/logger.ts#L1

Generated with Claude Code

If useful, react with a thumbs-up. Otherwise, thumbs-down.

onlycastle and others added 3 commits March 20, 2026 23:10
The 3-tier logger (debug/info/error) had info gated identically to debug,
making the distinction meaningless. info is used for lifecycle events
(server start, native dep install) that should always be visible.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@onlycastle onlycastle merged commit 5ca7881 into main Mar 21, 2026
1 check passed
@onlycastle onlycastle deleted the feat/plugin-debug-logging-20260320 branch March 21, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant