izanagi-ai 2.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.
Files changed (195) hide show
  1. package/AGENTS.md +53 -0
  2. package/CHANGELOG.md +198 -0
  3. package/LICENSE +21 -0
  4. package/README.md +96 -0
  5. package/ROADMAP.md +131 -0
  6. package/RULES.md +202 -0
  7. package/SYSTEM.md +201 -0
  8. package/agents/INDEX.md +40 -0
  9. package/agents/architect-agent.json +15 -0
  10. package/agents/bug-hunter-agent.json +14 -0
  11. package/agents/database-agent.json +14 -0
  12. package/agents/devops-agent.json +15 -0
  13. package/agents/docs-agent.json +15 -0
  14. package/agents/pm-agent.json +14 -0
  15. package/agents/professor-agent.json +15 -0
  16. package/agents/security-agent.json +14 -0
  17. package/agents/senior-engineer-agent.json +16 -0
  18. package/agents/techlead-agent.json +15 -0
  19. package/architecture/clean-architecture.md +98 -0
  20. package/architecture/cqrs-specialist.md +102 -0
  21. package/architecture/ddd-specialist.md +97 -0
  22. package/architecture/event-driven-architect.md +79 -0
  23. package/architecture/hexagonal-architecture.md +96 -0
  24. package/architecture/microservices-expert.md +83 -0
  25. package/architecture/monolith-expert.md +67 -0
  26. package/architecture/repository-pattern.md +73 -0
  27. package/architecture/unit-of-work.md +92 -0
  28. package/backend/README.md +29 -0
  29. package/bin/nexus.js +8 -0
  30. package/core/compression-engine.md +194 -0
  31. package/core/context-engine.md +239 -0
  32. package/core/decision-engine.md +377 -0
  33. package/core/evolution-engine.md +169 -0
  34. package/core/planning-engine.md +201 -0
  35. package/core/quality-gates.md +233 -0
  36. package/core/reflection-engine.md +182 -0
  37. package/core/skill-resolver.json +169 -0
  38. package/core/token-manager.md +152 -0
  39. package/database/database-engineer.md +244 -0
  40. package/database/mysql-specialist.md +61 -0
  41. package/database/postgresql-specialist.md +70 -0
  42. package/database/redis-specialist.md +73 -0
  43. package/database/sql-optimizer.md +95 -0
  44. package/database/sqlserver-specialist.md +69 -0
  45. package/devops/ci-cd-specialist.md +101 -0
  46. package/devops/devops-engineer.md +358 -0
  47. package/devops/docker-expert.md +105 -0
  48. package/devops/git-expert.md +76 -0
  49. package/devops/git-flow-specialist.md +71 -0
  50. package/devops/kubernetes-specialist.md +84 -0
  51. package/devops/linux-specialist.md +82 -0
  52. package/devops/windows-specialist.md +43 -0
  53. package/dist/cli/commands/compile.d.ts +2 -0
  54. package/dist/cli/commands/compile.d.ts.map +1 -0
  55. package/dist/cli/commands/compile.js +44 -0
  56. package/dist/cli/commands/compile.js.map +1 -0
  57. package/dist/cli/commands/doctor.d.ts +2 -0
  58. package/dist/cli/commands/doctor.d.ts.map +1 -0
  59. package/dist/cli/commands/doctor.js +88 -0
  60. package/dist/cli/commands/doctor.js.map +1 -0
  61. package/dist/cli/commands/init.d.ts +2 -0
  62. package/dist/cli/commands/init.d.ts.map +1 -0
  63. package/dist/cli/commands/init.js +26 -0
  64. package/dist/cli/commands/init.js.map +1 -0
  65. package/dist/cli/commands/list.d.ts +2 -0
  66. package/dist/cli/commands/list.d.ts.map +1 -0
  67. package/dist/cli/commands/list.js +50 -0
  68. package/dist/cli/commands/list.js.map +1 -0
  69. package/dist/cli/commands/run.d.ts +2 -0
  70. package/dist/cli/commands/run.d.ts.map +1 -0
  71. package/dist/cli/commands/run.js +49 -0
  72. package/dist/cli/commands/run.js.map +1 -0
  73. package/dist/cli/index.d.ts +2 -0
  74. package/dist/cli/index.d.ts.map +1 -0
  75. package/dist/cli/index.js +72 -0
  76. package/dist/cli/index.js.map +1 -0
  77. package/dist/index.d.ts +3 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +3 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/installer.d.ts +5 -0
  82. package/dist/installer.d.ts.map +1 -0
  83. package/dist/installer.js +86 -0
  84. package/dist/installer.js.map +1 -0
  85. package/dist/postinstall.d.ts +2 -0
  86. package/dist/postinstall.d.ts.map +1 -0
  87. package/dist/postinstall.js +8 -0
  88. package/dist/postinstall.js.map +1 -0
  89. package/frontend/README.md +19 -0
  90. package/memory/context-recovery.md +49 -0
  91. package/memory/conversation-summarizer.md +65 -0
  92. package/memory/long-term-project-memory.md +58 -0
  93. package/memory/memory-manager.md +299 -0
  94. package/memory/session-compression.md +182 -0
  95. package/memory/smart-recall.md +37 -0
  96. package/optimization/compact-example.md +87 -0
  97. package/optimization/cost-optimizer.md +53 -0
  98. package/optimization/prompt-optimizer.md +194 -0
  99. package/optimization/token-audit.md +177 -0
  100. package/optimization/token-reducer.md +202 -0
  101. package/package.json +67 -0
  102. package/security/owasp-auditor.md +249 -0
  103. package/security/pentest-reviewer.md +109 -0
  104. package/security/security-engineer.md +238 -0
  105. package/skills/INDEX.md +434 -0
  106. package/skills/accessibility-reviewer.md +63 -0
  107. package/skills/agentic-coding.md +56 -0
  108. package/skills/ai-agent/SKILL.md +107 -0
  109. package/skills/ai-agent-dev/SKILL.md +117 -0
  110. package/skills/alternative-solution-generator.md +72 -0
  111. package/skills/architecture-patterns/SKILL.md +113 -0
  112. package/skills/breaking-change-detector.md +84 -0
  113. package/skills/bug-hunter.md +234 -0
  114. package/skills/bug-prevention.md +75 -0
  115. package/skills/chaos-engineering/SKILL.md +108 -0
  116. package/skills/clean-code-validator.md +218 -0
  117. package/skills/cloud-architect/SKILL.md +78 -0
  118. package/skills/cloud-infra/SKILL.md +99 -0
  119. package/skills/code-auditor.md +24 -0
  120. package/skills/complexity-analyzer.md +102 -0
  121. package/skills/confidence-estimator.md +53 -0
  122. package/skills/continuous-improvement.md +46 -0
  123. package/skills/continuous-learning-engine.md +51 -0
  124. package/skills/cto-advisor.md +66 -0
  125. package/skills/data-engineer/SKILL.md +76 -0
  126. package/skills/data-engineering/SKILL.md +82 -0
  127. package/skills/debug-specialist.md +215 -0
  128. package/skills/dependency-analyzer.md +78 -0
  129. package/skills/design-pattern-advisor.md +78 -0
  130. package/skills/documentation-writer.md +66 -0
  131. package/skills/dry-kiss-yagni-validator.md +114 -0
  132. package/skills/economia-tokens/SKILL.md +40 -0
  133. package/skills/er-diagram-builder.md +85 -0
  134. package/skills/feature-flags/SKILL.md +95 -0
  135. package/skills/frontend/SKILL.md +327 -0
  136. package/skills/frontend-dev/SKILL.md +178 -0
  137. package/skills/graphql/SKILL.md +104 -0
  138. package/skills/hallucination-detection.md +49 -0
  139. package/skills/handoff-sessao/SKILL.md +32 -0
  140. package/skills/i18n-l10n/SKILL.md +103 -0
  141. package/skills/iac-terraform/SKILL.md +98 -0
  142. package/skills/legacy-migration/SKILL.md +91 -0
  143. package/skills/logging-expert.md +78 -0
  144. package/skills/mcp-server-dev.md +33 -0
  145. package/skills/memoria-projeto/SKILL.md +49 -0
  146. package/skills/mobile-dev/SKILL.md +82 -0
  147. package/skills/mobile-engineer/SKILL.md +74 -0
  148. package/skills/monitoring-specialist.md +59 -0
  149. package/skills/observability-expert.md +60 -0
  150. package/skills/performance-optimizer.md +239 -0
  151. package/skills/principal-engineer.md +55 -0
  152. package/skills/privacy-engineer/SKILL.md +79 -0
  153. package/skills/professor-modo/SKILL.md +33 -0
  154. package/skills/project-manager.md +74 -0
  155. package/skills/prompt-engineering.md +27 -0
  156. package/skills/qa/SKILL.md +231 -0
  157. package/skills/qa-engineer/SKILL.md +222 -0
  158. package/skills/readme-generator.md +42 -0
  159. package/skills/refactoring-specialist.md +250 -0
  160. package/skills/release-planner.md +70 -0
  161. package/skills/requirement-analyzer.md +65 -0
  162. package/skills/risk-analyzer.md +73 -0
  163. package/skills/root-cause-analyzer.md +210 -0
  164. package/skills/scalability-expert.md +73 -0
  165. package/skills/security-privacy/SKILL.md +98 -0
  166. package/skills/self-correction.md +54 -0
  167. package/skills/self-critique.md +42 -0
  168. package/skills/senior-code-reviewer.md +193 -0
  169. package/skills/sequence-diagram-builder.md +56 -0
  170. package/skills/serverless-edge/SKILL.md +103 -0
  171. package/skills/software-architect.md +356 -0
  172. package/skills/solid-validator.md +332 -0
  173. package/skills/sre-reliability/SKILL.md +115 -0
  174. package/skills/staff-engineer.md +61 -0
  175. package/skills/task-planner.md +61 -0
  176. package/skills/tech-lead.md +59 -0
  177. package/skills/technical-debt-analyzer.md +81 -0
  178. package/skills/technical-writer.md +39 -0
  179. package/skills/tradeoff-analyzer.md +79 -0
  180. package/skills/uml-generator.md +72 -0
  181. package/skills/ux-reviewer.md +61 -0
  182. package/skills/wasm/SKILL.md +133 -0
  183. package/skills/web-perf-engineer/SKILL.md +75 -0
  184. package/skills/web-perf-seo/SKILL.md +111 -0
  185. package/skills/websocket-realtime/SKILL.md +107 -0
  186. package/teaching/adaptive-teaching.md +37 -0
  187. package/teaching/code-explainer.md +172 -0
  188. package/teaching/interactive-teaching.md +41 -0
  189. package/teaching/learning-tracker.md +63 -0
  190. package/teaching/mentor-mode.md +200 -0
  191. package/teaching/professor-mode.md +222 -0
  192. package/testing/e2e-test-engineer.md +68 -0
  193. package/testing/integration-test-engineer.md +74 -0
  194. package/testing/mocking-specialist.md +78 -0
  195. package/testing/unit-test-engineer.md +209 -0
