sumulige-claude 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.claude/.kickoff-hint.txt +3 -2
  2. package/.claude/AGENTS.md +6 -6
  3. package/.claude/CLAUDE.md +138 -0
  4. package/.claude/README.md +234 -43
  5. package/.claude/USAGE.md +175 -0
  6. package/.claude/boris-optimizations.md +167 -0
  7. package/.claude/commands/fix.md +83 -0
  8. package/.claude/commands/plan.md +88 -0
  9. package/.claude/commands/refactor.md +102 -0
  10. package/.claude/commands/todos.md +6 -41
  11. package/.claude/hooks/code-formatter.cjs +2 -7
  12. package/.claude/hooks/conversation-logger.cjs +222 -0
  13. package/.claude/hooks/multi-session.cjs +3 -9
  14. package/.claude/hooks/pre-push.cjs +3 -2
  15. package/.claude/hooks/project-kickoff.cjs +198 -20
  16. package/.claude/hooks/rag-skill-loader.cjs +0 -7
  17. package/.claude/hooks/session-restore.cjs +0 -0
  18. package/.claude/hooks/session-save.cjs +0 -0
  19. package/.claude/hooks/thinking-silent.cjs +3 -9
  20. package/.claude/hooks/todo-manager.cjs +142 -269
  21. package/.claude/hooks/verify-work.cjs +4 -10
  22. package/.claude/rag/skill-index.json +147 -8
  23. package/.claude/rules/coding-style.md +119 -0
  24. package/.claude/rules/hooks.md +288 -0
  25. package/.claude/rules/performance.md +78 -0
  26. package/.claude/rules/security.md +56 -0
  27. package/.claude/rules/testing.md +89 -0
  28. package/.claude/settings.json +115 -0
  29. package/.claude/settings.local.json +19 -1
  30. package/.claude/skills/SKILLS.md +145 -0
  31. package/.claude/skills/design-brain/SKILL.md +190 -0
  32. package/.claude/skills/design-brain/metadata.yaml +26 -0
  33. package/.claude/skills/examples/README.md +47 -0
  34. package/.claude/skills/examples/basic-task.md +67 -0
  35. package/.claude/skills/examples/bug-fix-workflow.md +92 -0
  36. package/.claude/skills/examples/feature-development.md +81 -0
  37. package/.claude/skills/manus-kickoff/SKILL.md +128 -0
  38. package/.claude/skills/manus-kickoff/examples/basic.md +84 -0
  39. package/.claude/skills/manus-kickoff/metadata.yaml +33 -0
  40. package/.claude/skills/manus-kickoff/templates/PROJECT_KICKOFF.md +89 -0
  41. package/.claude/skills/manus-kickoff/templates/PROJECT_PROPOSAL.md +227 -0
  42. package/.claude/skills/manus-kickoff/templates/TASK_PLAN.md +121 -0
  43. package/.claude/skills/quality-guard/SKILL.md +138 -0
  44. package/.claude/skills/quality-guard/metadata.yaml +27 -0
  45. package/.claude/skills/quick-fix/SKILL.md +138 -0
  46. package/.claude/skills/quick-fix/metadata.yaml +26 -0
  47. package/.claude/skills/test-master/SKILL.md +186 -0
  48. package/.claude/skills/test-master/metadata.yaml +29 -0
  49. package/.claude/templates/PROJECT_KICKOFF.md +89 -0
  50. package/.claude/templates/PROJECT_PROPOSAL.md +227 -0
  51. package/.claude/templates/TASK_PLAN.md +121 -0
  52. package/.claude-plugin/marketplace.json +2 -2
  53. package/AGENTS.md +49 -7
  54. package/CHANGELOG.md +56 -2
  55. package/CLAUDE-template.md +114 -0
  56. package/README.md +73 -1
  57. package/config/official-skills.json +2 -2
  58. package/development/knowledge-base/.index.clean.json +1 -0
  59. package/jest.config.js +3 -1
  60. package/lib/commands.js +1626 -1207
  61. package/lib/marketplace.js +1 -0
  62. package/package.json +1 -1
  63. package/project-paradigm.md +313 -0
  64. package/prompts/how-to-find.md +163 -0
  65. package/tests/commands.test.js +940 -17
  66. package/tests/config-schema.test.js +425 -0
  67. package/tests/marketplace.test.js +330 -214
  68. package/tests/sync-external.test.js +214 -0
  69. package/tests/update-registry.test.js +251 -0
  70. package/tests/utils.test.js +12 -8
  71. package/tests/web-search.test.js +392 -0
  72. package/thinkinglens-silent.md +138 -0
  73. package/.claude/skills/api-tester/SKILL.md +0 -90
  74. package/.claude/skills/api-tester/examples/basic.md +0 -3
  75. package/.claude/skills/api-tester/metadata.yaml +0 -30
  76. package/.claude/skills/api-tester/templates/default.md +0 -3
  77. package/.claude/skills/template/SKILL.md +0 -6
