AgentSkillsCN

debug-with-logger

在调试测试失败、探究行为表现,或使用BreakdownLogger输出运行测试时使用此功能。它可引导3阶段调试流程与环境控制。触发词包括:“debug”“デバッグ”“test failure”“テスト失敗”“investigate”“調査”“LOG_LEVEL”“LOG_KEY”。

SKILL.md
--- frontmatter
name: debug-with-logger
description: Use when debugging test failures, investigating behavior, or running tests with BreakdownLogger output. Guides the 3-phase debugging workflow and environment controls. Trigger words - 'debug', 'デバッグ', 'test failure', 'テスト失敗', 'investigate', '調査', 'LOG_LEVEL', 'LOG_KEY'.
allowed-tools: Read, Grep, Glob, Bash

Debug with Logger

3つの直交する制御次元(level×length×key)を段階的に絞り込むことで、根本原因を効率的に特定する。

制御次元

変数問い
LOG_LEVEL深刻度debug/info/warn/error
LOG_LENGTH詳細度未設定/S/L/W
LOG_KEYコンポーネントカンマ区切り(完全一致)

3フェーズ

bash
# Phase 1: エラーのみで障害箇所を特定
LOG_LEVEL=error deno test --allow-env --allow-read --allow-write
# Phase 2: KEYで絞り込み
LOG_LEVEL=debug LOG_KEY=<key> LOG_LENGTH=S deno test --allow-env --allow-read --allow-write
# Phase 3: 特定箇所の全量確認
LOG_LEVEL=debug LOG_KEY=<key> LOG_LENGTH=W deno test --allow-env --allow-read --allow-write tests/<file>_test.ts

KEY検索

bash
grep -rn 'new BreakdownLogger(' --include='*.ts' | grep -oP '"[^"]*"' | sort -u

トラブルシュート

出力なし→LOG_LEVEL確認 / 出力過多→LOG_KEY追加 / 切り詰め→LOG_LENGTH上げる / KEY不明→ソースgrep / モジュール横断→LOG_KEY=key1,key2

ERRORはstderr、他はstdout。2> stderr.logでエラー分離、2>&1 | tee debug.logで全量取得。調査中ロガーはfix-<id>キーで作成し、deno run --allow-read jsr:@tettuan/breakdownlogger/validate .で本番混入を防ぐ。