@@ -0,0 +1,169 @@
1
+ {
2
+ "resolver": "Mapeia short IDs para caminhos reais de skills. Usado nos agentes para reduzir tokens.",
3
+
4
+ "aliases": {
5
+ "architect": "skills/software-architect",
6
+ "clean-arch": "architecture/clean-architecture",
7
+ "hexagonal": "architecture/hexagonal-architecture",
8
+ "cqrs": "architecture/cqrs-specialist",
9
+ "event-driven": "architecture/event-driven-architect",
10
+ "ddd": "architecture/ddd-specialist",
11
+ "microservices": "architecture/microservices-expert",
12
+ "monolith": "architecture/monolith-expert",
13
+ "repository": "architecture/repository-pattern",
14
+ "uow": "architecture/unit-of-work",
15
+
16
+ "backend": "coding/backend-engineer",
17
+ "frontend": "coding/frontend-engineer",
18
+ "api": "coding/api-designer",
19
+ "laravel": "coding/laravel-specialist",
20
+ "php": "coding/php-specialist",
21
+ "js": "coding/javascript-specialist",
22
+ "ts": "coding/typescript-specialist",
23
+ "python": "coding/python-specialist",
24
+ "react": "coding/react-specialist",
25
+ "vue": "coding/vue-specialist",
26
+ "node": "coding/nodejs-specialist",
27
+ "java": "coding/java-specialist",
28
+ "csharp": "coding/csharp-specialist",
29
+
30
+ "security": "security/security-engineer",
31
+ "owasp": "security/owasp-auditor",
32
+ "pentest": "security/pentest-reviewer",
33
+
34
+ "reviewer": "skills/senior-code-reviewer",
35
+ "clean-code": "skills/clean-code-validator",
36
+ "solid": "skills/solid-validator",
37
+ "dry-kiss-yagni": "skills/dry-kiss-yagni-validator",
38
+ "complexity": "skills/complexity-analyzer",
39
+ "bug-prevention": "skills/bug-prevention",
40
+ "patterns": "skills/design-pattern-advisor",
41
+ "refactor": "skills/refactoring-specialist",
42
+ "tech-debt": "skills/technical-debt-analyzer",
43
+ "breaking-change": "skills/breaking-change-detector",
44
+ "perf": "skills/performance-optimizer",
45
+ "scalability": "skills/scalability-expert",
46
+
47
+ "unit-test": "testing/unit-test-engineer",
48
+ "integration-test": "testing/integration-test-engineer",
49
+ "e2e-test": "testing/e2e-test-engineer",
50
+ "mock": "testing/mocking-specialist",
51
+
52
+ "db": "database/database-engineer",
53
+ "sql": "database/sql-optimizer",
54
+ "postgres": "database/postgresql-specialist",
55
+ "mysql": "database/mysql-specialist",
56
+ "sqlserver": "database/sqlserver-specialist",
57
+ "redis": "database/redis-specialist",
58
+
59
+ "devops": "devops/devops-engineer",
60
+ "docker": "devops/docker-expert",
61
+ "k8s": "devops/kubernetes-specialist",
62
+ "git": "devops/git-expert",
63
+ "gitflow": "devops/git-flow-specialist",
64
+ "cicd": "devops/ci-cd-specialist",
65
+ "linux": "devops/linux-specialist",
66
+ "windows": "devops/windows-specialist",
67
+
68
+ "debug": "skills/debug-specialist",
69
+ "bug": "skills/bug-hunter",
70
+ "root-cause": "skills/root-cause-analyzer",
71
+
72
+ "professor": "teaching/professor-mode",
73
+ "mentor": "teaching/mentor-mode",
74
+ "explainer": "teaching/code-explainer",
75
+ "interactive": "teaching/interactive-teaching",
76
+ "adaptive": "teaching/adaptive-teaching",
77
+ "tracker": "teaching/learning-tracker",
78
+
79
+ "memory": "memory/memory-manager",
80
+ "session-compress": "memory/session-compression",
81
+ "summarizer": "memory/conversation-summarizer",
82
+ "recovery": "memory/context-recovery",
83
+ "recall": "memory/smart-recall",
84
+ "project-memory": "memory/long-term-project-memory",
85
+
86
+ "token-reduce": "optimization/token-reducer",
87
+ "prompt": "optimization/prompt-optimizer",
88
+ "cost": "optimization/cost-optimizer",
89
+
90
+ "requirements": "skills/requirement-analyzer",
91
+ "risk": "skills/risk-analyzer",
92
+ "deps": "skills/dependency-analyzer",
93
+ "tradeoff": "skills/tradeoff-analyzer",
94
+ "alternatives": "skills/alternative-solution-generator",
95
+
96
+ "docs": "skills/documentation-writer",
97
+ "tech-writer": "skills/technical-writer",
98
+ "readme": "skills/readme-generator",
99
+ "uml": "skills/uml-generator",
100
+ "sequence": "skills/sequence-diagram-builder",
101
+ "er": "skills/er-diagram-builder",
102
+
103
+ "pm": "skills/project-manager",
104
+ "planner": "skills/task-planner",
105
+ "release": "skills/release-planner",
106
+
107
+ "ux": "skills/ux-reviewer",
108
+ "a11y": "skills/accessibility-reviewer",
109
+ "logging": "skills/logging-expert",
110
+ "observability": "skills/observability-expert",
111
+ "monitoring": "skills/monitoring-specialist",
112
+
113
+ "self-fix": "skills/self-correction",
114
+ "self-critique": "skills/self-critique",
115
+ "improvement": "skills/continuous-improvement",
116
+ "hallucination": "skills/hallucination-detection",
117
+ "confidence": "skills/confidence-estimator",
118
+ "learning": "skills/continuous-learning-engine",
119
+
120
+ "principal": "skills/principal-engineer",
121
+ "staff": "skills/staff-engineer",
122
+ "techlead": "skills/tech-lead",
123
+ "cto": "skills/cto-advisor",
124
+ "quality-gates": "core/quality-gates",
125
+ "planning-engine": "core/planning-engine",
126
+ "context-engine": "core/context-engine",
127
+ "token-manager": "core/token-manager",
128
+ "compression-engine": "core/compression-engine",
129
+ "reflection-engine": "core/reflection-engine",
130
+ "evolution-engine": "core/evolution-engine",
131
+ "decision-engine": "core/decision-engine",
132
+
133
+ "ai-agent": "skills/ai-agent/SKILL",
134
+ "ai-agent-dev": "skills/ai-agent-dev/SKILL",
135
+ "architecture-patterns": "skills/architecture-patterns/SKILL",
136
+ "chaos-engineering": "skills/chaos-engineering/SKILL",
137
+ "cloud-architect": "skills/cloud-architect/SKILL",
138
+ "cloud-infra": "skills/cloud-infra/SKILL",
139
+ "data-engineer": "skills/data-engineer/SKILL",
140
+ "data-engineering": "skills/data-engineering/SKILL",
141
+ "economia-tokens": "skills/economia-tokens/SKILL",
142
+ "feature-flags": "skills/feature-flags/SKILL",
143
+ "frontend-tokens": "skills/frontend/SKILL",
144
+ "frontend-dev": "skills/frontend-dev/SKILL",
145
+ "graphql": "skills/graphql/SKILL",
146
+ "handoff-sessao": "skills/handoff-sessao/SKILL",
147
+ "i18n-l10n": "skills/i18n-l10n/SKILL",
148
+ "iac-terraform": "skills/iac-terraform/SKILL",
149
+ "legacy-migration": "skills/legacy-migration/SKILL",
150
+ "memoria-projeto": "skills/memoria-projeto/SKILL",
151
+ "mobile-dev": "skills/mobile-dev/SKILL",
152
+ "mobile-engineer": "skills/mobile-engineer/SKILL",
153
+ "privacy-engineer": "skills/privacy-engineer/SKILL",
154
+ "professor-modo": "skills/professor-modo/SKILL",
155
+ "qa-checklist": "skills/qa/SKILL",
156
+ "qa-engineer": "skills/qa-engineer/SKILL",
157
+ "security-privacy": "skills/security-privacy/SKILL",
158
+ "serverless-edge": "skills/serverless-edge/SKILL",
159
+ "sre-reliability": "skills/sre-reliability/SKILL",
160
+ "wasm": "skills/wasm/SKILL",
161
+ "web-perf-engineer": "skills/web-perf-engineer/SKILL",
162
+ "web-perf-seo": "skills/web-perf-seo/SKILL",
163
+ "websocket-realtime": "skills/websocket-realtime/SKILL",
164
+ "agentic-coding": "skills/agentic-coding",
165
+ "mcp": "skills/mcp-server-dev",
166
+ "prompt-eng": "skills/prompt-engineering",
167
+ "code-auditor": "skills/code-auditor"
168
+ }
169
+ }
@@ -0,0 +1,152 @@
1
+ # Core: Token Manager
2
+
3
+ > Version 1.0.0
4
+ > Priority: Critical
5
+ > Dependencies: Context Engine, Compression Engine
6
+ > Compatibility: ">=1.0.0"
7
+
8
+ ---
9
+
10
+ ## Identity
11
+
12
+ The Token Manager monitors, budgets, and optimizes every token spent across the entire system. It enforces per-response limits, triggers compression when thresholds are breached, and logs token usage for cost analysis.
13
+
14
+ ---
15
+
16
+ ## Goals
17
+
18
+ - Never exceed the hard token limit per response.
19
+ - Trigger compression proactively at 70% usage.
20
+ - Provide real-time token accounting per skill.
21
+ - Log token usage for optimization and cost tracking.
22
+
23
+ ---
24
+
25
+ ## Budget Tiers
26
+
27
+ | Tier | Limit | When Applied |
28
+ |------|-------|-------------|
29
+ | Soft | 2048 tokens | Normal response |
30
+ | Hard | 4096 tokens | Complex response |
31
+ | Context | 8192 tokens | Full context window |
32
+ | Emergency | 512 tokens | Only for error recovery |
33
+
34
+ ---
35
+
36
+ ## Monitor
37
+
38
+ ```
39
+ ┌─────────────────────────────────────────────────┐
40
+ │ TOKEN MONITOR │
41
+ │ │
42
+ │ Current Usage: 1,234 / 2,048 (60%) │
43
+ │ Budget Remaining: 814 tokens │
44
+ │ Status: ✅ Normal │
45
+ │ │
46
+ │ ┌──────────────┬──────────┬──────────┐ │
47
+ │ │ Skill │ Allocated│ Used │ │
48
+ │ ├──────────────┼──────────┼──────────┤ │
49
+ │ │ Architect │ 400 │ 380 │ │
50
+ │ │ Security │ 300 │ 290 │ │
51
+ │ │ Backend │ 800 │ 564 │ │
52
+ │ └──────────────┴──────────┴──────────┘ │
53
+ └─────────────────────────────────────────────────┘
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Triggers
59
+
60
+ | Condition | Action |
61
+ |-----------|--------|
62
+ | Usage > 70% of soft limit | Activate Compression Engine |
63
+ | Usage > 90% of soft limit | Force compression, reduce detail level |
64
+ | Usage > 100% of soft limit | Drop lowest priority section |
65
+ | Usage > 100% of hard limit | Emergency — truncate to essentials, notify Reflection |
66
+
67
+ ---
68
+
69
+ ## Allocation Algorithm
70
+
71
+ ```
72
+ function allocate(skills, total_budget):
73
+ sum_priority = sum(skills.priority for skills)
74
+
75
+ for skill in skills:
76
+ weight = skill.priority / sum_priority
77
+ skill.budget = floor(total_budget * weight)
78
+
79
+ return skills
80
+ ```
81
+
82
+ Priority weights: critical = 0.4, high = 0.3, medium = 0.2, low = 0.1
83
+
84
+ ---
85
+
86
+ ## Accounting
87
+
88
+ Every response includes a token usage footer when debug mode is active:
89
+
90
+ ```
91
+ ---
92
+ Token Usage: 1,234
93
+ Budget: 2,048
94
+ Remaining: 814
95
+ Compression: none
96
+ Skills: Architect(380), Security(290), Backend(564)
97
+ ---
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Savings Techniques
103
+
104
+ | Technique | Tokens Saved | Cost |
105
+ |-----------|-------------|------|
106
+ | Drop filler words | 5-10% | Zero |
107
+ | Use abbreviations | 3-5% | Low (clarity risk) |
108
+ | Summarize examples | 10-20% | Low |
109
+ | Remove code comments | 15-25% | Medium (context loss) |
110
+ | Use compact format | 20-30% | Low |
111
+ | Skip redundant validation | 5-10% | Medium |
112
+
113
+ ---
114
+
115
+ ## Rules
116
+
117
+ ### Always
118
+
119
+ - ✅ Track every token in every response.
120
+ - ✅ Trigger compression proactively at 70%.
121
+ - ✅ Log token usage per skill.
122
+ - ✅ Respect hard limit unconditionally.
123
+
124
+ ### Never
125
+
126
+ - ❌ Exceed hard limit.
127
+ - ❌ Skip compression when triggered.
128
+ - ❌ Compress security-critical information.
129
+
130
+ ---
131
+
132
+ ## Metrics
133
+
134
+ | Metric | Target | How to Measure |
135
+ |--------|--------|---------------|
136
+ | Soft limit compliance | 100% | Responses within soft limit |
137
+ | Hard limit breaches | 0 | Responses exceeding hard limit |
138
+ | Compression trigger rate | ≥ 90% | Triggers vs actual breaches |
139
+ | Average tokens per response | < 1500 | Running average |
140
+
141
+ ---
142
+
143
+ ## Changelog
144
+
145
+ ### 1.0.0 (2026-07-17)
146
+
147
+ - Initial release
148
+ - 4-tier budget system
149
+ - Priority-based allocation algorithm
150
+ - Real-time monitoring with status tracking
151
+ - Compression triggers at 70% and 90%
152
+ - Emergency truncation at hard limit
@@ -0,0 +1,244 @@
1
+ # Database: Database Engineer
2
+
3
+ > Version 1.0.0
4
+ > Priority: High
5
+ > Dependencies: Software Architect, SQL Optimizer
6
+ > Compatibility: ">=1.0.0"
7
+
8
+ ---
9
+
10
+ ## Identity
11
+
12
+ The Database Engineer designs, implements, and optimizes database schemas. It ensures data integrity through constraints, enforces relationships, optimizes queries with proper indexing, and plans for growth with partitioning and sharding strategies.
13
+
14
+ ---
15
+
16
+ ## Goals
17
+
18
+ - Design normalized schemas (3NF minimum).
19
+ - Enforce data integrity with constraints (PK, FK, CHECK, UNIQUE).
20
+ - Optimize queries with proper indexing strategies.
21
+ - Plan migrations that are safe and reversible.
22
+ - Document schema with ER diagrams.
23
+
24
+ ---
25
+
26
+ ## Triggers
27
+
28
+ | Condition | Action |
29
+ |-----------|--------|
30
+ | `task == "database"` or `task == "schema"` | Full database design |
31
+ | `task == "migration"` | Create migration |
32
+ | After architecture approved | Design data model |
33
+ | Performance issue | Query optimization |
34
+
35
+ ---
36
+
37
+ ## Workflow
38
+
39
+ ```
40
+ 1. Analyze domain entities
41
+ ↓
42
+ 2. Design entity-relationship model
43
+ ↓
44
+ 3. Normalize to 3NF (or denormalize intentionally)
45
+ ↓
46
+ 4. Choose data types
47
+ ↓
48
+ 5. Define constraints (PK, FK, UNIQUE, CHECK)
49
+ ↓
50
+ 6. Design index strategy
51
+ ↓
52
+ 7. Create migration files
53
+ ↓
54
+ 8. Create seeders (if needed)
55
+ ↓
56
+ 9. Generate ER diagram documentation
57
+ ↓
58
+ 10. Validate with sample queries
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Naming Conventions
64
+
65
+ ```yaml
66
+ tables: snake_case, plural
67
+ - users, posts, comments, post_tags
68
+
69
+ columns: snake_case, singular
70
+ - id, name, email, created_at, post_id
71
+
72
+ primary_key: "id" (auto-increment or UUID)
73
+ foreign_key: "{singular_table}_id"
74
+ - post_id, user_id, comment_id
75
+
76
+ indexes: "{table}_{column}_index"
77
+ - posts_user_id_index, comments_post_id_index
78
+
79
+ timestamps: created_at, updated_at
80
+ soft_deletes: deleted_at
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Data Type Selection
86
+
87
+ ```yaml
88
+ integers:
89
+ id: bigIncrements or uuid
90
+ counters: integer (smallint if < 32768)
91
+ foreign_keys: unsignedBigInteger or uuid
92
+
93
+ strings:
94
+ short: string(100)
95
+ medium: string(255)
96
+ long: text
97
+ very_long: longText
98
+
99
+ booleans: boolean (not tinyint)
100
+
101
+ temporal:
102
+ dates: date (not datetime if time isn't needed)
103
+ timestamps: datetime or timestampTz
104
+ duration: integer (seconds)
105
+
106
+ financial: decimal(10, 2) — never float
107
+
108
+ binary: uuid (not string)
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Migration Template (Laravel)
114
+
115
+ ```php
116
+ Schema::create('posts', function (Blueprint $table) {
117
+ $table->id();
118
+ $table->foreignId('user_id')->constrained()->cascadeOnDelete();
119
+ $table->string('title', 200);
120
+ $table->string('slug', 255)->unique();
121
+ $table->text('content');
122
+ $table->string('status', 20)->default('draft'); // draft, published, archived
123
+ $table->timestampTz('published_at')->nullable();
124
+ $table->timestamps();
125
+ $table->softDeletes();
126
+
127
+ $table->index('status');
128
+ $table->index('published_at');
129
+ });
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Index Strategy
135
+
136
+ ```yaml
137
+ primary_key: always indexed (PK)
138
+ unique: for columns with unique constraint
139
+ foreign_key: always index FK columns
140
+ where: index columns used in WHERE clauses
141
+ order: index columns used in ORDER BY
142
+ join: index columns used in JOIN conditions
143
+
144
+ composite_indexes:
145
+ - table: posts
146
+ columns: [status, published_at]
147
+ reason: "WHERE status = 'published' ORDER BY published_at DESC"
148
+
149
+ - table: comments
150
+ columns: [post_id, created_at]
151
+ reason: "WHERE post_id = ? ORDER BY created_at DESC"
152
+
153
+ partial_indexes:
154
+ - table: posts
155
+ columns: [published_at]
156
+ condition: "WHERE status = 'published'"
157
+
158
+ avoid:
159
+ - indexing boolean columns (low cardinality)
160
+ - indexing text/blob columns
161
+ - over-indexing (write performance impact)
162
+ ```
163
+
164
+ ---
165
+
166
+ ## Normalization Levels
167
+
168
+ | Level | Rules | When to Break |
169
+ |-------|-------|--------------|
170
+ | **1NF** | Atomic columns, unique rows | Never skip |
171
+ | **2NF** | 1NF + full PK dependency | Never skip |
172
+ | **3NF** | 2NF + transitive dependency removed | Default target |
173
+ | **Denormalize** | Intentionally add redundancy | For read performance (reports, analytics) |
174
+
175
+ ---
176
+
177
+ ## Migration Safety
178
+
179
+ ```yaml
180
+ safe:
181
+ - Adding a new table
182
+ - Adding a nullable column
183
+ - Adding an index (concurrently in production)
184
+ - Adding a default value to an existing column
185
+
186
+ requires_care:
187
+ - Adding a NOT NULL column (need default first)
188
+ - Renaming a column (2-step: add + drop)
189
+ - Changing column type (check data compatibility)
190
+ - Adding a foreign key (lock risk on large tables)
191
+
192
+ unsafe:
193
+ - Dropping a column (data loss)
194
+ - Dropping a table (data loss)
195
+ - Changing a column to NOT NULL without default
196
+ - Running on production without review
197
+ ```
198
+
199
+ ---
200
+
201
+ ## Rules
202
+
203
+ ### Always
204
+
205
+ - ✅ Design schema before writing code.
206
+ - ✅ Use migrations for all schema changes.
207
+ - ✅ Add indexes for FK, WHERE, ORDER BY, and JOIN.
208
+ - ✅ Normalize to 3NF by default.
209
+ - ✅ Make migrations reversible (up + down).
210
+ - ✅ Document relationships and constraints.
211
+
212
+ ### Never
213
+
214
+ - ❌ Use `float` for currency (use `decimal`).
215
+ - ❌ Skip indexes on foreign keys.
216
+ - ❌ Run unsafe migrations on production without review.
217
+ - ❌ Store serialized data in columns (use JSON or related tables).
218
+ - ❌ Use `*` in SELECT (always specify columns).
219
+ - ❌ Forget soft deletes where appropriate.
220
+
221
+ ---
222
+
223
+ ## Metrics
224
+
225
+ | Metric | Target | How to Measure |
226
+ |--------|--------|---------------|
227
+ | Normalization level | ≥ 3NF | Schema review |
228
+ | Index coverage | 100% of FK + WHERE | Query analysis |
229
+ | Migration reversibility | 100% | Check down() methods exist |
230
+ | Query performance | < 100ms p95 | Query log analysis |
231
+
232
+ ---
233
+
234
+ ## Changelog
235
+
236
+ ### 1.0.0 (2026-07-17)
237
+
238
+ - Initial release
239
+ - Naming conventions for tables, columns, indexes
240
+ - Data type selection guide
241
+ - Migration template with comments (Laravel)
242
+ - Index strategy (PK, FK, WHERE, ORDER, JOIN, composite, partial)
243
+ - Normalization guide with break conditions
244
+ - Migration safety levels (safe, careful, unsafe)
@@ -0,0 +1,61 @@
1
+ # Database: MySQL Specialist
2
+
3
+ > Version 1.0.0 | Priority: Medium
4
+ > Dependencies: Database Engineer, SQL Optimizer
5
+ > Compatibility: ">=1.0.0"
6
+
7
+ ---
8
+
9
+ ## Identity
10
+
11
+ MySQL Specialist optimizes for MySQL 8+ specific features: InnoDB, full-text indexes, window functions, CTEs, JSON, and EXPLAIN FORMAT=JSON.
12
+
13
+ ---
14
+
15
+ ## MySQL-Specific Features
16
+
17
+ ```yaml
18
+ engine: InnoDB only (never MyISAM)
19
+ charset: utf8mb4 (full Unicode, including emoji)
20
+ collation: utf8mb4_unicode_ci
21
+ json: native JSON type with virtual columns
22
+ fulltext: FULLTEXT index on CHAR/VARCHAR/TEXT
23
+ window: ROW_NUMBER(), RANK() (MySQL 8+)
24
+ CTE: WITH ... AS (MySQL 8+)
25
+ spatial: SPATIAL index for geometry
26
+ ```
27
+
28
+ ---
29
+
30
+ ## EXPLAIN Analysis
31
+
32
+ ```sql
33
+ EXPLAIN FORMAT=JSON
34
+ SELECT * FROM posts WHERE status = 'published'\G
35
+
36
+ -- Look for:
37
+ -- type: ALL (full scan) → needs index
38
+ -- type: index (full index scan) → better, but still slow
39
+ -- type: ref/range → good, index used
40
+ -- type: const → best (PK/UNIQUE lookup)
41
+ -- Extra: Using filesort → needs index on ORDER BY
42
+ -- Extra: Using temporary → needs index on GROUP BY
43
+ ```
44
+
45
+ ---
46
+
47
+ ## InnoDB Tuning
48
+
49
+ ```ini
50
+ innodb_buffer_pool_size = 70% of RAM
51
+ innodb_log_file_size = 1GB
52
+ innodb_flush_log_at_trx_commit = 2 (balance)
53
+ innodb_file_per_table = 1
54
+ innodb_autoinc_lock_mode = 2
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Changelog
60
+
61
+ ### 1.0.0 — Initial release. InnoDB, EXPLAIN FORMAT=JSON, tuning.
@@ -0,0 +1,70 @@
1
+ # Database: PostgreSQL Specialist
2
+
3
+ > Version 1.0.0 | Priority: High
4
+ > Dependencies: Database Engineer, SQL Optimizer
5
+ > Compatibility: ">=1.0.0"
6
+
7
+ ---
8
+
9
+ ## Identity
10
+
11
+ PostgreSQL Specialist leverages PG-specific features: JSONB, full-text search (tsvector), partial indexes, CTEs, window functions, partitioning, and extensions.
12
+
13
+ ---
14
+
15
+ ## PG-Specific Features
16
+
17
+ ```yaml
18
+ jsonb: use for flexible schemas, with GIN index for @> queries
19
+ fulltext: tsvector/tsquery with GIN index
20
+ partitioning: LIST/RANGE/HASH for large tables
21
+ CTE: WITH ... AS for recursive queries, materialized
22
+ window: ROW_NUMBER(), RANK(), LAG(), LEAD()
23
+ partial_index: index with WHERE clause
24
+ exclusion: for overlap/adjacency constraints
25
+ extensions: pgcrypto, uuid-ossp, postgis, pg_stat_statements
26
+ ```
27
+
28
+ ---
29
+
30
+ ## JSONB Patterns
31
+
32
+ ```sql
33
+ -- Table
34
+ CREATE TABLE events (
35
+ id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
36
+ payload JSONB NOT NULL,
37
+ created_at TIMESTAMPTZ DEFAULT NOW()
38
+ );
39
+
40
+ -- Index
41
+ CREATE INDEX idx_events_payload ON events USING GIN (payload jsonb_path_ops);
42
+
43
+ -- Queries
44
+ SELECT * FROM events WHERE payload @> '{"type": "user_created"}';
45
+ SELECT * FROM events WHERE payload->>'email' LIKE '%@example.com';
46
+ UPDATE events SET payload = jsonb_set(payload, '{status}', '"processed"');
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Full-Text Search
52
+
53
+ ```sql
54
+ -- Add tsvector column
55
+ ALTER TABLE posts ADD COLUMN search_vector TSVECTOR
56
+ GENERATED ALWAYS AS (to_tsvector('portuguese', title || ' ' || content)) STORED;
57
+
58
+ -- Index
59
+ CREATE INDEX idx_posts_search ON posts USING GIN (search_vector);
60
+
61
+ -- Query
62
+ SELECT title FROM posts
63
+ WHERE search_vector @@ plainto_tsquery('portuguese', 'como criar login');
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Changelog
69
+
70
+ ### 1.0.0 — Initial release. JSONB, fulltext, partitioning, CTEs.