skillstore-cli 1.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 +95 -0
- package/data/bundles/devflow-complete.json +19 -0
- package/data/free-skills/devflow-agile/manifest.json +19 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile/retro.md +23 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile/review.md +21 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile/sprint.md +30 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile/standup.md +20 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile.md +35 -0
- package/data/free-skills/devflow-agile/plugin/commands/devflow.md +42 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/SKILL.md +93 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/assets/sample-output.md +182 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/references/clean-architecture.md +361 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/references/clean-code-guide.md +207 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/references/debugging-methodology.md +191 -0
- package/data/free-skills/devflow-agile/template/agents/agile-coach.md +76 -0
- package/data/free-skills/devflow-agile/template/workflows/agile-sprint-workflow.md +81 -0
- package/data/free-skills/devflow-bootstrap/manifest.json +8 -0
- package/data/free-skills/devflow-bootstrap/plugin/commands/bootstrap/auto.md +31 -0
- package/data/free-skills/devflow-bootstrap/plugin/commands/bootstrap.md +38 -0
- package/data/free-skills/devflow-bootstrap/plugin/commands/devflow.md +20 -0
- package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/SKILL.md +56 -0
- package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/assets/sample-output.md +216 -0
- package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/references/architecture-decisions.md +254 -0
- package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/references/stack-templates.md +400 -0
- package/data/free-skills/devflow-bootstrap/template/agents/bootstrap-specialist.md +56 -0
- package/data/free-skills/devflow-bootstrap/template/workflows/bootstrap-workflow.md +70 -0
- package/data/free-skills/devflow-docs/manifest.json +8 -0
- package/data/free-skills/devflow-docs/plugin/commands/devflow.md +20 -0
- package/data/free-skills/devflow-docs/plugin/commands/docs/generate.md +17 -0
- package/data/free-skills/devflow-docs/plugin/commands/docs/parse.md +19 -0
- package/data/free-skills/devflow-docs/plugin/commands/docs.md +26 -0
- package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/SKILL.md +59 -0
- package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/assets/sample-output.md +114 -0
- package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/references/extraction-techniques.md +115 -0
- package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/references/ocr-strategies.md +167 -0
- package/data/free-skills/devflow-docs/template/agents/docs-specialist.md +35 -0
- package/data/free-skills/devflow-docs/template/workflows/docs-workflow.md +70 -0
- package/data/free-skills/devflow-postproject/manifest.json +13 -0
- package/data/free-skills/devflow-postproject/plugin/commands/devflow.md +34 -0
- package/data/free-skills/devflow-postproject/plugin/commands/postproject/handover.md +21 -0
- package/data/free-skills/devflow-postproject/plugin/commands/postproject/retro.md +21 -0
- package/data/free-skills/devflow-postproject/plugin/commands/postproject/support.md +21 -0
- package/data/free-skills/devflow-postproject/plugin/commands/postproject.md +32 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/SKILL.md +70 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/assets/sample-output.md +79 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/facilitation-techniques.md +178 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/lessons-learned-template.md +118 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/retro-techniques.md +100 -0
- package/data/free-skills/devflow-postproject/template/agents/transition-manager.md +71 -0
- package/data/free-skills/devflow-postproject/template/workflows/transition-workflow.md +72 -0
- package/data/free-skills/devflow-presale/manifest.json +15 -0
- package/data/free-skills/devflow-presale/plugin/commands/devflow.md +47 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale/analyze.md +30 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale/estimate.md +30 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale/price.md +30 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale/propose.md +30 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale.md +42 -0
- package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/SKILL.md +63 -0
- package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/assets/sample-output.md +129 -0
- package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/references/extraction-framework.md +140 -0
- package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/references/output-template.md +132 -0
- package/data/free-skills/devflow-presale/template/agents/presale-lead.md +83 -0
- package/data/free-skills/devflow-presale/template/agents/proposal-reviewer.md +63 -0
- package/data/free-skills/devflow-presale/template/workflows/presale-workflow.md +70 -0
- package/data/registry/categories.json +7 -0
- package/data/registry/packages.json +184 -0
- package/data/shared/framework/agents/brainstormer.md +74 -0
- package/data/shared/framework/agents/code-reviewer.md +87 -0
- package/data/shared/framework/agents/debugger.md +84 -0
- package/data/shared/framework/agents/docs-manager.md +55 -0
- package/data/shared/framework/agents/git-manager.md +59 -0
- package/data/shared/framework/agents/planner.md +68 -0
- package/data/shared/framework/agents/researcher.md +66 -0
- package/data/shared/framework/agents/tester.md +65 -0
- package/data/shared/framework/commands/cook/auto.md +27 -0
- package/data/shared/framework/commands/cook.md +45 -0
- package/data/shared/framework/commands/fix/ci.md +21 -0
- package/data/shared/framework/commands/fix/test.md +26 -0
- package/data/shared/framework/commands/fix/types.md +29 -0
- package/data/shared/framework/commands/fix.md +26 -0
- package/data/shared/framework/commands/git/cm.md +37 -0
- package/data/shared/framework/commands/git/pr.md +40 -0
- package/data/shared/framework/config/CLAUDE.md.template +26 -0
- package/data/shared/framework/config/settings.json +41 -0
- package/data/shared/framework/config/skillstore.config.json +29 -0
- package/data/shared/framework/hooks/discord-notify.sh +85 -0
- package/data/shared/framework/hooks/docs-sync.sh +53 -0
- package/data/shared/framework/hooks/modularization-hook.js +103 -0
- package/data/shared/framework/hooks/notification.js +94 -0
- package/data/shared/framework/hooks/quality-gate.js +109 -0
- package/data/shared/framework/hooks/scout-block.js +77 -0
- package/data/shared/framework/hooks/telegram-notify.sh +77 -0
- package/data/shared/framework/protocols/error-recovery.md +80 -0
- package/data/shared/framework/protocols/orchestration-protocol.md +112 -0
- package/data/shared/framework/quality/review-protocol.md +76 -0
- package/data/shared/framework/quality/verification-protocol.md +66 -0
- package/data/shared/framework/rules/development-rules.md +75 -0
- package/data/shared/framework/skills/backend-development/SKILL.md +77 -0
- package/data/shared/framework/skills/backend-development/assets/sample-output.md +175 -0
- package/data/shared/framework/skills/backend-development/references/advanced-patterns.md +180 -0
- package/data/shared/framework/skills/backend-development/references/api-design-guide.md +160 -0
- package/data/shared/framework/skills/backend-development/references/architecture-patterns.md +183 -0
- package/data/shared/framework/skills/backend-development/references/observability-resilience.md +155 -0
- package/data/shared/framework/skills/backend-development/references/troubleshooting.md +199 -0
- package/data/shared/framework/skills/codebase-analysis/SKILL.md +72 -0
- package/data/shared/framework/skills/codebase-analysis/assets/sample-output.md +263 -0
- package/data/shared/framework/skills/codebase-analysis/references/analysis-techniques.md +241 -0
- package/data/shared/framework/skills/codebase-analysis/references/dependency-mapping.md +280 -0
- package/data/shared/framework/skills/codebase-analysis/references/tech-debt-assessment.md +208 -0
- package/data/shared/framework/skills/databases/SKILL.md +72 -0
- package/data/shared/framework/skills/databases/assets/sample-output.md +212 -0
- package/data/shared/framework/skills/databases/references/advanced-data-patterns.md +259 -0
- package/data/shared/framework/skills/databases/references/query-optimization.md +214 -0
- package/data/shared/framework/skills/databases/references/schema-design.md +159 -0
- package/data/shared/framework/skills/databases/references/troubleshooting.md +214 -0
- package/data/shared/framework/skills/debugging-investigation/SKILL.md +84 -0
- package/data/shared/framework/skills/debugging-investigation/assets/sample-output.md +314 -0
- package/data/shared/framework/skills/debugging-investigation/references/systematic-debugging.md +197 -0
- package/data/shared/framework/skills/debugging-investigation/references/tool-specific-guides.md +202 -0
- package/data/shared/framework/skills/debugging-investigation/references/troubleshooting-patterns.md +196 -0
- package/data/shared/framework/skills/frontend-development/SKILL.md +67 -0
- package/data/shared/framework/skills/frontend-development/assets/sample-output.md +110 -0
- package/data/shared/framework/skills/frontend-development/references/component-patterns.md +112 -0
- package/data/shared/framework/skills/frontend-development/references/performance-guide.md +169 -0
- package/data/shared/framework/skills/frontend-development/references/routing-forms-realtime.md +374 -0
- package/data/shared/framework/skills/frontend-development/references/ssr-rsc-patterns.md +284 -0
- package/data/shared/framework/skills/frontend-development/references/troubleshooting.md +154 -0
- package/data/shared/framework/skills/mobile-development/SKILL.md +67 -0
- package/data/shared/framework/skills/mobile-development/assets/sample-output.md +382 -0
- package/data/shared/framework/skills/mobile-development/references/mobile-patterns.md +681 -0
- package/data/shared/framework/skills/mobile-development/references/mobile-performance.md +524 -0
- package/data/shared/framework/skills/mobile-development/references/troubleshooting.md +158 -0
- package/data/shared/framework/skills/security-audit/SKILL.md +83 -0
- package/data/shared/framework/skills/security-audit/assets/sample-output.md +451 -0
- package/data/shared/framework/skills/security-audit/references/owasp-checklist.md +580 -0
- package/data/shared/framework/skills/security-audit/references/secure-coding-patterns.md +433 -0
- package/data/shared/framework/skills/security-audit/references/vulnerability-remediation.md +331 -0
- package/data/shared/framework/skills/ui-generation/SKILL.md +70 -0
- package/data/shared/framework/skills/ui-generation/assets/sample-output.md +139 -0
- package/data/shared/framework/skills/ui-generation/references/accessibility-responsive.md +127 -0
- package/data/shared/framework/skills/ui-generation/references/compound-components.md +252 -0
- package/data/shared/framework/skills/ui-generation/references/generation-patterns.md +110 -0
- package/data/shared/framework/skills/ui-generation/references/storybook-design-system.md +278 -0
- package/data/shared/framework/skills/ui-generation/references/troubleshooting.md +198 -0
- package/data/shared/framework/workflows/documentation-management.md +58 -0
- package/data/shared/framework/workflows/primary-workflow.md +88 -0
- package/dist/commands/activate.d.ts +3 -0
- package/dist/commands/activate.d.ts.map +1 -0
- package/dist/commands/activate.js +34 -0
- package/dist/commands/activate.js.map +1 -0
- package/dist/commands/bundle.d.ts +3 -0
- package/dist/commands/bundle.d.ts.map +1 -0
- package/dist/commands/bundle.js +64 -0
- package/dist/commands/bundle.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +99 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +37 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/search.d.ts +3 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +30 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +35 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +68 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/download/cache.d.ts +3 -0
- package/dist/download/cache.d.ts.map +1 -0
- package/dist/download/cache.js +18 -0
- package/dist/download/cache.js.map +1 -0
- package/dist/download/client.d.ts +2 -0
- package/dist/download/client.d.ts.map +1 -0
- package/dist/download/client.js +58 -0
- package/dist/download/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/file-copier.d.ts +6 -0
- package/dist/installer/file-copier.d.ts.map +1 -0
- package/dist/installer/file-copier.js +32 -0
- package/dist/installer/file-copier.js.map +1 -0
- package/dist/installer/plugin-installer.d.ts +12 -0
- package/dist/installer/plugin-installer.d.ts.map +1 -0
- package/dist/installer/plugin-installer.js +33 -0
- package/dist/installer/plugin-installer.js.map +1 -0
- package/dist/installer/template-installer.d.ts +12 -0
- package/dist/installer/template-installer.d.ts.map +1 -0
- package/dist/installer/template-installer.js +45 -0
- package/dist/installer/template-installer.js.map +1 -0
- package/dist/license/crypto.d.ts +16 -0
- package/dist/license/crypto.d.ts.map +1 -0
- package/dist/license/crypto.js +50 -0
- package/dist/license/crypto.js.map +1 -0
- package/dist/license/license-store.d.ts +19 -0
- package/dist/license/license-store.d.ts.map +1 -0
- package/dist/license/license-store.js +99 -0
- package/dist/license/license-store.js.map +1 -0
- package/dist/license/validator.d.ts +32 -0
- package/dist/license/validator.d.ts.map +1 -0
- package/dist/license/validator.js +81 -0
- package/dist/license/validator.js.map +1 -0
- package/dist/registry/loader.d.ts +30 -0
- package/dist/registry/loader.d.ts.map +1 -0
- package/dist/registry/loader.js +22 -0
- package/dist/registry/loader.js.map +1 -0
- package/dist/registry/search-engine.d.ts +9 -0
- package/dist/registry/search-engine.d.ts.map +1 -0
- package/dist/registry/search-engine.js +30 -0
- package/dist/registry/search-engine.js.map +1 -0
- package/dist/utils/config.d.ts +14 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +28 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/logger.d.ts +9 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +22 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/paths.d.ts +20 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +79 -0
- package/dist/utils/paths.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Tech Debt Assessment
|
|
2
|
+
|
|
3
|
+
## Tech Debt Taxonomy
|
|
4
|
+
|
|
5
|
+
### Code Debt
|
|
6
|
+
- **Duplication**: copy-pasted logic instead of shared abstractions
|
|
7
|
+
- **Complexity**: functions with cyclomatic complexity > 15, deeply nested conditionals
|
|
8
|
+
- **Naming**: unclear variable/function names that require comments to explain
|
|
9
|
+
- **Style inconsistency**: mixed formatting, different patterns for the same operation
|
|
10
|
+
|
|
11
|
+
### Design Debt
|
|
12
|
+
- **Wrong abstractions**: premature abstractions that don't match actual use cases
|
|
13
|
+
- **Tight coupling**: modules that cannot be changed or tested independently
|
|
14
|
+
- **Leaky abstractions**: implementation details exposed through interfaces
|
|
15
|
+
- **Missing boundaries**: business logic mixed with infrastructure (SQL in controllers, HTTP in services)
|
|
16
|
+
|
|
17
|
+
### Infrastructure Debt
|
|
18
|
+
- **Outdated tooling**: old Node.js/Python/Go versions, deprecated bundlers
|
|
19
|
+
- **Manual processes**: deployments, database migrations, or environment setup done by hand
|
|
20
|
+
- **Missing CI/CD**: no automated testing, linting, or deployment pipeline
|
|
21
|
+
- **Configuration drift**: environments differ in ways that cause "works on my machine" bugs
|
|
22
|
+
|
|
23
|
+
### Testing Debt
|
|
24
|
+
- **Low coverage**: critical paths with < 50% test coverage
|
|
25
|
+
- **Flaky tests**: tests that fail intermittently due to timing, external dependencies, or shared state
|
|
26
|
+
- **Missing test types**: no integration tests, no E2E tests, no contract tests
|
|
27
|
+
- **Slow test suite**: test suite takes > 10 minutes, discouraging frequent runs
|
|
28
|
+
|
|
29
|
+
### Documentation Debt
|
|
30
|
+
- **Stale docs**: README or wiki that describes a previous version of the system
|
|
31
|
+
- **Missing ADRs**: architectural decisions made without recorded reasoning
|
|
32
|
+
- **No onboarding guide**: new developers take weeks to become productive
|
|
33
|
+
- **Undocumented APIs**: internal or external APIs without request/response examples
|
|
34
|
+
|
|
35
|
+
## Severity Scoring Matrix
|
|
36
|
+
|
|
37
|
+
Rate each tech debt item on two dimensions:
|
|
38
|
+
|
|
39
|
+
### Impact Score (1-5)
|
|
40
|
+
|
|
41
|
+
| Score | Impact Level | Description |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| 1 | Minimal | Cosmetic issue, no functional impact |
|
|
44
|
+
| 2 | Low | Minor inconvenience, easy workaround exists |
|
|
45
|
+
| 3 | Moderate | Slows development, occasional bugs |
|
|
46
|
+
| 4 | High | Frequent bugs, significant velocity impact |
|
|
47
|
+
| 5 | Critical | Security risk, data loss potential, blocks features |
|
|
48
|
+
|
|
49
|
+
### Effort Score (1-5)
|
|
50
|
+
|
|
51
|
+
| Score | Effort Level | Description |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| 1 | Trivial | < 1 hour, single file change |
|
|
54
|
+
| 2 | Small | 1-4 hours, few files |
|
|
55
|
+
| 3 | Medium | 1-2 days, multiple modules |
|
|
56
|
+
| 4 | Large | 3-5 days, cross-cutting changes |
|
|
57
|
+
| 5 | Major | 1+ weeks, architecture-level change |
|
|
58
|
+
|
|
59
|
+
### Priority Calculation
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Priority Score = Impact × (6 - Effort)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Higher score = higher priority. This formula favors high-impact, low-effort items (quick wins).
|
|
66
|
+
|
|
67
|
+
| Priority Score | Action |
|
|
68
|
+
|---|---|
|
|
69
|
+
| 20-25 | Immediate — fix in current sprint |
|
|
70
|
+
| 12-19 | Planned — schedule in next 2-3 sprints |
|
|
71
|
+
| 6-11 | Backlog — address when touching related code |
|
|
72
|
+
| 1-5 | Defer — not worth dedicated effort |
|
|
73
|
+
|
|
74
|
+
## Tech Debt Discovery Checklist
|
|
75
|
+
|
|
76
|
+
### Automated Checks
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Count linter warnings
|
|
80
|
+
npx eslint src/ --format json | jq '[.[].messages | length] | add'
|
|
81
|
+
|
|
82
|
+
# Count TODO/FIXME/HACK markers
|
|
83
|
+
grep -rn 'TODO\|FIXME\|HACK\|XXX\|WORKAROUND' --include='*.ts' --include='*.tsx' src/ | wc -l
|
|
84
|
+
|
|
85
|
+
# List all TODO/FIXME with file locations
|
|
86
|
+
grep -rn 'TODO\|FIXME\|HACK' --include='*.ts' --include='*.tsx' src/
|
|
87
|
+
|
|
88
|
+
# TypeScript strict mode gaps
|
|
89
|
+
npx tsc --noEmit --strict 2>&1 | wc -l
|
|
90
|
+
|
|
91
|
+
# Check TypeScript strict settings
|
|
92
|
+
cat tsconfig.json | grep -E '"strict"|"noImplicit|"strictNull"'
|
|
93
|
+
|
|
94
|
+
# Dependency age — packages not updated in 12+ months
|
|
95
|
+
npm outdated --long
|
|
96
|
+
|
|
97
|
+
# Test coverage summary
|
|
98
|
+
npx jest --coverage --coverageReporters=text-summary 2>&1 | tail -5
|
|
99
|
+
|
|
100
|
+
# Bundle size analysis
|
|
101
|
+
npx webpack-bundle-analyzer stats.json
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Manual Inspection Points
|
|
105
|
+
|
|
106
|
+
- [ ] Are there god classes/files (> 500 lines)?
|
|
107
|
+
- [ ] Do any modules have 10+ dependencies?
|
|
108
|
+
- [ ] Are error messages helpful for debugging?
|
|
109
|
+
- [ ] Is there consistent error handling across the codebase?
|
|
110
|
+
- [ ] Are environment variables validated at startup?
|
|
111
|
+
- [ ] Is there a consistent data validation strategy?
|
|
112
|
+
- [ ] Are database queries parameterized (no string concatenation)?
|
|
113
|
+
- [ ] Is there a clear separation between business logic and infrastructure?
|
|
114
|
+
- [ ] Can each module be tested in isolation?
|
|
115
|
+
- [ ] Are there any hardcoded secrets, URLs, or configuration values?
|
|
116
|
+
|
|
117
|
+
## Remediation Prioritization
|
|
118
|
+
|
|
119
|
+
### Quadrant Model
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
High Impact
|
|
123
|
+
|
|
|
124
|
+
PLANNED | QUICK WINS
|
|
125
|
+
(schedule it) | (do it now)
|
|
126
|
+
|
|
|
127
|
+
High Effort -------- -+--------- Low Effort
|
|
128
|
+
|
|
|
129
|
+
IGNORE | BOY SCOUT
|
|
130
|
+
(not worth it) | (fix when nearby)
|
|
131
|
+
|
|
|
132
|
+
Low Impact
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Quick Wins (High Impact, Low Effort)
|
|
136
|
+
- Add missing input validation on public endpoints
|
|
137
|
+
- Fix known security vulnerabilities in dependencies
|
|
138
|
+
- Add TypeScript strict mode to new files
|
|
139
|
+
- Remove dead code flagged by tooling
|
|
140
|
+
- Add error monitoring (Sentry, DataDog)
|
|
141
|
+
|
|
142
|
+
### Planned Work (High Impact, High Effort)
|
|
143
|
+
- Break apart monolithic services
|
|
144
|
+
- Migrate from deprecated framework version
|
|
145
|
+
- Add integration test suite for critical paths
|
|
146
|
+
- Implement proper authentication/authorization
|
|
147
|
+
- Establish CI/CD pipeline
|
|
148
|
+
|
|
149
|
+
### Boy Scout Items (Low Impact, Low Effort)
|
|
150
|
+
- Rename unclear variables when editing a file
|
|
151
|
+
- Add type annotations to functions you're modifying
|
|
152
|
+
- Remove commented-out code you encounter
|
|
153
|
+
- Fix linter warnings in files you touch
|
|
154
|
+
- Add JSDoc to public functions you're working on
|
|
155
|
+
|
|
156
|
+
### Ignore (Low Impact, High Effort)
|
|
157
|
+
- Rewriting stable legacy code that rarely changes
|
|
158
|
+
- Migrating to a new ORM when the current one works fine
|
|
159
|
+
- Full code style migration when auto-formatters exist
|
|
160
|
+
- Abstracting one-off scripts that run correctly
|
|
161
|
+
|
|
162
|
+
## Tech Debt Tracking Template
|
|
163
|
+
|
|
164
|
+
Use this template to create a tech debt inventory:
|
|
165
|
+
|
|
166
|
+
| ID | Category | Description | Impact (1-5) | Effort (1-5) | Priority | Status | Owner |
|
|
167
|
+
|---|---|---|---|---|---|---|---|
|
|
168
|
+
| TD-001 | Testing | No E2E tests for checkout flow | 5 | 4 | 10 | Planned | @team-payments |
|
|
169
|
+
| TD-002 | Code | Duplicated validation in 3 controllers | 3 | 2 | 12 | Backlog | — |
|
|
170
|
+
| TD-003 | Infra | Node.js 16 EOL, need upgrade to 20 | 4 | 3 | 12 | In Progress | @platform |
|
|
171
|
+
| TD-004 | Design | Auth logic spread across 5 modules | 4 | 4 | 8 | Planned | @team-identity |
|
|
172
|
+
| TD-005 | Docs | API docs 6 months out of date | 3 | 2 | 12 | Backlog | — |
|
|
173
|
+
|
|
174
|
+
### Tracking Best Practices
|
|
175
|
+
|
|
176
|
+
- Review the inventory quarterly — remove resolved items, reassess priorities
|
|
177
|
+
- Assign owners to high-priority items — unowned debt never gets fixed
|
|
178
|
+
- Include tech debt budget in sprint planning (15-20% of capacity)
|
|
179
|
+
- Celebrate debt reduction — make it visible in retrospectives
|
|
180
|
+
- Link tech debt items to incidents they cause — builds business case
|
|
181
|
+
|
|
182
|
+
## "Boy Scout Rule" Integration
|
|
183
|
+
|
|
184
|
+
> "Leave the code better than you found it." — Robert C. Martin
|
|
185
|
+
|
|
186
|
+
### Within Scope
|
|
187
|
+
|
|
188
|
+
When working on a feature or bug fix, improve nearby code:
|
|
189
|
+
- Fix linter warnings in files you're editing
|
|
190
|
+
- Add types to functions you're calling
|
|
191
|
+
- Rename unclear variables in your working area
|
|
192
|
+
- Remove dead code you discover
|
|
193
|
+
- Add missing tests for functions you're modifying
|
|
194
|
+
|
|
195
|
+
### Out of Scope
|
|
196
|
+
|
|
197
|
+
Do NOT let Boy Scout improvements derail your current task:
|
|
198
|
+
- Don't refactor an entire module when fixing a one-line bug
|
|
199
|
+
- Don't upgrade a dependency if it's not related to your change
|
|
200
|
+
- Don't rewrite a function if the existing behavior is correct
|
|
201
|
+
- Keep cleanup commits separate from feature commits for clean git history
|
|
202
|
+
|
|
203
|
+
### Making It Sustainable
|
|
204
|
+
|
|
205
|
+
- Time-box Boy Scout improvements to 15-20 minutes per PR
|
|
206
|
+
- If you find something bigger, create a tech debt ticket instead of fixing it now
|
|
207
|
+
- Review Boy Scout changes in PRs — they should be low-risk and obvious improvements
|
|
208
|
+
- Track cumulative impact — small improvements compound over time
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: databases
|
|
3
|
+
description: Database design, query optimization, migrations, and data modeling for SQL and NoSQL systems
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Databases
|
|
7
|
+
|
|
8
|
+
## Triggers
|
|
9
|
+
|
|
10
|
+
Activate this skill when:
|
|
11
|
+
- Designing a new database schema or data model
|
|
12
|
+
- Optimizing slow queries (identified by monitoring or EXPLAIN output)
|
|
13
|
+
- Planning database migrations (especially for production systems)
|
|
14
|
+
- Choosing between SQL and NoSQL for a new feature or service
|
|
15
|
+
- Adding or reviewing indexes
|
|
16
|
+
- Handling data integrity issues or race conditions
|
|
17
|
+
- Implementing sharding, partitioning, or multi-tenant data isolation
|
|
18
|
+
- Setting up Change Data Capture (CDC) or event streaming from databases
|
|
19
|
+
- Designing temporal/versioned data or audit trail systems
|
|
20
|
+
- Evaluating full-text search solutions (in-database vs external)
|
|
21
|
+
|
|
22
|
+
## Process
|
|
23
|
+
|
|
24
|
+
### 1. Requirements Analysis
|
|
25
|
+
- Identify entities, their attributes, and relationships
|
|
26
|
+
- Estimate data volume (rows per table now and in 12 months)
|
|
27
|
+
- List read/write patterns (which queries run most often, at what frequency)
|
|
28
|
+
- Identify consistency requirements (strict ACID vs. eventual consistency)
|
|
29
|
+
- Note compliance requirements (data retention, PII handling, auditing)
|
|
30
|
+
|
|
31
|
+
### 2. Data Modeling
|
|
32
|
+
- Start with a conceptual model (entities and relationships on paper)
|
|
33
|
+
- Create logical model (tables, columns, types, constraints)
|
|
34
|
+
- Normalize to 3NF, then selectively denormalize for read performance
|
|
35
|
+
- Define primary keys (prefer UUIDs or ULIDs for distributed systems, auto-increment for single-node)
|
|
36
|
+
- Map relationships (foreign keys, junction tables, embedded docs)
|
|
37
|
+
|
|
38
|
+
### 3. Schema Design
|
|
39
|
+
- Choose appropriate data types (don't use VARCHAR(255) for everything)
|
|
40
|
+
- Add NOT NULL constraints by default — make nullable only with reason
|
|
41
|
+
- Define CHECK constraints for enums and ranges
|
|
42
|
+
- Set up created_at/updated_at timestamps with defaults
|
|
43
|
+
- Add soft delete (deleted_at) if required by business rules
|
|
44
|
+
|
|
45
|
+
### 4. Index Design
|
|
46
|
+
- Create indexes based on actual query patterns, not guesses
|
|
47
|
+
- Start with indexes on: foreign keys, columns in WHERE/JOIN/ORDER BY
|
|
48
|
+
- Use composite indexes matching query column order (leftmost prefix rule)
|
|
49
|
+
- Monitor unused indexes and remove them (they slow down writes)
|
|
50
|
+
|
|
51
|
+
### 5. Query Optimization
|
|
52
|
+
- Run EXPLAIN/ANALYZE on slow queries
|
|
53
|
+
- Fix common anti-patterns (N+1, SELECT *, missing indexes)
|
|
54
|
+
- Consider denormalization or materialized views for complex reports
|
|
55
|
+
- Set up query monitoring (slow query log, pg_stat_statements)
|
|
56
|
+
|
|
57
|
+
### 6. Migration Planning
|
|
58
|
+
- Write reversible migrations (up and down)
|
|
59
|
+
- Plan zero-downtime migrations for production (expand-contract pattern)
|
|
60
|
+
- Test migrations against production-size data before deploying
|
|
61
|
+
- Back up before every production migration
|
|
62
|
+
|
|
63
|
+
## References
|
|
64
|
+
|
|
65
|
+
- [Schema Design](references/schema-design.md) — normalization, indexes, SQL vs NoSQL, naming conventions
|
|
66
|
+
- [Query Optimization](references/query-optimization.md) — EXPLAIN, anti-patterns, connection pooling, migrations
|
|
67
|
+
- [Advanced Data Patterns](references/advanced-data-patterns.md) — sharding, CDC, temporal tables, full-text search, multi-tenancy
|
|
68
|
+
- [Troubleshooting](references/troubleshooting.md) — slow query diagnosis, lock contention, replication lag, migration failures, deadlocks
|
|
69
|
+
|
|
70
|
+
## Assets
|
|
71
|
+
|
|
72
|
+
- [Sample Output](assets/sample-output.md) — example database design for an E-commerce Order System
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Sample Output: E-commerce Order System Database Design
|
|
2
|
+
|
|
3
|
+
## Entities
|
|
4
|
+
|
|
5
|
+
- **users** — customer accounts
|
|
6
|
+
- **products** — catalog items with pricing
|
|
7
|
+
- **orders** — purchase transactions
|
|
8
|
+
- **order_items** — line items within an order
|
|
9
|
+
- **addresses** — shipping/billing addresses
|
|
10
|
+
- **payments** — payment records linked to orders
|
|
11
|
+
|
|
12
|
+
## Schema
|
|
13
|
+
|
|
14
|
+
### users
|
|
15
|
+
```sql
|
|
16
|
+
CREATE TABLE users (
|
|
17
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
18
|
+
email TEXT NOT NULL UNIQUE,
|
|
19
|
+
name TEXT NOT NULL,
|
|
20
|
+
password_hash TEXT NOT NULL,
|
|
21
|
+
is_active BOOLEAN NOT NULL DEFAULT true,
|
|
22
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
23
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### products
|
|
28
|
+
```sql
|
|
29
|
+
CREATE TABLE products (
|
|
30
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
31
|
+
sku TEXT NOT NULL UNIQUE,
|
|
32
|
+
name TEXT NOT NULL,
|
|
33
|
+
description TEXT,
|
|
34
|
+
price_cents INTEGER NOT NULL CHECK (price_cents >= 0),
|
|
35
|
+
currency TEXT NOT NULL DEFAULT 'VND' CHECK (currency IN ('VND', 'USD')),
|
|
36
|
+
stock_quantity INTEGER NOT NULL DEFAULT 0 CHECK (stock_quantity >= 0),
|
|
37
|
+
is_active BOOLEAN NOT NULL DEFAULT true,
|
|
38
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
39
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### addresses
|
|
44
|
+
```sql
|
|
45
|
+
CREATE TABLE addresses (
|
|
46
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
47
|
+
user_id UUID NOT NULL REFERENCES users(id),
|
|
48
|
+
label TEXT NOT NULL DEFAULT 'home' CHECK (label IN ('home', 'work', 'other')),
|
|
49
|
+
full_name TEXT NOT NULL,
|
|
50
|
+
phone TEXT NOT NULL,
|
|
51
|
+
address_line1 TEXT NOT NULL,
|
|
52
|
+
address_line2 TEXT,
|
|
53
|
+
city TEXT NOT NULL,
|
|
54
|
+
district TEXT,
|
|
55
|
+
postal_code TEXT,
|
|
56
|
+
country TEXT NOT NULL DEFAULT 'VN',
|
|
57
|
+
is_default BOOLEAN NOT NULL DEFAULT false,
|
|
58
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
59
|
+
);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### orders
|
|
63
|
+
```sql
|
|
64
|
+
CREATE TABLE orders (
|
|
65
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
66
|
+
user_id UUID NOT NULL REFERENCES users(id),
|
|
67
|
+
shipping_address_id UUID NOT NULL REFERENCES addresses(id),
|
|
68
|
+
status TEXT NOT NULL DEFAULT 'pending'
|
|
69
|
+
CHECK (status IN ('pending', 'confirmed', 'processing', 'shipped', 'delivered', 'cancelled', 'refunded')),
|
|
70
|
+
subtotal_cents INTEGER NOT NULL CHECK (subtotal_cents >= 0),
|
|
71
|
+
shipping_cents INTEGER NOT NULL DEFAULT 0 CHECK (shipping_cents >= 0),
|
|
72
|
+
discount_cents INTEGER NOT NULL DEFAULT 0 CHECK (discount_cents >= 0),
|
|
73
|
+
total_cents INTEGER NOT NULL CHECK (total_cents >= 0),
|
|
74
|
+
currency TEXT NOT NULL DEFAULT 'VND',
|
|
75
|
+
notes TEXT,
|
|
76
|
+
ordered_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
77
|
+
shipped_at TIMESTAMPTZ,
|
|
78
|
+
delivered_at TIMESTAMPTZ,
|
|
79
|
+
cancelled_at TIMESTAMPTZ,
|
|
80
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
81
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
82
|
+
);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### order_items
|
|
86
|
+
```sql
|
|
87
|
+
CREATE TABLE order_items (
|
|
88
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
89
|
+
order_id UUID NOT NULL REFERENCES orders(id) ON DELETE CASCADE,
|
|
90
|
+
product_id UUID NOT NULL REFERENCES products(id),
|
|
91
|
+
product_name TEXT NOT NULL,
|
|
92
|
+
product_sku TEXT NOT NULL,
|
|
93
|
+
unit_price_cents INTEGER NOT NULL CHECK (unit_price_cents >= 0),
|
|
94
|
+
quantity INTEGER NOT NULL CHECK (quantity > 0),
|
|
95
|
+
line_total_cents INTEGER NOT NULL CHECK (line_total_cents >= 0),
|
|
96
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
97
|
+
);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Note**: `product_name`, `product_sku`, and `unit_price_cents` are denormalized intentionally — they capture the values at time of purchase. If the product price changes later, historical orders remain accurate.
|
|
101
|
+
|
|
102
|
+
### payments
|
|
103
|
+
```sql
|
|
104
|
+
CREATE TABLE payments (
|
|
105
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
106
|
+
order_id UUID NOT NULL REFERENCES orders(id),
|
|
107
|
+
method TEXT NOT NULL CHECK (method IN ('credit_card', 'bank_transfer', 'cod', 'momo', 'zalopay')),
|
|
108
|
+
status TEXT NOT NULL DEFAULT 'pending'
|
|
109
|
+
CHECK (status IN ('pending', 'processing', 'completed', 'failed', 'refunded')),
|
|
110
|
+
amount_cents INTEGER NOT NULL CHECK (amount_cents > 0),
|
|
111
|
+
currency TEXT NOT NULL DEFAULT 'VND',
|
|
112
|
+
provider_transaction_id TEXT,
|
|
113
|
+
paid_at TIMESTAMPTZ,
|
|
114
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
115
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
116
|
+
);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Indexes
|
|
120
|
+
|
|
121
|
+
```sql
|
|
122
|
+
-- users
|
|
123
|
+
CREATE INDEX idx_users_email ON users (email);
|
|
124
|
+
|
|
125
|
+
-- products
|
|
126
|
+
CREATE INDEX idx_products_sku ON products (sku);
|
|
127
|
+
CREATE INDEX idx_products_active ON products (is_active, name) WHERE is_active = true;
|
|
128
|
+
|
|
129
|
+
-- addresses
|
|
130
|
+
CREATE INDEX idx_addresses_user ON addresses (user_id);
|
|
131
|
+
|
|
132
|
+
-- orders (most queried table)
|
|
133
|
+
CREATE INDEX idx_orders_user ON orders (user_id, ordered_at DESC);
|
|
134
|
+
CREATE INDEX idx_orders_status ON orders (status) WHERE status NOT IN ('delivered', 'cancelled');
|
|
135
|
+
CREATE INDEX idx_orders_date ON orders (ordered_at DESC);
|
|
136
|
+
|
|
137
|
+
-- order_items
|
|
138
|
+
CREATE INDEX idx_order_items_order ON order_items (order_id);
|
|
139
|
+
CREATE INDEX idx_order_items_product ON order_items (product_id);
|
|
140
|
+
|
|
141
|
+
-- payments
|
|
142
|
+
CREATE INDEX idx_payments_order ON payments (order_id);
|
|
143
|
+
CREATE INDEX idx_payments_status ON payments (status) WHERE status = 'pending';
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Index Rationale
|
|
147
|
+
|
|
148
|
+
| Index | Supports Query |
|
|
149
|
+
|-------|---------------|
|
|
150
|
+
| `idx_orders_user` | "Show my orders" (user dashboard, sorted by date) |
|
|
151
|
+
| `idx_orders_status` | Admin: "Show pending orders to process" (partial, excludes completed) |
|
|
152
|
+
| `idx_products_active` | Product listing page (only active products) |
|
|
153
|
+
| `idx_payments_status` | Payment reconciliation job (find pending payments) |
|
|
154
|
+
|
|
155
|
+
## Common Queries
|
|
156
|
+
|
|
157
|
+
### User's Recent Orders with Items
|
|
158
|
+
```sql
|
|
159
|
+
SELECT o.id, o.status, o.total_cents, o.ordered_at,
|
|
160
|
+
json_agg(json_build_object('name', oi.product_name, 'qty', oi.quantity, 'total', oi.line_total_cents)) as items
|
|
161
|
+
FROM orders o
|
|
162
|
+
JOIN order_items oi ON oi.order_id = o.id
|
|
163
|
+
WHERE o.user_id = $1
|
|
164
|
+
GROUP BY o.id
|
|
165
|
+
ORDER BY o.ordered_at DESC
|
|
166
|
+
LIMIT 10;
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Daily Revenue Report
|
|
170
|
+
```sql
|
|
171
|
+
SELECT DATE(ordered_at) as order_date,
|
|
172
|
+
COUNT(*) as order_count,
|
|
173
|
+
SUM(total_cents) as revenue_cents
|
|
174
|
+
FROM orders
|
|
175
|
+
WHERE status IN ('confirmed', 'processing', 'shipped', 'delivered')
|
|
176
|
+
AND ordered_at >= $1 AND ordered_at < $2
|
|
177
|
+
GROUP BY DATE(ordered_at)
|
|
178
|
+
ORDER BY order_date;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Migration Plan
|
|
182
|
+
|
|
183
|
+
### Phase 1: Initial Schema (Sprint 1)
|
|
184
|
+
```
|
|
185
|
+
001_create_users.sql
|
|
186
|
+
002_create_products.sql
|
|
187
|
+
003_create_addresses.sql
|
|
188
|
+
004_create_orders.sql
|
|
189
|
+
005_create_order_items.sql
|
|
190
|
+
006_create_payments.sql
|
|
191
|
+
007_create_indexes.sql
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Phase 2: Enhancements (Sprint 2-3)
|
|
195
|
+
```
|
|
196
|
+
008_add_orders_tracking_number.sql -- ALTER TABLE orders ADD COLUMN tracking_number TEXT
|
|
197
|
+
009_add_products_categories.sql -- New categories table + product_categories junction
|
|
198
|
+
010_add_order_status_history.sql -- Audit table for status changes
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Zero-Downtime Migration Example
|
|
202
|
+
Adding `tracking_number` to orders:
|
|
203
|
+
1. `ALTER TABLE orders ADD COLUMN tracking_number TEXT;` (nullable, no lock on PostgreSQL 11+)
|
|
204
|
+
2. Deploy code that writes tracking_number when available
|
|
205
|
+
3. No backfill needed (existing orders don't have tracking numbers)
|
|
206
|
+
4. Add index when needed: `CREATE INDEX CONCURRENTLY idx_orders_tracking ON orders (tracking_number) WHERE tracking_number IS NOT NULL;`
|
|
207
|
+
|
|
208
|
+
### Backup Strategy
|
|
209
|
+
- **Full backup**: Daily at 02:00 UTC via `pg_dump`
|
|
210
|
+
- **WAL archiving**: Continuous to S3 for point-in-time recovery
|
|
211
|
+
- **Retention**: 30 days of daily backups, 7 days of WAL
|
|
212
|
+
- **Recovery test**: Monthly restore to staging environment
|