pdd-skills 3.0.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.
- package/README.md +1478 -0
- package/bin/pdd.js +354 -0
- package/config/bpmn-rules.yaml +166 -0
- package/config/checkstyle.xml +105 -0
- package/config/eslint.config.js +48 -0
- package/config/pmd.xml +91 -0
- package/config/prd-rules.yaml +113 -0
- package/config/ruff.toml +45 -0
- package/config/sqlfluff.cfg +82 -0
- package/hooks/hook-executor.js +332 -0
- package/index.js +43 -0
- package/lib/api-routes.js +750 -0
- package/lib/api-server.js +408 -0
- package/lib/cache/cache-config.js +209 -0
- package/lib/cache/system-cache.js +852 -0
- package/lib/config-manager.js +373 -0
- package/lib/generate.js +528 -0
- package/lib/grpc/grpc-routes.js +1134 -0
- package/lib/grpc/grpc-server.js +912 -0
- package/lib/grpc/proto-definitions.js +1033 -0
- package/lib/init.js +172 -0
- package/lib/iteration/auto-fixer.js +1025 -0
- package/lib/iteration/auto-reviewer.js +923 -0
- package/lib/iteration/controller.js +577 -0
- package/lib/list.js +130 -0
- package/lib/mcp-server.js +548 -0
- package/lib/openclaw/api-integration.js +535 -0
- package/lib/openclaw/cli-integration.js +567 -0
- package/lib/openclaw/data-sync.js +845 -0
- package/lib/openclaw/openclaw-adapter.js +783 -0
- package/lib/plugin/example-plugins/code-stats/index.js +332 -0
- package/lib/plugin/example-plugins/code-stats/plugin.json +1 -0
- package/lib/plugin/example-plugins/custom-linter/index.js +472 -0
- package/lib/plugin/example-plugins/custom-linter/plugin.json +1 -0
- package/lib/plugin/example-plugins/hello-world/index.js +86 -0
- package/lib/plugin/example-plugins/hello-world/plugin.json +1 -0
- package/lib/plugin/plugin-manager.js +655 -0
- package/lib/plugin/plugin-sdk.js +565 -0
- package/lib/plugin/sandbox.js +627 -0
- package/lib/quality/rules/maintainability.js +418 -0
- package/lib/quality/rules/performance.js +498 -0
- package/lib/quality/rules/readability.js +441 -0
- package/lib/quality/rules/robustness.js +504 -0
- package/lib/quality/rules/security.js +444 -0
- package/lib/quality/scorer.js +576 -0
- package/lib/report.js +669 -0
- package/lib/sdk-base.js +301 -0
- package/lib/sdk-js.js +446 -0
- package/lib/sdk-python/README.md +546 -0
- package/lib/sdk-python/examples/basic_usage.py +450 -0
- package/lib/sdk-python/pdd_sdk/__init__.py +180 -0
- package/lib/sdk-python/pdd_sdk/client.py +1170 -0
- package/lib/sdk-python/pdd_sdk/events.py +423 -0
- package/lib/sdk-python/pdd_sdk/exceptions.py +158 -0
- package/lib/sdk-python/pdd_sdk/models.py +518 -0
- package/lib/sdk-python/pdd_sdk/utils.py +759 -0
- package/lib/token/budget-alert.js +367 -0
- package/lib/token/budget-manager.js +485 -0
- package/lib/update.js +54 -0
- package/lib/utils/logger.js +88 -0
- package/lib/verify.js +741 -0
- package/lib/version.js +52 -0
- package/lib/vm/README.md +102 -0
- package/lib/vm/dashboard/api-routes.js +669 -0
- package/lib/vm/dashboard/server.js +391 -0
- package/lib/vm/dashboard/sse.js +358 -0
- package/lib/vm/dashboard/static/css/dashboard.css +1378 -0
- package/lib/vm/dashboard/static/index.html +118 -0
- package/lib/vm/dashboard/static/js/app.js +949 -0
- package/lib/vm/dashboard/static/js/charts.js +913 -0
- package/lib/vm/dashboard/static/js/kanban-view.js +1053 -0
- package/lib/vm/dashboard/static/js/pipeline-view.js +463 -0
- package/lib/vm/dashboard/static/js/quality-view.js +598 -0
- package/lib/vm/dashboard/static/js/system-view.js +1021 -0
- package/lib/vm/data-provider.js +1191 -0
- package/lib/vm/event-bus.js +402 -0
- package/lib/vm/hooks/extract-hook.js +307 -0
- package/lib/vm/hooks/generate-hook.js +374 -0
- package/lib/vm/hooks/hook-interface.js +458 -0
- package/lib/vm/hooks/report-hook.js +331 -0
- package/lib/vm/hooks/verify-hook.js +454 -0
- package/lib/vm/models.js +1003 -0
- package/lib/vm/reconciler.js +855 -0
- package/lib/vm/scanner.js +988 -0
- package/lib/vm/state-schema.js +955 -0
- package/lib/vm/state-store.js +733 -0
- package/lib/vm/tui/components/card.js +339 -0
- package/lib/vm/tui/components/progress-bar.js +368 -0
- package/lib/vm/tui/components/sparkline.js +327 -0
- package/lib/vm/tui/components/status-light.js +294 -0
- package/lib/vm/tui/components/table.js +370 -0
- package/lib/vm/tui/input.js +335 -0
- package/lib/vm/tui/renderer.js +548 -0
- package/lib/vm/tui/screens/kanban-screen.js +397 -0
- package/lib/vm/tui/screens/overview-screen.js +357 -0
- package/lib/vm/tui/screens/quality-screen.js +336 -0
- package/lib/vm/tui/screens/system-screen.js +379 -0
- package/lib/vm/tui/tui.js +805 -0
- package/package.json +1 -0
- package/scripts/cso-analyzer.js +198 -0
- package/scripts/eval-runner.js +359 -0
- package/scripts/i18n-checker.js +109 -0
- package/scripts/linter/activiti-linter.js +272 -0
- package/scripts/linter/prd-linter.js +162 -0
- package/scripts/linter/report-generator.js +207 -0
- package/scripts/linter/run-linters.js +285 -0
- package/scripts/linter/sql-linter.js +166 -0
- package/scripts/token-analyzer.js +162 -0
- package/scripts/vm-test.js +180 -0
- package/skills/core/official-doc-writer/LICENSE +21 -0
- package/skills/core/official-doc-writer/README.md +232 -0
- package/skills/core/official-doc-writer/SKILL.md +475 -0
- package/skills/core/official-doc-writer/_meta.json +1 -0
- package/skills/core/official-doc-writer/document_generator.py +580 -0
- package/skills/core/official-doc-writer/evals/default-evals.json +1 -0
- package/skills/core/official-doc-writer/examples.md +150 -0
- package/skills/core/official-doc-writer/fonts/FONTS_LIST.md +45 -0
- package/skills/core/official-doc-writer/fonts/README.md +141 -0
- package/skills/core/official-doc-writer/fonts/SIMFANG.TTF +0 -0
- package/skills/core/official-doc-writer/fonts/SIMHEI.TTF +0 -0
- package/skills/core/official-doc-writer/fonts/SIMKAI.TTF +0 -0
- package/skills/core/official-doc-writer/fonts/SIMSUN.TTC +0 -0
- package/skills/core/official-doc-writer/fonts//346/226/271/346/255/243/345/260/217/346/240/207/345/256/213GBK.TTF +0 -0
- package/skills/core/official-doc-writer/references/GBT_9704-2012_/345/205/232/346/224/277/346/234/272/345/205/263/345/205/254/346/226/207/346/240/274/345/274/217.md +422 -0
- package/skills/core/official-doc-writer/scripts/__pycache__/generate_official_doc.cpython-313.pyc +0 -0
- package/skills/core/official-doc-writer/scripts/dialog_manager.py +564 -0
- package/skills/core/official-doc-writer/scripts/generate_official_doc.py +252 -0
- package/skills/core/official-doc-writer/scripts/install_fonts.py +390 -0
- package/skills/core/official-doc-writer/scripts/smart_prompts.py +363 -0
- package/skills/core/pdd-ba/SKILL.md +305 -0
- package/skills/core/pdd-ba/_meta.json +1 -0
- package/skills/core/pdd-ba/evals/default-evals.json +1 -0
- package/skills/core/pdd-code-reviewer/SKILL.md +378 -0
- package/skills/core/pdd-code-reviewer/_meta.json +1 -0
- package/skills/core/pdd-code-reviewer/evals/default-evals.json +1 -0
- package/skills/core/pdd-doc-change/SKILL.md +350 -0
- package/skills/core/pdd-doc-change/_meta.json +1 -0
- package/skills/core/pdd-doc-change/evals/default-evals.json +1 -0
- package/skills/core/pdd-doc-gardener/SKILL.md +248 -0
- package/skills/core/pdd-doc-gardener/_meta.json +1 -0
- package/skills/core/pdd-doc-gardener/evals/default-evals.json +1 -0
- package/skills/core/pdd-entropy-reduction/SKILL.md +360 -0
- package/skills/core/pdd-entropy-reduction/_meta.json +1 -0
- package/skills/core/pdd-entropy-reduction/evals/default-evals.json +1 -0
- package/skills/core/pdd-entropy-reduction/references/entropy-report-template.md +287 -0
- package/skills/core/pdd-entropy-reduction/references/golden-principles.md +573 -0
- package/skills/core/pdd-entropy-reduction/scripts/entropy_scan.py +712 -0
- package/skills/core/pdd-extract-features/SKILL.md +320 -0
- package/skills/core/pdd-extract-features/_meta.json +1 -0
- package/skills/core/pdd-extract-features/evals/default-evals.json +1 -0
- package/skills/core/pdd-generate-spec/SKILL.md +418 -0
- package/skills/core/pdd-generate-spec/_meta.json +1 -0
- package/skills/core/pdd-generate-spec/evals/default-evals.json +1 -0
- package/skills/core/pdd-implement-feature/SKILL.md +332 -0
- package/skills/core/pdd-implement-feature/_meta.json +1 -0
- package/skills/core/pdd-implement-feature/evals/default-evals.json +1 -0
- package/skills/core/pdd-main/SKILL.md +540 -0
- package/skills/core/pdd-main/_meta.json +1 -0
- package/skills/core/pdd-main/evals/default-evals.json +1 -0
- package/skills/core/pdd-main/evals/evals.json +215 -0
- package/skills/core/pdd-verify-feature/SKILL.md +474 -0
- package/skills/core/pdd-verify-feature/_meta.json +1 -0
- package/skills/core/pdd-verify-feature/evals/default-evals.json +1 -0
- package/skills/core/pdd-vm/evals/default-evals.json +1 -0
- package/skills/core/traffic-accident-assessor/LICENSE +29 -0
- package/skills/core/traffic-accident-assessor/SKILL.md +439 -0
- package/skills/core/traffic-accident-assessor/evals/evals.json +1 -0
- package/skills/core/traffic-accident-assessor/references/accident-types.md +369 -0
- package/skills/core/traffic-accident-assessor/references/liability-rules.md +287 -0
- package/skills/core/traffic-accident-assessor/references/traffic-laws.md +226 -0
- package/skills/core/traffic-accident-assessor/references//351/253/230/345/260/224/345/244/253/350/257/264/346/230/216/344/271/246.pdf +32576 -106
- package/skills/core/traffic-accident-assessor/scripts/generate_official_statement.py +588 -0
- package/skills/core/traffic-accident-assessor/scripts/generate_report.py +495 -0
- package/skills/core/traffic-accident-assessor/scripts/generate_statement.py +528 -0
- package/skills/core/traffic-accident-assessor.zip +0 -0
- package/skills/entropy/expert-arch-enforcer/SKILL.md +292 -0
- package/skills/entropy/expert-arch-enforcer/_meta.json +1 -0
- package/skills/entropy/expert-arch-enforcer/evals/default-evals.json +1 -0
- package/skills/entropy/expert-auto-refactor/SKILL.md +327 -0
- package/skills/entropy/expert-auto-refactor/_meta.json +1 -0
- package/skills/entropy/expert-auto-refactor/evals/default-evals.json +1 -0
- package/skills/entropy/expert-code-quality/SKILL.md +468 -0
- package/skills/entropy/expert-code-quality/_meta.json +1 -0
- package/skills/entropy/expert-code-quality/evals/default-evals.json +1 -0
- package/skills/entropy/expert-code-quality/evals/evals.json +109 -0
- package/skills/entropy/expert-code-quality/references/code-smells.md +605 -0
- package/skills/entropy/expert-code-quality/references/design-patterns.md +1111 -0
- package/skills/entropy/expert-code-quality/references/refactoring-catalog.md +1281 -0
- package/skills/entropy/expert-code-quality/references/solid-principles.md +524 -0
- package/skills/entropy/expert-entropy-auditor/SKILL.md +276 -0
- package/skills/entropy/expert-entropy-auditor/_meta.json +1 -0
- package/skills/entropy/expert-entropy-auditor/evals/default-evals.json +1 -0
- package/skills/expert/expert-activiti/SKILL.md +497 -0
- package/skills/expert/expert-activiti/_meta.json +1 -0
- package/skills/expert/expert-mysql/SKILL.md +832 -0
- package/skills/expert/expert-mysql/_meta.json +1 -0
- package/skills/expert/expert-performance/SKILL.md +379 -0
- package/skills/expert/expert-performance/_meta.json +1 -0
- package/skills/expert/expert-performance/evals/default-evals.json +1 -0
- package/skills/expert/expert-ruoyi/SKILL.md +472 -0
- package/skills/expert/expert-ruoyi/_meta.json +1 -0
- package/skills/expert/expert-security/SKILL.md +1341 -0
- package/skills/expert/expert-security/_meta.json +1 -0
- package/skills/expert/expert-security/evals/default-evals.json +1 -0
- package/skills/expert/software-architect/SKILL.md +350 -0
- package/skills/expert/software-architect/_meta.json +1 -0
- package/skills/expert/software-engineer/SKILL.md +437 -0
- package/skills/expert/software-engineer/_meta.json +1 -0
- package/skills/expert/software-engineer/architecture.md +130 -0
- package/skills/expert/software-engineer/patterns.md +151 -0
- package/skills/expert/software-engineer/testing.md +135 -0
- package/skills/expert/system-architect/SKILL.md +628 -0
- package/skills/expert/system-architect/_meta.json +1 -0
- package/skills/expert/system-architect/assets/templates/ARCHITECTURE.md +25 -0
- package/skills/expert/system-architect/assets/templates/README.md +44 -0
- package/skills/expert/system-architect/references/js-ts-standards.md +18 -0
- package/skills/expert/system-architect/references/python-standards.md +19 -0
- package/skills/expert/system-architect/references/scaffolding.md +61 -0
- package/skills/expert/system-architect/references/security-checklist.md +21 -0
- package/skills/openspec/openspec-apply-change/SKILL.md +156 -0
- package/skills/openspec/openspec-apply-change/_meta.json +1 -0
- package/skills/openspec/openspec-archive-change/SKILL.md +114 -0
- package/skills/openspec/openspec-archive-change/_meta.json +1 -0
- package/skills/openspec/openspec-bulk-archive-change/SKILL.md +246 -0
- package/skills/openspec/openspec-bulk-archive-change/_meta.json +1 -0
- package/skills/openspec/openspec-continue-change/SKILL.md +118 -0
- package/skills/openspec/openspec-continue-change/_meta.json +1 -0
- package/skills/openspec/openspec-explore/SKILL.md +288 -0
- package/skills/openspec/openspec-explore/_meta.json +1 -0
- package/skills/openspec/openspec-ff-change/SKILL.md +101 -0
- package/skills/openspec/openspec-ff-change/_meta.json +1 -0
- package/skills/openspec/openspec-new-change/SKILL.md +74 -0
- package/skills/openspec/openspec-new-change/_meta.json +1 -0
- package/skills/openspec/openspec-onboard/SKILL.md +554 -0
- package/skills/openspec/openspec-onboard/_meta.json +1 -0
- package/skills/openspec/openspec-sync-specs/SKILL.md +138 -0
- package/skills/openspec/openspec-sync-specs/_meta.json +1 -0
- package/skills/openspec/openspec-verify-change/SKILL.md +168 -0
- package/skills/openspec/openspec-verify-change/_meta.json +1 -0
- package/skills/pr/pdd-multi-review/SKILL.md +534 -0
- package/skills/pr/pdd-multi-review/_meta.json +1 -0
- package/skills/pr/pdd-pr-batch/SKILL.md +303 -0
- package/skills/pr/pdd-pr-batch/_meta.json +1 -0
- package/skills/pr/pdd-pr-create/SKILL.md +344 -0
- package/skills/pr/pdd-pr-create/_meta.json +1 -0
- package/skills/pr/pdd-pr-merge/SKILL.md +286 -0
- package/skills/pr/pdd-pr-merge/_meta.json +1 -0
- package/skills/pr/pdd-pr-review/SKILL.md +217 -0
- package/skills/pr/pdd-pr-review/_meta.json +1 -0
- package/skills/pr/pdd-task-manager/SKILL.md +636 -0
- package/skills/pr/pdd-task-manager/_meta.json +1 -0
- package/skills/pr/pdd-template-engine/SKILL.md +306 -0
- package/skills/pr/pdd-template-engine/_meta.json +1 -0
- package/templates/behavior-shaping/iron-law-template.md +87 -0
- package/templates/behavior-shaping/rationalization-template.md +62 -0
- package/templates/behavior-shaping/red-flags-template.md +70 -0
- package/templates/bilingual-template.md +139 -0
- package/templates/config/default.yaml +47 -0
- package/templates/project/default/README.md +31 -0
- package/templates/project/frontend/README.md +46 -0
- package/templates/project/java/README.md +48 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: expert-code-quality
|
|
3
|
+
description: "Code quality expert integrating refactoring techniques and design patterns for systematic improvement. Call when reviewing code, refactoring, or applying SOLID principles."
|
|
4
|
+
license: "MIT"
|
|
5
|
+
author: "neuqik@hotmail.com"
|
|
6
|
+
version: "2.0"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Code Quality Expert
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This skill integrates two foundational software engineering disciplines:
|
|
14
|
+
1. **Refactoring** - Improving code structure without changing behavior
|
|
15
|
+
2. **Design Patterns** - Proven solutions to common design problems
|
|
16
|
+
|
|
17
|
+
Combined, they form a powerful toolkit for writing clean, maintainable, and extensible code.
|
|
18
|
+
|
|
19
|
+
## Directory Structure
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
expert-code-quality/
|
|
23
|
+
├── SKILL.md # Skill definition file
|
|
24
|
+
├── LICENSE # MIT License
|
|
25
|
+
└── references/ # Reference documents
|
|
26
|
+
├── refactoring-catalog.md # Complete catalog of refactoring techniques
|
|
27
|
+
├── design-patterns.md # 23 GoF patterns
|
|
28
|
+
├── code-smells.md # Detailed description of code smells
|
|
29
|
+
└── solid-principles.md # In-depth analysis of SOLID principles
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Trigger Conditions
|
|
33
|
+
|
|
34
|
+
**Automatic Triggers:**
|
|
35
|
+
- User asks about code quality issues
|
|
36
|
+
- Need to identify code smells
|
|
37
|
+
- Request for design pattern recommendations
|
|
38
|
+
- Performing code refactoring
|
|
39
|
+
- Evaluating SOLID principle compliance
|
|
40
|
+
|
|
41
|
+
**Manual Triggers:**
|
|
42
|
+
- User enters commands like `/code-quality`, `/refactor`, `/pattern`, etc.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Core Capabilities
|
|
47
|
+
|
|
48
|
+
### 1. Code Smell Detection
|
|
49
|
+
|
|
50
|
+
#### 1.1 Quick Reference: 22 Code Smells
|
|
51
|
+
|
|
52
|
+
**Method-Level Smells:**
|
|
53
|
+
|
|
54
|
+
| Smell | Detection Pattern | Severity |
|
|
55
|
+
|-------|------------------|----------|
|
|
56
|
+
| **Long Method** | Method > 20 lines | High |
|
|
57
|
+
| **Duplicated Code** | Similar code blocks | Critical |
|
|
58
|
+
| **Long Parameter List** | Parameters > 4 | Medium |
|
|
59
|
+
| **Switch Statements** | Large switch/case blocks | Medium |
|
|
60
|
+
|
|
61
|
+
**Class-Level Smells:**
|
|
62
|
+
|
|
63
|
+
| Smell | Detection Pattern | Severity |
|
|
64
|
+
|-------|------------------|----------|
|
|
65
|
+
| **Large Class** | Class > 300 lines or > 10 fields | High |
|
|
66
|
+
| **Divergent Change** | One class changes for multiple reasons | High |
|
|
67
|
+
| **Shotgun Surgery** | One change requires modifying many classes | High |
|
|
68
|
+
| **Feature Envy** | Method uses data from other classes more | Medium |
|
|
69
|
+
|
|
70
|
+
**Relationship-Level Smells:**
|
|
71
|
+
|
|
72
|
+
| Smell | Detection Pattern | Severity |
|
|
73
|
+
|-------|------------------|----------|
|
|
74
|
+
| **Inappropriate Intimacy** | Classes access each other's private parts | Medium |
|
|
75
|
+
| **Message Chains** | `a.b().c().d()` chains | Medium |
|
|
76
|
+
| **Middle Man** | Class only does delegation | Low |
|
|
77
|
+
| **Data Clumps** | Same data items always appear together | Medium |
|
|
78
|
+
|
|
79
|
+
#### 1.2 Smell Detection Checklist
|
|
80
|
+
|
|
81
|
+
When reviewing code, check:
|
|
82
|
+
- [ ] Are there methods longer than 20 lines?
|
|
83
|
+
- [ ] Is there duplicated code?
|
|
84
|
+
- [ ] Are there classes with more than 10 fields?
|
|
85
|
+
- [ ] Are there switch statements that could use polymorphism?
|
|
86
|
+
- [ ] Are there methods with more than 4 parameters?
|
|
87
|
+
- [ ] Is there deep inheritance hierarchy (> 3 levels)?
|
|
88
|
+
- [ ] Does the class change for multiple reasons?
|
|
89
|
+
- [ ] Are there message chains with more than 3 calls?
|
|
90
|
+
- [ ] Are there "data classes" with only data and no behavior?
|
|
91
|
+
- [ ] Are there "lazy classes" that do almost nothing?
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### 2. Refactoring Techniques
|
|
96
|
+
|
|
97
|
+
#### 2.1 Refactoring Principles
|
|
98
|
+
|
|
99
|
+
**Two Hats (Kent Beck):**
|
|
100
|
+
|
|
101
|
+
| Hat | Activity | Rule |
|
|
102
|
+
|-----|----------|------|
|
|
103
|
+
| **Adding Features** | Add new functionality | Don't modify existing code |
|
|
104
|
+
| **Refactoring** | Improve structure | Don't add new features |
|
|
105
|
+
|
|
106
|
+
**Never wear both hats at the same time!**
|
|
107
|
+
|
|
108
|
+
**Refactoring Rhythm:**
|
|
109
|
+
```
|
|
110
|
+
Test → Small Change → Test → Small Change → Test
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### 2.2 Key Refactoring Techniques
|
|
114
|
+
|
|
115
|
+
**Composing Methods:**
|
|
116
|
+
|
|
117
|
+
| Refactoring | When to Use | Steps |
|
|
118
|
+
|-------------|-------------|-------|
|
|
119
|
+
| **Extract Method** | Method too long, code block needs naming | 1.Create new method 2.Copy code 3.Replace original code with call |
|
|
120
|
+
| **Inline Method** | Method body as clear as its name | 1.Replace calls with method body 2.Delete method |
|
|
121
|
+
| **Replace Temp with Query** | Temporary variable holds expression | 1.Extract expression to method 2.Replace temp with call |
|
|
122
|
+
| **Replace Method with Method Object** | Too many temporaries in long method | 1.Create class for method 2.Temporaries become fields |
|
|
123
|
+
|
|
124
|
+
**Moving Features:**
|
|
125
|
+
|
|
126
|
+
| Refactoring | When to Use | Steps |
|
|
127
|
+
|-------------|-------------|-------|
|
|
128
|
+
| **Move Method** | Method uses other class more | 1.Copy to target 2.Delegate in source 3.Delete source method |
|
|
129
|
+
| **Extract Class** | Class does too much | 1.Create new class 2.Move fields/methods 3.Link classes |
|
|
130
|
+
| **Hide Delegate** | Client knows delegation chain | 1.Add delegate method 2.Hide chain |
|
|
131
|
+
|
|
132
|
+
**Simplifying Conditionals:**
|
|
133
|
+
|
|
134
|
+
| Refactoring | When to Use | Steps |
|
|
135
|
+
|-------------|-------------|-------|
|
|
136
|
+
| **Decompose Conditional** | Complex conditional logic | 1.Extract condition 2.Extract then/else |
|
|
137
|
+
| **Consolidate Conditional** | Multiple checks with same result | 1.Combine with && or \|\| 2.Extract method |
|
|
138
|
+
| **Replace Nested Conditional with Guard Clauses** | Deeply nested if-else | 1.Add guard clause returns 2.Flatten structure |
|
|
139
|
+
| **Replace Conditional with Polymorphism** | Switch by type | 1.Create subclasses 2.Move behavior to each subclass |
|
|
140
|
+
|
|
141
|
+
#### 2.3 Refactoring Decision Tree
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Found code smell?
|
|
145
|
+
│
|
|
146
|
+
├─ Do you have tests?
|
|
147
|
+
│ ├─ No → Write tests first
|
|
148
|
+
│ └─ Yes → Continue
|
|
149
|
+
│
|
|
150
|
+
├─ Do you understand the code?
|
|
151
|
+
│ ├─ No → Refactor to understand
|
|
152
|
+
│ └─ Yes → Continue
|
|
153
|
+
│
|
|
154
|
+
└─ Choose refactoring approach:
|
|
155
|
+
│
|
|
156
|
+
├─ Method too long → Extract Method
|
|
157
|
+
├─ Duplicated code → Extract Method / Pull Up
|
|
158
|
+
├─ Class too large → Extract Class
|
|
159
|
+
├─ Parameter list too long → Introduce Parameter Object
|
|
160
|
+
├─ Switch statement → Replace with Polymorphism
|
|
161
|
+
└─ Complex conditionals → Decompose / Guard Clauses
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
### 3. Design Patterns
|
|
167
|
+
|
|
168
|
+
#### 3.1 SOLID Principles Foundation
|
|
169
|
+
|
|
170
|
+
Before applying patterns, ensure understanding of SOLID principles:
|
|
171
|
+
|
|
172
|
+
| Principle | Name | Description |
|
|
173
|
+
|-----------|------|-------------|
|
|
174
|
+
| **S** | Single Responsibility | One reason to change |
|
|
175
|
+
| **O** | Open/Closed | Open for extension, closed for modification |
|
|
176
|
+
| **L** | Liskov Substitution | Subtypes must be substitutable |
|
|
177
|
+
| **I** | Interface Segregation | Small, focused interfaces |
|
|
178
|
+
| **D** | Dependency Inversion | Depend on abstractions |
|
|
179
|
+
|
|
180
|
+
#### 3.2 Selection by Problem Type
|
|
181
|
+
|
|
182
|
+
| Problem | Pattern | Key Benefit |
|
|
183
|
+
|---------|---------|-------------|
|
|
184
|
+
| Need single instance | Singleton | Controlled access |
|
|
185
|
+
| Flexible object creation | Factory Method | Decouple creation |
|
|
186
|
+
| Create families of objects | Abstract Factory | Consistent products |
|
|
187
|
+
| Build complex objects | Builder | Step-by-step construction |
|
|
188
|
+
| Incompatible interfaces | Adapter | Make incompatible work |
|
|
189
|
+
| Dynamically add responsibilities | Decorator | Flexible extension |
|
|
190
|
+
| Control access | Proxy | Indirection layer |
|
|
191
|
+
| Simplify complex system | Facade | Simple interface |
|
|
192
|
+
| Tree structure | Composite | Uniform handling |
|
|
193
|
+
| Switch algorithms | Strategy | Interchangeable behaviors |
|
|
194
|
+
| Event notification | Observer | Loose coupling |
|
|
195
|
+
| Encapsulate requests | Command | Undo/redo support |
|
|
196
|
+
| State-dependent behavior | State | Clear state transitions |
|
|
197
|
+
|
|
198
|
+
#### 3.3 Selection by Code Smell
|
|
199
|
+
|
|
200
|
+
| Smell | Pattern Solution |
|
|
201
|
+
|-------|------------------|
|
|
202
|
+
| Large switch statement | State, Strategy |
|
|
203
|
+
| Multiple conditionals | Strategy, State, Null Object |
|
|
204
|
+
| Tight coupling | Observer, Mediator, Facade |
|
|
205
|
+
| Difficult object creation | Factory, Builder |
|
|
206
|
+
| Hard to extend class | Decorator, Adapter |
|
|
207
|
+
| Complex subsystem | Facade |
|
|
208
|
+
| Need varying algorithms | Strategy, Template Method |
|
|
209
|
+
|
|
210
|
+
#### 3.4 Pattern Quick Reference
|
|
211
|
+
|
|
212
|
+
**Creational Patterns:**
|
|
213
|
+
|
|
214
|
+
| Pattern | When to Use |
|
|
215
|
+
|---------|-------------|
|
|
216
|
+
| Singleton | Need single instance |
|
|
217
|
+
| Factory Method | Don't know exact class to create |
|
|
218
|
+
| Abstract Factory | Need families of related objects |
|
|
219
|
+
| Builder | Complex object with many options |
|
|
220
|
+
| Prototype | Clone existing objects |
|
|
221
|
+
|
|
222
|
+
**Structural Patterns:**
|
|
223
|
+
|
|
224
|
+
| Pattern | When to Use |
|
|
225
|
+
|---------|-------------|
|
|
226
|
+
| Adapter | Incompatible interfaces |
|
|
227
|
+
| Decorator | Dynamically add responsibilities |
|
|
228
|
+
| Proxy | Control access, lazy loading |
|
|
229
|
+
| Facade | Simplify complex interfaces |
|
|
230
|
+
| Composite | Tree structure, uniform handling |
|
|
231
|
+
| Flyweight | Many similar objects, share state |
|
|
232
|
+
| Bridge | Separate abstraction from implementation |
|
|
233
|
+
|
|
234
|
+
**Behavioral Patterns:**
|
|
235
|
+
|
|
236
|
+
| Pattern | When to Use |
|
|
237
|
+
|---------|-------------|
|
|
238
|
+
| Strategy | Interchangeable algorithms |
|
|
239
|
+
| Observer | One-to-many notifications |
|
|
240
|
+
| Command | Encapsulate requests, undo/redo |
|
|
241
|
+
| State | State-dependent behavior |
|
|
242
|
+
| Template Method | Algorithm skeleton, varying steps |
|
|
243
|
+
| Iterator | Uniform collection traversal |
|
|
244
|
+
| Mediator | Complex object interactions |
|
|
245
|
+
| Memento | Save/restore state |
|
|
246
|
+
| Chain of Resp. | Request has multiple handlers |
|
|
247
|
+
| Visitor | Add operations to object structure |
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
### 4. Integrated Workflow
|
|
252
|
+
|
|
253
|
+
#### 4.1 Code Quality Improvement Process
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
1. IDENTIFY
|
|
257
|
+
└── Detect code smells
|
|
258
|
+
└── Use smell checklist
|
|
259
|
+
└── Rate severity (Critical/High/Medium/Low)
|
|
260
|
+
|
|
261
|
+
2. DIAGNOSE
|
|
262
|
+
└── Understand root cause
|
|
263
|
+
└── Why does this smell exist?
|
|
264
|
+
└── What problems will it cause?
|
|
265
|
+
|
|
266
|
+
3. PLAN
|
|
267
|
+
└── Choose refactoring or pattern
|
|
268
|
+
└── Consider dependencies
|
|
269
|
+
└── Estimate impact
|
|
270
|
+
|
|
271
|
+
4. PREPARE
|
|
272
|
+
└── Ensure tests exist
|
|
273
|
+
└── Run tests to verify behavior
|
|
274
|
+
└── Create tests if missing
|
|
275
|
+
|
|
276
|
+
5. EXECUTE
|
|
277
|
+
└── Apply small changes
|
|
278
|
+
└── Test after each change
|
|
279
|
+
└── Keep code working
|
|
280
|
+
|
|
281
|
+
6. VERIFY
|
|
282
|
+
└── Run all tests
|
|
283
|
+
└── Check for new smells
|
|
284
|
+
└── Confirm improvement
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
#### 4.2 Smell→Refactoring→Pattern Flow
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
Detected code smell
|
|
291
|
+
│
|
|
292
|
+
▼
|
|
293
|
+
┌───────────────────┐
|
|
294
|
+
│ Is this a method │
|
|
295
|
+
│ level problem? │
|
|
296
|
+
└────────┬──────────┘
|
|
297
|
+
│
|
|
298
|
+
┌────┴────┐
|
|
299
|
+
│ Yes │ No
|
|
300
|
+
▼ ▼
|
|
301
|
+
Extract Is this a class
|
|
302
|
+
Method level problem?
|
|
303
|
+
│
|
|
304
|
+
┌────┴────┐
|
|
305
|
+
│ Yes │ No
|
|
306
|
+
▼ ▼
|
|
307
|
+
Extract Is this a
|
|
308
|
+
Class relationship
|
|
309
|
+
problem?
|
|
310
|
+
│
|
|
311
|
+
┌────┴────┐
|
|
312
|
+
│ Yes │ No
|
|
313
|
+
▼ ▼
|
|
314
|
+
Move/Hide Consider
|
|
315
|
+
Delegate Pattern
|
|
316
|
+
│
|
|
317
|
+
▼
|
|
318
|
+
┌──────────────┐
|
|
319
|
+
│ Which │
|
|
320
|
+
│ pattern fits │
|
|
321
|
+
│ best? │
|
|
322
|
+
└──────┬───────┘
|
|
323
|
+
│
|
|
324
|
+
┌───────────────┼───────────────┐
|
|
325
|
+
▼ ▼ ▼
|
|
326
|
+
Creational Structural Behavioral
|
|
327
|
+
Patterns Patterns Patterns
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
### 5. Collaboration Table
|
|
333
|
+
|
|
334
|
+
#### 5.1 Collaboration with Other Skills
|
|
335
|
+
|
|
336
|
+
| Collaborating Skill | Collaboration Mode | Description |
|
|
337
|
+
|--------------------|-------------------|-------------|
|
|
338
|
+
| **test-driven-development** | Sequential | Write tests before refactoring |
|
|
339
|
+
| **systematic-debugging** | Consultation | Find root cause before fixing |
|
|
340
|
+
| **requesting-code-review** | Reference | Get feedback on refactored code |
|
|
341
|
+
| **pdd-code-reviewer** | Reference | Get PDD project code review |
|
|
342
|
+
| **software-engineer** | Delegation | Quality check after code implementation |
|
|
343
|
+
|
|
344
|
+
#### 5.2 Collaboration Workflow
|
|
345
|
+
|
|
346
|
+
```
|
|
347
|
+
Code quality issue detected
|
|
348
|
+
↓
|
|
349
|
+
Invoke expert-code-quality
|
|
350
|
+
↓
|
|
351
|
+
Identify code smells + Recommend refactoring/patterns
|
|
352
|
+
↓
|
|
353
|
+
(If tests needed first) → Invoke test-driven-development
|
|
354
|
+
↓
|
|
355
|
+
(If code implementation needed) → Invoke software-engineer
|
|
356
|
+
↓
|
|
357
|
+
Complete code quality improvement
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
### 6. Quick Decision Matrix
|
|
363
|
+
|
|
364
|
+
| Scenario | Primary Action |
|
|
365
|
+
|----------|---------------|
|
|
366
|
+
| Found duplicated code | Extract Method |
|
|
367
|
+
| Method too long | Extract Method |
|
|
368
|
+
| Class too large | Extract Class |
|
|
369
|
+
| Parameter list too long | Introduce Parameter Object |
|
|
370
|
+
| Switch by type | Replace with Polymorphism |
|
|
371
|
+
| Need single instance | Consider Singleton |
|
|
372
|
+
| Need flexible creation | Factory Method or Builder |
|
|
373
|
+
| Incompatible interfaces | Adapter |
|
|
374
|
+
| Need to add behavior | Decorator |
|
|
375
|
+
| Complex subsystem | Facade |
|
|
376
|
+
| Need varying algorithms | Strategy |
|
|
377
|
+
| Need event notification | Observer |
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
### 7. Anti-Patterns
|
|
382
|
+
|
|
383
|
+
#### 7.1 Refactoring Anti-Patterns
|
|
384
|
+
|
|
385
|
+
| Anti-Pattern | Description | Correct Approach |
|
|
386
|
+
|--------------|-------------|------------------|
|
|
387
|
+
| **Big Bang Refactoring** | Rewrite everything at once | Small incremental changes |
|
|
388
|
+
| **Refactoring Without Tests** | Change code without safety net | Write tests first |
|
|
389
|
+
| **Over-Refactoring** | Refactor clean code | Stop when code is clear |
|
|
390
|
+
| **Refactoring Addiction** | Only refactor, never deliver | Balance refactoring with features |
|
|
391
|
+
| **Random Refactoring** | No clear goal | Identify smells first |
|
|
392
|
+
|
|
393
|
+
#### 7.2 Pattern Anti-Patterns
|
|
394
|
+
|
|
395
|
+
| Anti-Pattern | Description | Correct Approach |
|
|
396
|
+
|--------------|-------------|------------------|
|
|
397
|
+
| **Pattern Obsession** | Use patterns everywhere | Use patterns to solve problems |
|
|
398
|
+
| **Singleton Abuse** | Everything is singleton | Use only when truly needed |
|
|
399
|
+
| **Factory Overkill** | Factory for single product | Use factory for multiple products |
|
|
400
|
+
| **Decorator Nesting** | Too many decorator layers | Limit nesting depth |
|
|
401
|
+
| **Premature Pattern** | Use pattern before needed | Let patterns emerge from refactoring |
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
### 8. Practice Checklists
|
|
406
|
+
|
|
407
|
+
#### 8.1 Code Review Checklist
|
|
408
|
+
|
|
409
|
+
Before approving code, verify:
|
|
410
|
+
- [ ] No critical code smells
|
|
411
|
+
- [ ] Reasonable method size (< 20 lines)
|
|
412
|
+
- [ ] Class has single responsibility
|
|
413
|
+
- [ ] No duplicated code
|
|
414
|
+
- [ ] Clear conditionals
|
|
415
|
+
- [ ] Meaningful names
|
|
416
|
+
- [ ] Tests exist and pass
|
|
417
|
+
- [ ] Follows SOLID principles
|
|
418
|
+
- [ ] Patterns used appropriately (not overused)
|
|
419
|
+
|
|
420
|
+
#### 8.2 Refactoring Safety Checklist
|
|
421
|
+
|
|
422
|
+
Before refactoring:
|
|
423
|
+
- [ ] All tests pass
|
|
424
|
+
- [ ] Tests cover code to refactor
|
|
425
|
+
- [ ] Understand code functionality
|
|
426
|
+
- [ ] Have rollback plan
|
|
427
|
+
- [ ] Make small changes
|
|
428
|
+
- [ ] Test after each change
|
|
429
|
+
|
|
430
|
+
#### 8.3 Pattern Application Checklist
|
|
431
|
+
|
|
432
|
+
Before applying pattern:
|
|
433
|
+
- [ ] Problem matches pattern intent
|
|
434
|
+
- [ ] Pattern solves real problem (not imagined)
|
|
435
|
+
- [ ] Team understands pattern
|
|
436
|
+
- [ ] Pattern doesn't overcomplicate
|
|
437
|
+
- [ ] Alternatives considered
|
|
438
|
+
- [ ] Pattern fits project context
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Guardrails
|
|
443
|
+
|
|
444
|
+
- Must provide suggestions based on Martin Fowler's refactoring catalog and GoF design patterns
|
|
445
|
+
- Refactoring suggestions need specific code transformation examples
|
|
446
|
+
- Pattern application needs to weigh pros and cons, not blindly recommend
|
|
447
|
+
- Code review needs to specifically point out problems and improvement suggestions
|
|
448
|
+
- Clearly state uncertain issues to avoid misleading
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
## Version History
|
|
453
|
+
|
|
454
|
+
### v2.0 (2026-03-21)
|
|
455
|
+
- Unified to Chinese description
|
|
456
|
+
- Added collaboration table, clarified collaboration with other skills
|
|
457
|
+
- Enhanced quick decision matrix
|
|
458
|
+
- Optimized refactoring decision tree
|
|
459
|
+
- Added anti-pattern checklist
|
|
460
|
+
|
|
461
|
+
### v1.0 (Initial version)
|
|
462
|
+
- Basic code quality detection
|
|
463
|
+
- Refactoring technique catalog
|
|
464
|
+
- Design pattern reference
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
> **Remember**: Good code isn't about being clever—it's about being clear. Refactoring and patterns are tools to achieve clarity, not ends in themselves.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "expert-code-quality", "version": "1.0.0", "category": "entropy", "description": "Code quality expert integrating refactoring techniques and design patterns for systematic improvement. Call when reviewing code, refactoring, checking code smells, or applying SOLID principles.", "triggers": ["代码审查", "重构", "设计模式", "SOLID原则"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"name": "SKILL.md-exists", "description": "技能文件存在且格式正确", "type": "structure", "expect": {"exists": true, "hasDescription": true}, "checks": {"file_exists": "SKILL.md"}}, {"name": "_meta.json-valid", "description": "元数据文件格式正确", "type": "structure", "expect": {"exists": true, "hasName": true, "hasVersion": true, "hasTriggers": true}, "checks": {"file_exists": "_meta.json"}}, {"name": "quality-dimensions-defined", "description": "定义了代码质量维度(重构+设计模式)", "type": "content", "contains": ["quality", "Refactoring", "Design Patterns", "maintainable", "SOLID"]}, {"name": "refactoring-techniques-defined", "description": "整合了重构技术和设计模式", "type": "content", "contains": ["Refactoring", "Design Patterns", "clean", "extensible"]}, {"name": "references-defined", "description": "定义了参考文档目录结构", "type": "content", "contains": ["references", "catalog", "patterns", "smells", "principles"]}]
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "code-quality-expert",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"name": "detect-code-smells",
|
|
7
|
+
"prompt": "Review this Java code and identify any code smells:\n\n```java\npublic class OrderManager {\n public void processOrder(Order order) {\n // Validate order\n if (order.getItems() == null || order.getItems().isEmpty()) {\n throw new IllegalArgumentException(\"Order has no items\");\n }\n if (order.getCustomer() == null) {\n throw new IllegalArgumentException(\"Order has no customer\");\n }\n if (order.getCustomer().getAddress() == null) {\n throw new IllegalArgumentException(\"Customer has no address\");\n }\n \n // Calculate total\n double total = 0;\n for (OrderItem item : order.getItems()) {\n total += item.getPrice() * item.getQuantity();\n }\n \n // Apply discount\n double discount = 0;\n if (order.getCustomer().getType().equals(\"VIP\")) {\n discount = total * 0.1;\n } else if (order.getCustomer().getType().equals(\"Premium\")) {\n discount = total * 0.15;\n } else if (order.getCustomer().getType().equals(\"Gold\")) {\n discount = total * 0.2;\n }\n \n // Save order\n DatabaseConnection db = new DatabaseConnection();\n db.connect();\n db.execute(\"INSERT INTO orders VALUES (...) \");\n db.close();\n \n // Send email\n EmailService email = new EmailService();\n email.send(order.getCustomer().getEmail(), \"Order confirmed\");\n }\n}",
|
|
8
|
+
"expected_output": "Should identify multiple code smells: Long Method, Switch Statements, Feature Envy, Primitive Obsession, and suggest appropriate refactorings",
|
|
9
|
+
"assertions": [
|
|
10
|
+
{
|
|
11
|
+
"name": "identifies_long_method",
|
|
12
|
+
"description": "Should identify the method is too long and doing too many things"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "identifies_switch_statements",
|
|
16
|
+
"description": "Should identify switch/if-else on customer type as a smell"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "suggests_refactorings",
|
|
20
|
+
"description": "Should suggest specific refactorings like Extract Method, Replace Conditional with Polymorphism"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": 2,
|
|
26
|
+
"name": "recommend-design-pattern",
|
|
27
|
+
"prompt": "I have a class that needs to create different types of report objects (PDFReport, ExcelReport, HTMLReport) based on user configuration. The creation logic is getting complex with many conditionals. What design pattern should I use and how should I implement it?",
|
|
28
|
+
"expected_output": "Should recommend Factory Method or Abstract Factory pattern with clear explanation and implementation example",
|
|
29
|
+
"assertions": [
|
|
30
|
+
{
|
|
31
|
+
"name": "recommends_factory_pattern",
|
|
32
|
+
"description": "Should recommend Factory Method or Abstract Factory pattern"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "provides_implementation",
|
|
36
|
+
"description": "Should provide code example showing the pattern implementation"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "explains_benefits",
|
|
40
|
+
"description": "Should explain why this pattern fits the problem"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": 3,
|
|
46
|
+
"name": "refactoring-guidance",
|
|
47
|
+
"prompt": "I found this code smell in my codebase - a class called 'UserManager' that handles user authentication, user profile management, user notifications, and user reporting. It's over 500 lines. How should I refactor this?",
|
|
48
|
+
"expected_output": "Should identify this as Large Class and Divergent Change smells, recommend Extract Class refactoring, and provide step-by-step guidance",
|
|
49
|
+
"assertions": [
|
|
50
|
+
{
|
|
51
|
+
"name": "identifies_smells",
|
|
52
|
+
"description": "Should correctly identify Large Class and Divergent Change"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "recommends_extract_class",
|
|
56
|
+
"description": "Should recommend Extract Class refactoring"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "provides_steps",
|
|
60
|
+
"description": "Should provide step-by-step refactoring guidance"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "mentions_srp",
|
|
64
|
+
"description": "Should mention Single Responsibility Principle"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": 4,
|
|
70
|
+
"name": "solid-principle-violation",
|
|
71
|
+
"prompt": "Review this code for SOLID principle violations:\n\n```java\npublic class ReportGenerator {\n private MySQLDatabase db;\n \n public ReportGenerator() {\n this.db = new MySQLDatabase();\n }\n \n public void generateReport(String type) {\n if (type.equals(\"PDF\")) {\n generatePdfReport();\n } else if (type.equals(\"Excel\")) {\n generateExcelReport();\n } else if (type.equals(\"HTML\")) {\n generateHtmlReport();\n }\n }\n \n private void generatePdfReport() { /* ... */ }\n private void generateExcelReport() { /* ... */ }\n private void generateHtmlReport() { /* ... */ }\n}\n```",
|
|
72
|
+
"expected_output": "Should identify OCP violation (switch on type), DIP violation (direct instantiation), and suggest improvements",
|
|
73
|
+
"assertions": [
|
|
74
|
+
{
|
|
75
|
+
"name": "identifies_ocp_violation",
|
|
76
|
+
"description": "Should identify Open/Closed Principle violation in generateReport method"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "identifies_dip_violation",
|
|
80
|
+
"description": "Should identify Dependency Inversion Principle violation in constructor"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "suggests_improvements",
|
|
84
|
+
"description": "Should suggest Strategy pattern and dependency injection"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": 5,
|
|
90
|
+
"name": "pattern-selection",
|
|
91
|
+
"prompt": "I need to implement a feature where multiple objects need to be notified when a user's status changes. What design pattern should I use?",
|
|
92
|
+
"expected_output": "Should recommend Observer pattern with explanation and implementation example",
|
|
93
|
+
"assertions": [
|
|
94
|
+
{
|
|
95
|
+
"name": "recommends_observer",
|
|
96
|
+
"description": "Should recommend Observer pattern"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "explains_pattern",
|
|
100
|
+
"description": "Should explain how Observer pattern works"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "provides_example",
|
|
104
|
+
"description": "Should provide code example"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|