Community程式設計與開發github.com

lobehub/debug

Debug 套件使用指南。適用於新增偵錯日誌、理解日誌命名空間或實作除錯功能。由偵錯日誌請求或日誌實作觸發。

debug 是什麼?

此技能提供關於 `debug` 套件的完整使用指南,專為需要在專案中加入偵錯日誌、管理日誌命名空間或實作除錯功能的開發者設計。它涵蓋了從基本安裝、啟用/停用日誌、命名空間匹配模式,到進階主題如著色輸出、動態啟用與瀏覽器相容性等。技能強調整合到主流開發環境(包括 Cursor、Claude Code 等),支援 Node.js 與瀏覽器環境,並說明日誌輸出如何根據 `DEBUG` 環境變數控制。透過此技能,用戶可以減少對 `console.log` 的依賴,實現更高效、更具結構性的除錯流程,特別適合大型專案或需要細粒度控制日誌輸出的場景。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lobehub/lobehub/tree/main/skills/debug

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

debug 是做什麼的?

Debug 套件使用指南。適用於新增偵錯日誌、理解日誌命名空間或實作除錯功能。由偵錯日誌請求或日誌實作觸發。

簡介

debug 是一個輕量級的 Node.js 與瀏覽器偵錯工具,透過命名空間機制讓你輕鬆控制哪些日誌應該輸出。它模仿了 Node.js 核心的除錯方式,常用於 libraries 與應用程式中以提供可開關的內部除錯資訊。

安裝

npm install debug

基本用法

在你的模組中引入 debug 並建立一個除錯器實例:

const debug = require('debug')('myapp:server');

debug('伺服器啟動中...');

命名空間

命名空間以冒號 (:) 分隔層級。例如:

  • myapp:server
  • myapp:server:db
  • myapp:client

啟用除錯日誌

透過 DEBUG 環境變數控制:

# 啟用 myapp 命名空間下所有日誌
DEBUG=myapp:* node app.js

# 啟用多個命名空間
DEBUG=myapp:server,express:* node app.js

# 啟用所有日誌(不建議生產環境使用)
DEBUG=* node app.js

進階功能

顏色輸出

每個命名空間會自動分配顏色以區分輸出。

動態啟用

你也可以在執行時動態啟用:

debug.enable('myapp:*');

瀏覽器相容性

在瀏覽器環境中,debug 會使用 localStorage 儲存啟用設定:

localStorage.debug = 'myapp:*';

與開發環境整合

此技能針對 Cursor、Claude Code 與其他支援 Markdown 技能定義的開發環境進行了最佳化。當你提出關於偵錯日誌或除錯功能的請求時,此技能將自動觸發並提供相關指引。

參考資源

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

lobehub/add-provider-doc

Add documentation for a new AI provider — usage docs, env vars, Docker config, image resources.

lobehub/add-setting-env

Add server-side environment variables that control default values for user settings.

lobehub/desktop

Electron desktop development guide — IPC handlers, controllers, preload scripts, window/menu management.

lobehub/drizzle

LobeHub Drizzle ORM schema and query style. Use for pgTable schemas, indexes, joins, inferred types, db.select/db.query, schema fields, foreign keys, junction tables, or postgres query patterns.

lobehub/hotkey

Add or edit LobeHub keyboard shortcuts. Use for HotkeyEnum, HOTKEYS_REGISTRATION, combineKeys, useHotkeyById, tooltip hotkeys, shortcut scope, conflicts, or Cmd/Ctrl key combos.

lobehub/i18n

LobeHub i18n with react-i18next. Use for user-facing strings, locale keys, namespaces, useTranslation, t(), interpolation, zh-CN/en-US previews, hardcoded UI copy, or pnpm i18n.

lobehub/linear

Linear issue management. Use for LOBE-xxx issues, Linear links, PRs referencing Linear, retrieving issues, updating status, completion comments, or sub-issue trees.

lobehub/lobehub

Use for public LobeHub website documentation under docs/**, including self-hosting, deployment, migration, and configuration guides. Excludes product changelogs and source-code API docs.

lobehub/microcopy

UI copy and microcopy guidelines. Use for user-facing copy, buttons, errors, empty states, onboarding, i18n wording, translation, or copy improvements in Chinese or English.

lobehub/modal

LobeHub imperative modal conventions. Use when creating or migrating modals, dialogs, popups, confirm flows, ModalHost wiring, createModal, confirmModal, useModalContext, or base-ui modal APIs.

lobehub/pr

Create a PR for the current branch (targets `canary` by default), including splitting one cross-layer branch into ordered stacked PRs so a lower layer (db / shared package / server TRPC) merges before its callers (desktop / CLI / UI). Use when the user asks to create / submit a PR, or to split a branch because clients call a server contract that isn't on the trunk yet. Triggers on 'pr', 'create pr', 'submit pr', 'open a PR', 'pull request', 'split this PR', 'stacked PR', 'backend should merge first', '提 PR', '提个 PR', '新建 PR', '拆 PR', '后端先合', '分层合并'.

lobehub/project-overview

LobeHub open-source monorepo architecture map. Use when locating code layers, understanding apps/packages/src layout, business stubs, project structure, or onboarding to the repository.

lobehub/react

LobeHub React component conventions. Use when editing TSX UI, choosing base-ui vs @lobehub/ui vs antd, styling with antd-style, routing, desktop variants, layouts, or component state.

lobehub/store-data-structures

LobeHub Zustand store data-shape patterns. Use when designing store state, list/detail splits, normalized maps, reducers, messagesMap, topicsMap, or choosing shared type sources.

lobehub/testing

Vitest testing guide. Use when writing or updating tests, fixing failing tests, improving coverage, debugging test issues, or setting up mocks.

lobehub/typescript

LobeHub TypeScript style and type-safety guide. Use when editing TS/TSX/MTS, fixing types, choosing interface vs type, avoiding any/object, import type, async flow, or ts-expect-error.

lobehub/upstash-workflow

LobeHub Upstash Workflow and QStash guide. Use for async workflows, process/paginate/execute fan-out, serve handlers, context.run/call/sleep, or workflow triggers.

lobehub/version-release

Version release workflow — release process and GitHub Release notes (not docs/changelog pages).

lobehub/zustand

LobeHub Zustand store conventions. Use when editing src/store, store slices, public/internal actions, dispatch actions, flattenActions, optimistic updates, selectors, maps, or class action migration.

相關技能