home / skills / lobehub / lobe-chat / debug
This skill helps you implement and interpret debug logging with namespace conventions and format specifiers for efficient troubleshooting.
npx playbooks add skill lobehub/lobe-chat --skill debugReview the files below or copy the command above to add this skill to your agents.
---
name: debug
description: Debug package usage guide. Use when adding debug logging, understanding log namespaces, or implementing debugging features. Triggers on debug logging requests or logging implementation.
user-invocable: false
---
# Debug Package Usage Guide
## Basic Usage
```typescript
import debug from 'debug';
// Format: lobe-[module]:[submodule]
const log = debug('lobe-server:market');
log('Simple message');
log('With variable: %O', object);
log('Formatted number: %d', number);
```
## Namespace Conventions
- Desktop: `lobe-desktop:[module]`
- Server: `lobe-server:[module]`
- Client: `lobe-client:[module]`
- Router: `lobe-[type]-router:[module]`
## Format Specifiers
- `%O` - Object expanded (recommended for complex objects)
- `%o` - Object
- `%s` - String
- `%d` - Number
## Enable Debug Output
### Browser
```javascript
localStorage.debug = 'lobe-*';
```
### Node.js
```bash
DEBUG=lobe-* npm run dev
DEBUG=lobe-* pnpm dev
```
### Electron
```typescript
process.env.DEBUG = 'lobe-*';
```
## Example
```typescript
// src/server/routers/edge/market/index.ts
import debug from 'debug';
const log = debug('lobe-edge-router:market');
log('getAgent input: %O', input);
```
This skill documents how to use the debug package for consistent, namespaced logging across the codebase. It explains namespace conventions, format specifiers, and how to enable debug output in browser, Node, and Electron environments. Use it to add targeted debug statements without cluttering production logs.
It shows how to create a logger with debug('lobe-[component]:[module]') and then call log(...) with format specifiers for structured output. The guide defines standard namespaces for desktop, server, client, and routers so log output can be filtered by area. It also covers enabling debug output via localStorage, environment variables, or process.env depending on runtime.
How do I see logs only for one module?
Set the debug filter to that namespace, e.g., DEBUG=lobe-server:market or localStorage.debug = 'lobe-server:market' in the browser.
Which format specifier should I use for objects?
Use %O for expanded, detailed object output; %o is a compact object, %s for strings, %d for numbers.