lobe-editor / rules
Cursor rule180 starsChanged 12 days agoMITView on GitHub
Debug logging standards and usage guidelines for LobeHub Editor
- Reads credentials
We split this debug-logging.mdc into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 78
Keep messages short and avoid logging inside hot loops.
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Debug logging standards and usage guidelines for LobeHub Editor
---
# Debug Logging Standards
LobeHub Editor uses the [debug](https://www.npmjs.com/package/debug) package. All helpers live
in [src/utils/debug.ts](mdc:src/utils/debug.ts).
## Usage
```typescript
import { createDebugLogger } from '@/utils/debug';
const logger = createDebugLogger('plugin', 'my-plugin'); // namespace: lobe-editor:plugin:my-plugin
logger.debug('Processing data'); // lobe-editor:plugin:my-plugin (alias: logger.log)
logger.info('Plugin initialized'); // lobe-editor:plugin:my-plugin:info
logger.warn('Deprecated option'); // lobe-editor:plugin:my-plugin:warn -> console.warn
logger.error('Operation failed:', error); // lobe-editor:plugin:my-plugin:error -> console.error
```
`warn` / `error` use the native console methods (for dev tool filtering) but, like `debug` /
`info`, only print when their namespace is enabled.
Common categories:
```typescript
// Kernel plugins
createDebugLogger('plugin', 'link');
// Services
createDebugLogger('service', 'markdown');
// React code
createDebugLogger('react');
```
`debugLoggers` provides ready-made loggers for `demo`, `file`, `image`, `kernel`, `markdown`,
`math`, `mention`, `plugin`, `react`, `service`, `slash` and `upload`.
## Other Helpers
- `devConsole.{log,info,warn,error}`: plain console output only when
`process.env.NODE_ENV === 'development'` (`isDev`). Use it in demos.
- `prodSafeLogger`: `error` / `warn` always print; `debug` / `info` go through the kernel logger.
- `browserDebug.enable(namespaces = 'lobe-editor:*')`, `browserDebug.disable()`,
`browserDebug.getConfig()`, `browserDebug.showCategories()`: toggle and inspect logging in the
browser via `localStorage.debug`.
## Enabling Output
```bash
# Node (tests, headless): DEBUG environment variable (see .env.example)
DEBUG=lobe-editor:*
DEBUG=lobe-editor:kernel,lobe-editor:plugin:*
DEBUG=lobe-editor:*,-lobe-editor:demo
DEBUG=lobe-editor:*:error,lobe-editor:*:warn
```
```javascript
// Browser console
localStorage.debug = 'lobe-editor:*'; // then reload
```
## Namespaces in Use
- `lobe-editor:kernel`
- `lobe-editor:plugin:<name>` (e.g. `markdown`, `litexml`, `link`, `image`, `upload`, `math`)
- `lobe-editor:service:<name>` (e.g. `markdown`, `slash`, `node-identity`)
- `lobe-editor:react`, `lobe-editor:react-plugin:<name>`
- Top-level categories from `debugLoggers` (`lobe-editor:upload`, `lobe-editor:demo`, ...)
## Rules
1. Library code uses `createDebugLogger` (or `debugLoggers`), not bare `console.log`.
2. Demo files may use `devConsole`.
3. `info` for major events, `warn` for recoverable issues, `error` for failures, `debug`
sparingly for tracing.
4. Keep messages short and avoid logging inside hot loops.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/coding-standards.mdcCursor rule
- .cursor/rules/documentation-standards.mdcCursor rule
- .cursor/rules/environment-setup.mdcCursor rule
- .cursor/rules/hotkey-standards.mdcCursor rule
- .cursor/rules/plugin-development.mdcCursor rule
- .cursor/rules/project-structure.mdcCursor rule
- .cursor/rules/react-development.mdcCursor rule
- building-landing-homeSkill
- using-docs-kitSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

