Skip to content

Commit 346fc46

Browse files
authored
♻️ refactor: migrate AI Rules to Claude Code Skills (lobehub#11737)
♻️ refactor: migrate AI Rules to Claude Code Skills system Migrate all AI Rules from .cursor/rules/ to .agents/skills/ directory: - Move 23 skills to .agents/skills/ (main directory) - Update symlinks: .claude/skills, .cursor/skills, .codex/skills - Create project-overview skill from project documentation - Add references/ subdirectories for complex skills - Remove LobeChat references from skill descriptions - Delete obsolete .cursor/rules/ and .claude/commands/prompts/ directories Skills structure enables better portability and maintainability across AI tools.
1 parent ad34072 commit 346fc46

File tree

113 files changed

+2882
-5688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+2882
-5688
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
name: add-provider-doc
3+
description: Guide for adding new AI provider documentation. Use when adding documentation for a new AI provider (like OpenAI, Anthropic, etc.), including usage docs, environment variables, Docker config, and image resources. Triggers on provider documentation tasks.
4+
---
5+
6+
# Adding New AI Provider Documentation
7+
8+
Complete workflow for adding documentation for a new AI provider.
9+
10+
## Overview
11+
12+
1. Create usage documentation (EN + CN)
13+
2. Add environment variable documentation (EN + CN)
14+
3. Update Docker configuration files
15+
4. Update .env.example
16+
5. Prepare image resources
17+
18+
## Step 1: Create Provider Usage Documentation
19+
20+
### Required Files
21+
22+
- `docs/usage/providers/{provider-name}.mdx` (English)
23+
- `docs/usage/providers/{provider-name}.zh-CN.mdx` (Chinese)
24+
25+
### Key Requirements
26+
27+
- 5-6 screenshots showing the process
28+
- Cover image for the provider
29+
- Real registration and dashboard URLs
30+
- Pricing information callout
31+
- **Never include real API keys** - use placeholders
32+
33+
Reference: `docs/usage/providers/fal.mdx`
34+
35+
## Step 2: Update Environment Variables Documentation
36+
37+
### Files to Update
38+
39+
- `docs/self-hosting/environment-variables/model-provider.mdx` (EN)
40+
- `docs/self-hosting/environment-variables/model-provider.zh-CN.mdx` (CN)
41+
42+
### Content Format
43+
44+
```markdown
45+
### `{PROVIDER}_API_KEY`
46+
- Type: Required
47+
- Description: API key from {Provider Name}
48+
- Example: `{api-key-format}`
49+
50+
### `{PROVIDER}_MODEL_LIST`
51+
- Type: Optional
52+
- Description: Control model list. Use `+` to add, `-` to hide
53+
- Example: `-all,+model-1,+model-2=Display Name`
54+
```
55+
56+
## Step 3: Update Docker Files
57+
58+
Update all Dockerfiles at the **end** of ENV section:
59+
60+
- `Dockerfile`
61+
- `Dockerfile.database`
62+
- `Dockerfile.pglite`
63+
64+
```dockerfile
65+
# {New Provider}
66+
{PROVIDER}_API_KEY="" {PROVIDER}_MODEL_LIST=""
67+
```
68+
69+
## Step 4: Update .env.example
70+
71+
```bash
72+
### {Provider Name} ###
73+
# {PROVIDER}_API_KEY={prefix}-xxxxxxxx
74+
```
75+
76+
## Step 5: Image Resources
77+
78+
- Cover image
79+
- 3-4 API dashboard screenshots
80+
- 2-3 LobeChat configuration screenshots
81+
- Host on LobeHub CDN: `hub-apac-1.lobeobjects.space`
82+
83+
## Checklist
84+
85+
- [ ] EN + CN usage docs
86+
- [ ] EN + CN env var docs
87+
- [ ] All 3 Dockerfiles updated
88+
- [ ] .env.example updated
89+
- [ ] All images prepared
90+
- [ ] No real API keys in docs
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
name: add-setting-env
3+
description: Guide for adding environment variables to configure user settings. Use when implementing server-side environment variables that control default values for user settings. Triggers on env var configuration or setting default value tasks.
4+
---
5+
6+
# Adding Environment Variable for User Settings
7+
8+
Add server-side environment variables to configure default values for user settings.
9+
10+
**Priority**: User Custom > Server Env Var > Hardcoded Default
11+
12+
## Steps
13+
14+
### 1. Define Environment Variable
15+
16+
Create `src/envs/<domain>.ts`:
17+
18+
```typescript
19+
import { createEnv } from '@t3-oss/env-nextjs';
20+
import { z } from 'zod';
21+
22+
export const get<Domain>Config = () => {
23+
return createEnv({
24+
server: {
25+
YOUR_ENV_VAR: z.coerce.number().min(MIN).max(MAX).optional(),
26+
},
27+
runtimeEnv: {
28+
YOUR_ENV_VAR: process.env.YOUR_ENV_VAR,
29+
},
30+
});
31+
};
32+
33+
export const <domain>Env = get<Domain>Config();
34+
```
35+
36+
### 2. Update Type (if new domain)
37+
38+
Add to `packages/types/src/serverConfig.ts`:
39+
40+
```typescript
41+
import { User<Domain>Config } from './user/settings';
42+
43+
export interface GlobalServerConfig {
44+
<domain>?: PartialDeep<User<Domain>Config>;
45+
}
46+
```
47+
48+
**Prefer reusing existing types** from `packages/types/src/user/settings`.
49+
50+
### 3. Assemble Server Config (if new domain)
51+
52+
In `src/server/globalConfig/index.ts`:
53+
54+
```typescript
55+
import { <domain>Env } from '@/envs/<domain>';
56+
57+
export const getServerGlobalConfig = async () => {
58+
const config: GlobalServerConfig = {
59+
<domain>: cleanObject({
60+
<settingName>: <domain>Env.YOUR_ENV_VAR,
61+
}),
62+
};
63+
return config;
64+
};
65+
```
66+
67+
### 4. Merge to User Store (if new domain)
68+
69+
In `src/store/user/slices/common/action.ts`:
70+
71+
```typescript
72+
const serverSettings: PartialDeep<UserSettings> = {
73+
<domain>: serverConfig.<domain>,
74+
};
75+
```
76+
77+
### 5. Update .env.example
78+
79+
```bash
80+
# <Description> (range/options, default: X)
81+
# YOUR_ENV_VAR=<example>
82+
```
83+
84+
### 6. Update Documentation
85+
86+
- `docs/self-hosting/environment-variables/basic.mdx` (EN)
87+
- `docs/self-hosting/environment-variables/basic.zh-CN.mdx` (CN)
88+
89+
## Example: AI_IMAGE_DEFAULT_IMAGE_NUM
90+
91+
```typescript
92+
// src/envs/image.ts
93+
AI_IMAGE_DEFAULT_IMAGE_NUM: z.coerce.number().min(1).max(20).optional(),
94+
95+
// packages/types/src/serverConfig.ts
96+
image?: PartialDeep<UserImageConfig>;
97+
98+
// src/server/globalConfig/index.ts
99+
image: cleanObject({ defaultImageNum: imageEnv.AI_IMAGE_DEFAULT_IMAGE_NUM }),
100+
101+
// src/store/user/slices/common/action.ts
102+
image: serverConfig.image,
103+
104+
// .env.example
105+
# AI_IMAGE_DEFAULT_IMAGE_NUM=4
106+
```

.agents/skills/debug/SKILL.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: debug
3+
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.
4+
user-invocable: false
5+
---
6+
7+
# Debug Package Usage Guide
8+
9+
## Basic Usage
10+
11+
```typescript
12+
import debug from 'debug';
13+
14+
// Format: lobe-[module]:[submodule]
15+
const log = debug('lobe-server:market');
16+
17+
log('Simple message');
18+
log('With variable: %O', object);
19+
log('Formatted number: %d', number);
20+
```
21+
22+
## Namespace Conventions
23+
24+
- Desktop: `lobe-desktop:[module]`
25+
- Server: `lobe-server:[module]`
26+
- Client: `lobe-client:[module]`
27+
- Router: `lobe-[type]-router:[module]`
28+
29+
## Format Specifiers
30+
31+
- `%O` - Object expanded (recommended for complex objects)
32+
- `%o` - Object
33+
- `%s` - String
34+
- `%d` - Number
35+
36+
## Enable Debug Output
37+
38+
### Browser
39+
40+
```javascript
41+
localStorage.debug = 'lobe-*';
42+
```
43+
44+
### Node.js
45+
46+
```bash
47+
DEBUG=lobe-* npm run dev
48+
DEBUG=lobe-* pnpm dev
49+
```
50+
51+
### Electron
52+
53+
```typescript
54+
process.env.DEBUG = 'lobe-*';
55+
```
56+
57+
## Example
58+
59+
```typescript
60+
// src/server/routers/edge/market/index.ts
61+
import debug from 'debug';
62+
63+
const log = debug('lobe-edge-router:market');
64+
65+
log('getAgent input: %O', input);
66+
```

.agents/skills/desktop/SKILL.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
name: desktop
3+
description: Electron desktop development guide. Use when implementing desktop features, IPC handlers, controllers, preload scripts, window management, menu configuration, or Electron-specific functionality. Triggers on desktop app development, Electron IPC, or desktop local tools implementation.
4+
disable-model-invocation: true
5+
---
6+
7+
# Desktop Development Guide
8+
9+
## Architecture Overview
10+
11+
LobeChat desktop is built on Electron with main-renderer architecture:
12+
13+
1. **Main Process** (`apps/desktop/src/main`): App lifecycle, system APIs, window management
14+
2. **Renderer Process**: Reuses web code from `src/`
15+
3. **Preload Scripts** (`apps/desktop/src/preload`): Securely expose main process to renderer
16+
17+
## Adding New Desktop Features
18+
19+
### 1. Create Controller
20+
Location: `apps/desktop/src/main/controllers/`
21+
22+
```typescript
23+
import { ControllerModule, IpcMethod } from '@/controllers';
24+
25+
export default class NewFeatureCtr extends ControllerModule {
26+
static override readonly groupName = 'newFeature';
27+
28+
@IpcMethod()
29+
async doSomething(params: SomeParams): Promise<SomeResult> {
30+
// Implementation
31+
return { success: true };
32+
}
33+
}
34+
```
35+
36+
Register in `apps/desktop/src/main/controllers/registry.ts`.
37+
38+
### 2. Define IPC Types
39+
Location: `packages/electron-client-ipc/src/types.ts`
40+
41+
```typescript
42+
export interface SomeParams { /* ... */ }
43+
export interface SomeResult { success: boolean; error?: string }
44+
```
45+
46+
### 3. Create Renderer Service
47+
Location: `src/services/electron/`
48+
49+
```typescript
50+
import { ensureElectronIpc } from '@/utils/electron/ipc';
51+
52+
const ipc = ensureElectronIpc();
53+
54+
export const newFeatureService = async (params: SomeParams) => {
55+
return ipc.newFeature.doSomething(params);
56+
};
57+
```
58+
59+
### 4. Implement Store Action
60+
Location: `src/store/`
61+
62+
### 5. Add Tests
63+
Location: `apps/desktop/src/main/controllers/__tests__/`
64+
65+
## Detailed Guides
66+
67+
See `references/` for specific topics:
68+
- **Feature implementation**: `references/feature-implementation.md`
69+
- **Local tools workflow**: `references/local-tools.md`
70+
- **Menu configuration**: `references/menu-config.md`
71+
- **Window management**: `references/window-management.md`
72+
73+
## Best Practices
74+
75+
1. **Security**: Validate inputs, limit exposed APIs
76+
2. **Performance**: Use async methods, batch data transfers
77+
3. **UX**: Add progress indicators, provide error feedback
78+
4. **Code organization**: Follow existing patterns, add documentation

0 commit comments

Comments
 (0)