@@ -1,15 +1,154 @@
1
1
  {
2
+ "version": "2.0.0",
3
+ "last_updated": "2026-01-22",
4
+ "description": "Optimized skill index - merged 9 skills into 4 core skills",
2
5
  "skills": [
3
6
  {
4
- "name": "api-tester",
5
- "description": "TODO: Add description for api-tester",
6
- "keywords": [
7
- "api tester"
8
- ],
9
- "path": ".claude/skills/api-tester/SKILL.md"
7
+ "name": "frontend-design",
8
+ "keywords": ["frontend", "ui", "react", "vue", "svelte", "design", "interface", "component", "web", "styling", "tailwind", "css"],
9
+ "description": "Create distinctive, production-grade frontend interfaces with high design quality",
10
+ "trigger": "when user asks to build web components, pages, artifacts, posters, or applications"
11
+ },
12
+ {
13
+ "name": "docx",
14
+ "keywords": ["docx", "word", "document", "office", "microsoft", "doc", "editing", "tracked changes", "comments"],
15
+ "description": "Comprehensive document creation, editing, and analysis with support for tracked changes and comments",
16
+ "trigger": "when working with .docx files for creating, editing, or analyzing documents"
17
+ },
18
+ {
19
+ "name": "pdf",
20
+ "keywords": ["pdf", "form", "fill", "extract", "merge", "split", "acrobat", "fillable"],
21
+ "description": "Comprehensive PDF manipulation toolkit for extracting text, creating new PDFs, and handling forms",
22
+ "trigger": "when working with PDF forms, extraction, or programmatic processing"
23
+ },
24
+ {
25
+ "name": "pptx",
26
+ "keywords": ["pptx", "powerpoint", "slide", "presentation", "deck", "microsoft", "office"],
27
+ "description": "Presentation creation, editing, and analysis with layout support",
28
+ "trigger": "when working with presentations (.pptx files)"
29
+ },
30
+ {
31
+ "name": "xlsx",
32
+ "keywords": ["xlsx", "excel", "spreadsheet", "csv", "tsv", "formula", "chart", "data analysis"],
33
+ "description": "Comprehensive spreadsheet creation, editing, and analysis with formula support",
34
+ "trigger": "when working with spreadsheets for reading, analyzing, or creating data"
35
+ },
36
+ {
37
+ "name": "canvas-design",
38
+ "keywords": ["art", "design", "canvas", "poster", "visual", "creative", "generative", "algorithmic"],
39
+ "description": "Create beautiful visual art in .png and .pdf documents using design philosophy",
40
+ "trigger": "when user asks to create a poster, piece of art, design, or other static visual piece"
41
+ },
42
+ {
43
+ "name": "mcp-builder",
44
+ "keywords": ["mcp", "api", "server", "integration", "tool", "model context protocol", "external service"],
45
+ "description": "Guide for creating high-quality MCP servers that enable LLMs to interact with external services",
46
+ "trigger": "when building MCP servers to integrate external APIs or services"
47
+ },
48
+ {
49
+ "name": "webapp-testing",
50
+ "keywords": ["browser", "automation", "screenshot", "puppeteer", "scraping"],
51
+ "description": "Toolkit for interacting with and testing local web applications using Playwright",
52
+ "trigger": "when testing frontend functionality, debugging UI behavior, or capturing browser screenshots"
53
+ },
54
+ {
55
+ "name": "orchestration",
56
+ "keywords": ["agent", "multi-agent", "workflow", "coordination", "parallel", "distributed"],
57
+ "description": "Multi-agent orchestration with cc-mirror tasks and domain-specific workflows",
58
+ "trigger": "when coordinating multiple agents or workflows for complex tasks"
59
+ },
60
+ {
61
+ "name": "algorithmic-art",
62
+ "keywords": ["p5.js", "generative", "algorithmic", "art", "creative", "random", "flow field", "particle"],
63
+ "description": "Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration",
64
+ "trigger": "when user requests creating art using code, generative art, or algorithmic art"
65
+ },
66
+ {
67
+ "name": "slack-gif-creator",
68
+ "keywords": ["gif", "slack", "animated", "animation", "meme", "visual"],
69
+ "description": "Knowledge and utilities for creating animated GIFs optimized for Slack",
70
+ "trigger": "when user requests animated GIFs for Slack"
71
+ },
72
+ {
73
+ "name": "theme-factory",
74
+ "keywords": ["theme", "style", "color", "typography", "branding", "design system"],
75
+ "description": "Toolkit for styling artifacts with a theme - 10 pre-set themes with colors/fonts",
76
+ "trigger": "when applying consistent theming to documents, slides, or web pages"
77
+ },
78
+ {
79
+ "name": "skill-creator",
80
+ "keywords": ["skill", "create skill", "custom skill", "extend", "workflow"],
81
+ "description": "Guide for creating effective skills that extend Claude's capabilities",
82
+ "trigger": "when user wants to create a new skill or update an existing skill"
83
+ },
84
+ {
85
+ "name": "doc-coauthoring",
86
+ "keywords": ["documentation", "doc", "proposal", "spec", "technical spec", "decision doc", "writing"],
87
+ "description": "Guide users through structured workflow for co-authoring documentation",
88
+ "trigger": "when user wants to write documentation, proposals, technical specs, or decision docs"
89
+ },
90
+ {
91
+ "name": "brand-guidelines",
92
+ "keywords": ["brand", "anthropic", "color", "typography", "style", "guidelines"],
93
+ "description": "Applies Anthropic's official brand colors and typography to artifacts",
94
+ "trigger": "when brand colors or style guidelines apply to the artifact"
95
+ },
96
+ {
97
+ "name": "internal-comms",
98
+ "keywords": ["internal", "communication", "status report", "newsletter", "faq", "company", "update"],
99
+ "description": "Resources for writing internal communications in company-preferred formats",
100
+ "trigger": "when asked to write internal communications like status reports or newsletters"
101
+ },
102
+ {
103
+ "name": "web-artifacts-builder",
104
+ "keywords": ["artifact", "html", "react", "complex", "state", "routing", "shadcn"],
105
+ "description": "Tools for creating elaborate, multi-component HTML artifacts using modern frontend web technologies",
106
+ "trigger": "for complex artifacts requiring state management, routing, or shadcn/ui components"
107
+ },
108
+ {
109
+ "name": "quality-guard",
110
+ "keywords": ["review", "security", "quality", "lint", "code review", "vulnerability", "owasp", "dead code", "refactor", "cleanup"],
111
+ "description": "Code quality guardian - merged: code review + security check + dead code cleanup. Supports --security, --clean modes.",
112
+ "trigger": "when reviewing code, checking security, or cleaning up dead code",
113
+ "model": "sonnet"
114
+ },
115
+ {
116
+ "name": "test-master",
117
+ "keywords": ["test", "tdd", "e2e", "playwright", "coverage", "unit test", "jest", "vitest"],
118
+ "description": "Test master - merged: TDD workflow + E2E testing. Supports --tdd, --e2e, --coverage modes.",
119
+ "trigger": "when writing tests, doing TDD, running E2E tests, or checking coverage",
120
+ "model": "sonnet"
121
+ },
122
+ {
123
+ "name": "design-brain",
124
+ "keywords": ["plan", "design", "architecture", "system design", "technical decision", "strategy"],
125
+ "description": "Design brain - merged: planner + architect. Supports --quick (default) and --deep modes.",
126
+ "trigger": "when planning implementation or making architecture decisions",
127
+ "model": "opus"
128
+ },
129
+ {
130
+ "name": "quick-fix",
131
+ "keywords": ["fix", "build error", "compile error", "type error", "lint error", "tsc"],
132
+ "description": "Quick fixer - fast build/lint/type error resolution using haiku model for speed and cost efficiency.",
133
+ "trigger": "when build fails, type errors occur, or lint errors need fixing",
134
+ "model": "haiku"
10
135
  }
11
136
  ],
12
137
  "auto_load": {
13
- "enabled": true
138
+ "enabled": true,
139
+ "confidence_threshold": 0.7,
140
+ "max_skills_per_task": 3
141
+ },
142
+ "fallback": {
143
+ "enabled": true,
144
+ "skill": "frontend-design"
145
+ },
146
+ "model_strategy": {
147
+ "description": "Cost-optimized model selection",
148
+ "rules": [
149
+ { "pattern": "quick-fix", "model": "haiku", "reason": "Fast, simple fixes" },
150
+ { "pattern": "quality-guard|test-master", "model": "sonnet", "reason": "Standard tasks" },
151
+ { "pattern": "design-brain", "model": "opus", "reason": "Complex architecture only" }
152
+ ]
14
153
  }
15
- }
154
+ }
@@ -0,0 +1,119 @@
1
+ # Coding Style Rules
2
+
3
+ > 代码风格规则 - 所有代码必须遵守
4
+
5
+ ## 不可变性 (CRITICAL)
6
+
7
+ **始终创建新对象,永不变异:**
8
+
9
+ ```javascript
10
+ // ❌ 错误:变异
11
+ function updateUser(user, name) {
12
+ user.name = name // 变异!
13
+ return user
14
+ }
15
+
16
+ // ✅ 正确:不可变
17
+ function updateUser(user, name) {
18
+ return {
19
+ ...user,
20
+ name
21
+ }
22
+ }
23
+ ```
24
+
25
+ ## 文件组织
26
+
27
+ **多个小文件 > 少数大文件:**
28
+
29
+ | 规则 | 阈值 |
30
+ |------|------|
31
+ | 典型文件 | 200-400 行 |
32
+ | 最大文件 | 800 行 |
33
+ | 组织方式 | 按功能/领域,而非按类型 |
34
+
35
+ 原则:高内聚,低耦合
36
+
37
+ ## 错误处理
38
+
39
+ **始终全面处理错误:**
40
+
41
+ ```typescript
42
+ try {
43
+ const result = await riskyOperation()
44
+ return result
45
+ } catch (error) {
46
+ console.error('Operation failed:', error)
47
+ throw new Error('用户友好的详细错误信息')
48
+ }
49
+ ```
50
+
51
+ ## 输入验证
52
+
53
+ **始终验证用户输入:**
54
+
55
+ ```typescript
56
+ import { z } from 'zod'
57
+
58
+ const schema = z.object({
59
+ email: z.string().email(),
60
+ age: z.number().int().min(0).max(150)
61
+ })
62
+
63
+ const validated = schema.parse(input)
64
+ ```
65
+
66
+ ## 代码质量检查清单
67
+
68
+ 完成工作前确认:
69
+
70
+ - [ ] 代码可读、命名良好
71
+ - [ ] 函数小(< 50 行)
72
+ - [ ] 文件聚焦(< 800 行)
73
+ - [ ] 无深嵌套(> 4 层)
74
+ - [ ] 适当的错误处理
75
+ - [ ] 无 console.log 语句
76
+ - [ ] 无硬编码值
77
+ - [ ] 无变异(使用不可变模式)
78
+
79
+ ## 命名规范
80
+
81
+ | 类型 | 规范 | 示例 |
82
+ |------|------|------|
83
+ | 变量 | camelCase | `userName`, `isActive` |
84
+ | 常量 | SCREAMING_SNAKE | `MAX_RETRY`, `API_URL` |
85
+ | 函数 | camelCase, 动词开头 | `getUserById`, `validateInput` |
86
+ | 类/组件 | PascalCase | `UserProfile`, `DataService` |
87
+ | 文件 | kebab-case 或 PascalCase | `user-service.ts`, `UserProfile.tsx` |
88
+
89
+ ## 禁止的模式
90
+
91
+ ```typescript
92
+ // ❌ 魔法数字
93
+ if (status === 200) { ... }
94
+
95
+ // ✅ 使用常量
96
+ const HTTP_OK = 200
97
+ if (status === HTTP_OK) { ... }
98
+
99
+ // ❌ 变量名不清晰
100
+ const x = getUser()
101
+ const tmp = process(data)
102
+
103
+ // ✅ 描述性命名
104
+ const currentUser = getUser()
105
+ const processedData = process(data)
106
+
107
+ // ❌ 直接变异数组
108
+ arr.push(item)
109
+ arr.sort()
110
+
111
+ // ✅ 创建新数组
112
+ const newArr = [...arr, item]
113
+ const sortedArr = [...arr].sort()
114
+ ```
115
+
116
+ ## 相关命令
117
+
118
+ - `/code-review` - 代码审查
119
+ - `/refactor-clean` - 重构清理
@@ -0,0 +1,288 @@
1
+ # Hooks 最佳实践
2
+
3
+ > 自动化钩子使用指南 - 融合自 everything-claude-code
4
+
5
+ ## Hook 类型
6
+
7
+ | 类型 | 触发时机 | 用途 |
8
+ |------|---------|------|
9
+ | PreToolUse | 工具执行前 | 验证、准备、确认 |
10
+ | PostToolUse | 工具执行后 | 格式化、检查、通知 |
11
+ | Stop | 会话结束时 | 总结、清理、保存 |
12
+
13
+ ## 推荐的 Hook 配置
14
+
15
+ ### PreToolUse Hooks
16
+
17
+ **1. Git Push 审查**
18
+
19
+ 在 `git push` 前确认分支和状态:
20
+
21
+ ```javascript
22
+ // hooks/git-push-review.cjs
23
+ module.exports = {
24
+ event: 'PreToolUse',
25
+ condition: (input) => {
26
+ return input.tool === 'Bash' &&
27
+ input.input?.command?.includes('git push')
28
+ },
29
+ action: async (input, context) => {
30
+ // 获取当前分支
31
+ const branch = execSync('git branch --show-current').toString().trim()
32
+
33
+ // 检查是否推送到 main/master
34
+ if (branch === 'main' || branch === 'master') {
35
+ return {
36
+ decision: 'ask',
37
+ message: `即将推送到 ${branch} 分支,确认继续?`
38
+ }
39
+ }
40
+
41
+ return { decision: 'allow' }
42
+ }
43
+ }
44
+ ```
45
+
46
+ **2. 敏感文件保护**
47
+
48
+ 防止修改关键配置文件:
49
+
50
+ ```javascript
51
+ // hooks/protect-sensitive.cjs
52
+ const PROTECTED_PATTERNS = [
53
+ '.env',
54
+ 'credentials',
55
+ 'secrets',
56
+ '*.pem',
57
+ '*.key'
58
+ ]
59
+
60
+ module.exports = {
61
+ event: 'PreToolUse',
62
+ condition: (input) => {
63
+ return ['Write', 'Edit'].includes(input.tool)
64
+ },
65
+ action: async (input, context) => {
66
+ const filePath = input.input?.file_path || ''
67
+
68
+ for (const pattern of PROTECTED_PATTERNS) {
69
+ if (filePath.includes(pattern) ||
70
+ filePath.endsWith(pattern.replace('*', ''))) {
71
+ return {
72
+ decision: 'ask',
73
+ message: `即将修改敏感文件 ${filePath},确认继续?`
74
+ }
75
+ }
76
+ }
77
+
78
+ return { decision: 'allow' }
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### PostToolUse Hooks
84
+
85
+ **1. 自动格式化**
86
+
87
+ 写入文件后自动运行 Prettier:
88
+
89
+ ```javascript
90
+ // hooks/auto-format.cjs
91
+ const { execSync } = require('child_process')
92
+
93
+ const FORMATTABLE_EXTENSIONS = [
94
+ '.js', '.jsx', '.ts', '.tsx',
95
+ '.json', '.md', '.css', '.scss'
96
+ ]
97
+
98
+ module.exports = {
99
+ event: 'PostToolUse',
100
+ condition: (input, output) => {
101
+ if (!['Write', 'Edit'].includes(input.tool)) return false
102
+
103
+ const filePath = input.input?.file_path || ''
104
+ return FORMATTABLE_EXTENSIONS.some(ext => filePath.endsWith(ext))
105
+ },
106
+ action: async (input, output, context) => {
107
+ const filePath = input.input?.file_path
108
+
109
+ try {
110
+ execSync(`npx prettier --write "${filePath}"`, {
111
+ stdio: 'pipe'
112
+ })
113
+ return { message: `已格式化: ${filePath}` }
114
+ } catch (error) {
115
+ // Prettier 未安装或格式化失败,静默处理
116
+ return null
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ **2. TypeScript 类型检查**
123
+
124
+ 编辑 TS 文件后检查类型:
125
+
126
+ ```javascript
127
+ // hooks/type-check.cjs
128
+ const { execSync } = require('child_process')
129
+
130
+ module.exports = {
131
+ event: 'PostToolUse',
132
+ condition: (input, output) => {
133
+ if (!['Write', 'Edit'].includes(input.tool)) return false
134
+
135
+ const filePath = input.input?.file_path || ''
136
+ return filePath.endsWith('.ts') || filePath.endsWith('.tsx')
137
+ },
138
+ action: async (input, output, context) => {
139
+ try {
140
+ execSync('npx tsc --noEmit', {
141
+ stdio: 'pipe',
142
+ timeout: 30000
143
+ })
144
+ return { message: '类型检查通过' }
145
+ } catch (error) {
146
+ const stderr = error.stderr?.toString() || ''
147
+ if (stderr.includes('error')) {
148
+ return {
149
+ message: `类型错误:\n${stderr.slice(0, 500)}`
150
+ }
151
+ }
152
+ return null
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
158
+ **3. Console.log 警告**
159
+
160
+ 检测遗留的调试语句:
161
+
162
+ ```javascript
163
+ // hooks/console-warning.cjs
164
+ const fs = require('fs')
165
+
166
+ module.exports = {
167
+ event: 'PostToolUse',
168
+ condition: (input, output) => {
169
+ if (!['Write', 'Edit'].includes(input.tool)) return false
170
+
171
+ const filePath = input.input?.file_path || ''
172
+ return filePath.endsWith('.ts') ||
173
+ filePath.endsWith('.tsx') ||
174
+ filePath.endsWith('.js') ||
175
+ filePath.endsWith('.jsx')
176
+ },
177
+ action: async (input, output, context) => {
178
+ const filePath = input.input?.file_path
179
+
180
+ try {
181
+ const content = fs.readFileSync(filePath, 'utf-8')
182
+ const consoleMatches = content.match(/console\.(log|debug|info)\(/g)
183
+
184
+ if (consoleMatches && consoleMatches.length > 0) {
185
+ return {
186
+ message: `警告: 文件中有 ${consoleMatches.length} 个 console 语句,提交前请移除`
187
+ }
188
+ }
189
+ } catch (error) {
190
+ // 文件读取失败,静默处理
191
+ }
192
+
193
+ return null
194
+ }
195
+ }
196
+ ```
197
+
198
+ ### Stop Hooks
199
+
200
+ **会话总结**
201
+
202
+ 会话结束时生成进度总结:
203
+
204
+ ```javascript
205
+ // hooks/session-summary.cjs
206
+ module.exports = {
207
+ event: 'Stop',
208
+ action: async (context) => {
209
+ const summary = {
210
+ timestamp: new Date().toISOString(),
211
+ filesModified: context.modifiedFiles || [],
212
+ tasksCompleted: context.completedTasks || [],
213
+ pendingTasks: context.pendingTasks || []
214
+ }
215
+
216
+ // 保存到会话日志
217
+ const logPath = '.claude/session-logs/latest.json'
218
+ fs.writeFileSync(logPath, JSON.stringify(summary, null, 2))
219
+
220
+ return {
221
+ message: `会话已保存,修改了 ${summary.filesModified.length} 个文件`
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ ## Hook 编写原则
228
+
229
+ ### 1. 快速执行
230
+
231
+ ```
232
+ Hook 不应阻塞主流程超过 2 秒
233
+ 使用超时保护
234
+ 异步操作不要等待
235
+ ```
236
+
237
+ ### 2. 静默失败
238
+
239
+ ```
240
+ Hook 失败不应中断主流程
241
+ 记录错误但继续执行
242
+ 提供有意义的错误信息
243
+ ```
244
+
245
+ ### 3. 最小权限
246
+
247
+ ```
248
+ 只请求必要的权限
249
+ 不修改不相关的文件
250
+ 不执行危险命令
251
+ ```
252
+
253
+ ### 4. 可配置
254
+
255
+ ```
256
+ 支持通过环境变量配置
257
+ 允许禁用特定 hook
258
+ 提供合理的默认值
259
+ ```
260
+
261
+ ## 现有 Hooks 清单
262
+
263
+ 当前项目 `.claude/hooks/` 已有:
264
+
265
+ | Hook | 功能 |
266
+ |------|------|
267
+ | code-formatter.cjs | 代码格式化 |
268
+ | multi-session.cjs | 多会话管理 |
269
+ | project-kickoff.cjs | 项目初始化 |
270
+ | rag-skill-loader.cjs | RAG 技能加载 |
271
+ | session-restore.cjs | 会话恢复 |
272
+ | session-save.cjs | 会话保存 |
273
+ | todo-manager.cjs | TODO 管理 |
274
+ | verify-work.cjs | 工作验证 |
275
+
276
+ ## 调试 Hooks
277
+
278
+ ```bash
279
+ # 启用 hook 调试日志
280
+ export CLAUDE_HOOK_DEBUG=true
281
+
282
+ # 查看 hook 执行日志
283
+ tail -f .claude/logs/hooks.log
284
+ ```
285
+
286
+ ---
287
+
288
+ **记住**:Hooks 是强大的自动化工具,但要谨慎使用。过多的 hooks 会影响性能,过于激进的 hooks 会干扰正常工作流程。
@@ -0,0 +1,78 @@
1
+ # Performance Rules
2
+
3
+ > 性能和资源管理规则
4
+
5
+ ## 模型选择策略
6
+
7
+ 根据任务复杂度选择合适的模型:
8
+
9
+ | 模型 | 适用场景 | 成本 |
10
+ |------|---------|------|
11
+ | **Haiku** | 简单任务、高频调用、轻量 agent | 最低 |
12
+ | **Sonnet** | 主要开发、代码生成、工作流编排 | 中等 |
13
+ | **Opus** | 复杂架构决策、深度推理、研究分析 | 最高 |
14
+
15
+ ### 推荐配置
16
+
17
+ ```
18
+ Conductor → Sonnet (需要全局理解)
19
+ Architect → Opus (需要深度思考)
20
+ Builder → Sonnet (主要编码工作)
21
+ Reviewer → Opus (需要严谨分析)
22
+ Librarian → Haiku (文档整理)
23
+ ```
24
+
25
+ ## Context Window 管理
26
+
27
+ **关键原则**:避免在 context 的最后 20% 进行复杂操作
28
+
29
+ ### 高 Context 敏感任务(避免在 context 末尾)
30
+ - 大规模重构
31
+ - 跨多文件的功能实现
32
+ - 复杂交互调试
33
+
34
+ ### 低 Context 敏感任务(可在任何时候)
35
+ - 单文件编辑
36
+ - 独立工具创建
37
+ - 文档更新
38
+ - 简单 bug 修复
39
+
40
+ ## MCP 管理
41
+
42
+ **关键**:不要同时启用所有 MCP
43
+
44
+ - 200k context 可能被压缩到 70k
45
+ - 建议配置 20-30 个 MCP
46
+ - 每个项目启用不超过 10 个
47
+ - 活跃工具保持在 80 个以下
48
+
49
+ ### 禁用不需要的 MCP
50
+
51
+ 在项目 `settings.json` 中:
52
+
53
+ ```json
54
+ {
55
+ "disabledMcpServers": [
56
+ "unused-mcp-1",
57
+ "unused-mcp-2"
58
+ ]
59
+ }
60
+ ```
61
+
62
+ ## 构建故障排除
63
+
64
+ 构建失败时:
65
+
66
+ 1. 使用 **build-error-resolver** skill
67
+ 2. 分析错误信息
68
+ 3. 增量修复
69
+ 4. 每次修复后验证
70
+
71
+ ## 复杂任务策略
72
+
73
+ 对于需要深度推理的任务:
74
+
75
+ 1. 使用 `ultrathink` 模式增强思考
76
+ 2. 启用 **Plan Mode** 进行结构化方案
77
+ 3. 多轮自我批判优化
78
+ 4. 使用分角色 sub-agents 进行多角度分析
@@ -0,0 +1,56 @@
1
+ # Security Rules
2
+
3
+ > 安全规则 - 所有提交必须遵守
4
+
5
+ ## 提交前强制检查
6
+
7
+ 每次提交代码前必须确认:
8
+
9
+ - [ ] **无硬编码密钥** - API keys, passwords, tokens 必须用环境变量
10
+ - [ ] **输入验证** - 所有用户输入已验证和清理
11
+ - [ ] **SQL 注入防护** - 使用参数化查询
12
+ - [ ] **XSS 防护** - HTML 输出已转义
13
+ - [ ] **CSRF 保护** - 表单提交有 token 验证
14
+ - [ ] **认证授权** - 敏感操作有权限检查
15
+ - [ ] **速率限制** - API 端点有请求限制
16
+ - [ ] **错误信息** - 不泄露敏感数据
17
+
18
+ ## 密钥管理
19
+
20
+ ```typescript
21
+ // ❌ 永远不要这样做
22
+ const apiKey = "sk-proj-xxxxx"
23
+ const password = "admin123"
24
+
25
+ // ✅ 正确方式
26
+ const apiKey = process.env.OPENAI_API_KEY
27
+ if (!apiKey) {
28
+ throw new Error('OPENAI_API_KEY not configured')
29
+ }
30
+ ```
31
+
32
+ ## 安全响应协议
33
+
34
+ 发现安全问题时:
35
+
36
+ 1. **立即停止** 当前工作
37
+ 2. **调用** security-reviewer skill
38
+ 3. **修复** CRITICAL 问题后才能继续
39
+ 4. **轮换** 任何已暴露的密钥
40
+ 5. **审查** 整个代码库是否有类似问题
41
+
42
+ ## 敏感文件
43
+
44
+ 以下文件永远不应提交:
45
+
46
+ ```
47
+ .env
48
+ .env.local
49
+ .env.production
50
+ *.pem
51
+ *.key
52
+ credentials.json
53
+ secrets.yaml
54
+ ```
55
+
56
+ 确保 `.gitignore` 包含这些模式。