Community编程与开发github.com

lobehub/debug

调试包使用指南。用于添加调试日志、理解日志命名空间或实现调试功能。当遇到调试日志请求或日志实现时触发。

debug 是什么?

此技能提供了关于如何使用 `debug` 包的全面指南,`debug` 是一个在 Node.js 和浏览器环境中广泛使用的轻量级调试日志工具。它适用于需要在代码中添加调试日志、配置日志命名空间以进行细粒度控制或实现自定义调试功能的开发者。该技能支持解析命名空间模式(如通配符和排除规则),并解释了如何通过 `DEBUG` 环境变量或 `localStorage` 启用日志。其文档涵盖了常见模式,如使用命名空间分层组织日志、通过颜色区分不同模块的输出,以及在生产环境中禁用日志的最佳实践。此技能与所有 AI 代理平台(如 Claude Code、Cursor 等)兼容,可帮助开发者快速集成调试日志功能。

兼容平台~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 包是一个小型但功能强大的 JavaScript 调试工具,受 Node.js 核心调试技术启发。它允许您通过命名空间启用或禁用特定模块的日志输出。

安装

npm install debug

基本用法

const debug = require('debug');

const log = debug('myapp:server');
const error = debug('myapp:error');

log('服务器启动中...');
error('数据库连接失败');

命名空间

命名空间以冒号分隔的层级结构组织日志:

  • myapp:* - 匹配所有 myapp 命名空间
  • myapp:server - 仅匹配服务器日志
  • myapp:-server - 排除服务器日志
  • * - 匹配所有命名空间

启用日志

通过环境变量 (Node.js)

DEBUG=myapp:* node app.js

通过 localStorage (浏览器)

localStorage.debug = 'myapp:*';

高级功能

  • 命名空间通配符支持 (* 和 ?)
  • 排除特定命名空间 (使用 - 前缀)
  • 颜色编码输出
  • 时间戳和格式化

最佳实践

  • 使用有意义的命名空间名称,如 app:module:function
  • 不要在控制语句中调用调试函数,以避免性能问题
  • 在部署到生产环境前禁用所有调试日志
  • 利用命名空间组合进行精细控制

参考资料

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.

相关技能