@namch/agent-assistant 1.0.0 → 1.0.2

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 (168) hide show
  1. package/README.md +114 -522
  2. package/agents/backend-engineer.md +0 -8
  3. package/agents/brainstormer.md +0 -6
  4. package/agents/business-analyst.md +0 -5
  5. package/agents/database-architect.md +0 -6
  6. package/agents/debugger.md +0 -6
  7. package/agents/designer.md +0 -5
  8. package/agents/devops-engineer.md +0 -7
  9. package/agents/docs-manager.md +0 -6
  10. package/agents/frontend-engineer.md +0 -7
  11. package/agents/game-engineer.md +0 -7
  12. package/agents/mobile-engineer.md +0 -7
  13. package/agents/performance-engineer.md +0 -7
  14. package/agents/planner.md +0 -6
  15. package/agents/project-manager.md +0 -6
  16. package/agents/researcher.md +0 -5
  17. package/agents/reviewer.md +0 -6
  18. package/agents/scouter.md +0 -6
  19. package/agents/security-engineer.md +0 -7
  20. package/agents/tech-lead.md +0 -7
  21. package/agents/tester.md +0 -5
  22. package/cli/README.md +19 -10
  23. package/documents/business/business-features.md +1 -1
  24. package/documents/business/business-prd.md +4 -4
  25. package/documents/knowledge-architecture.md +1 -1
  26. package/documents/knowledge-domain.md +1 -1
  27. package/documents/knowledge-overview.md +14 -29
  28. package/documents/knowledge-source-base.md +14 -14
  29. package/package.json +1 -1
  30. package/rules/QUICK-REFERENCE.md +4 -1
  31. package/rules/SKILL-DISCOVERY.md +37 -14
  32. package/skills/active-directory-attacks/SKILL.md +383 -0
  33. package/skills/active-directory-attacks/references/advanced-attacks.md +382 -0
  34. package/skills/agent-evaluation/SKILL.md +64 -0
  35. package/skills/agent-memory-mcp/SKILL.md +82 -0
  36. package/skills/agent-memory-systems/SKILL.md +67 -0
  37. package/skills/agent-tool-builder/SKILL.md +53 -0
  38. package/skills/ai-agents-architect/SKILL.md +90 -0
  39. package/skills/ai-product/SKILL.md +54 -0
  40. package/skills/ai-wrapper-product/SKILL.md +273 -0
  41. package/skills/api-documentation-generator/SKILL.md +484 -0
  42. package/skills/api-fuzzing-bug-bounty/SKILL.md +433 -0
  43. package/skills/api-security-best-practices/SKILL.md +907 -0
  44. package/skills/autonomous-agent-patterns/SKILL.md +761 -0
  45. package/skills/autonomous-agents/SKILL.md +68 -0
  46. package/skills/aws-penetration-testing/SKILL.md +405 -0
  47. package/skills/aws-penetration-testing/references/advanced-aws-pentesting.md +469 -0
  48. package/skills/azure-functions/SKILL.md +42 -0
  49. package/skills/backend-dev-guidelines/SKILL.md +342 -0
  50. package/skills/backend-dev-guidelines/resources/architecture-overview.md +451 -0
  51. package/skills/backend-dev-guidelines/resources/async-and-errors.md +307 -0
  52. package/skills/backend-dev-guidelines/resources/complete-examples.md +638 -0
  53. package/skills/backend-dev-guidelines/resources/configuration.md +275 -0
  54. package/skills/backend-dev-guidelines/resources/database-patterns.md +224 -0
  55. package/skills/backend-dev-guidelines/resources/middleware-guide.md +213 -0
  56. package/skills/backend-dev-guidelines/resources/routing-and-controllers.md +756 -0
  57. package/skills/backend-dev-guidelines/resources/sentry-and-monitoring.md +336 -0
  58. package/skills/backend-dev-guidelines/resources/services-and-repositories.md +789 -0
  59. package/skills/backend-dev-guidelines/resources/testing-guide.md +235 -0
  60. package/skills/backend-dev-guidelines/resources/validation-patterns.md +754 -0
  61. package/skills/broken-authentication/SKILL.md +476 -0
  62. package/skills/bullmq-specialist/SKILL.md +57 -0
  63. package/skills/bun-development/SKILL.md +691 -0
  64. package/skills/burp-suite-testing/SKILL.md +380 -0
  65. package/skills/cloud-penetration-testing/SKILL.md +501 -0
  66. package/skills/cloud-penetration-testing/references/advanced-cloud-scripts.md +318 -0
  67. package/skills/computer-use-agents/SKILL.md +315 -0
  68. package/skills/content-creator/SKILL.md +248 -0
  69. package/skills/content-creator/assets/content_calendar_template.md +99 -0
  70. package/skills/content-creator/references/brand_guidelines.md +199 -0
  71. package/skills/content-creator/references/content_frameworks.md +534 -0
  72. package/skills/content-creator/references/social_media_optimization.md +317 -0
  73. package/skills/content-creator/scripts/brand_voice_analyzer.py +185 -0
  74. package/skills/content-creator/scripts/seo_optimizer.py +419 -0
  75. package/skills/context-window-management/SKILL.md +53 -0
  76. package/skills/conversation-memory/SKILL.md +61 -0
  77. package/skills/copy-editing/SKILL.md +439 -0
  78. package/skills/copywriting/SKILL.md +225 -0
  79. package/skills/crewai/SKILL.md +243 -0
  80. package/skills/discord-bot-architect/SKILL.md +277 -0
  81. package/skills/dispatching-parallel-agents/SKILL.md +180 -0
  82. package/skills/email-sequence/SKILL.md +925 -0
  83. package/skills/email-systems/SKILL.md +54 -0
  84. package/skills/ethical-hacking-methodology/SKILL.md +466 -0
  85. package/skills/executing-plans/SKILL.md +76 -0
  86. package/skills/file-path-traversal/SKILL.md +486 -0
  87. package/skills/finishing-a-development-branch/SKILL.md +200 -0
  88. package/skills/frontend-dev-guidelines/SKILL.md +359 -0
  89. package/skills/frontend-dev-guidelines/resources/common-patterns.md +331 -0
  90. package/skills/frontend-dev-guidelines/resources/complete-examples.md +872 -0
  91. package/skills/frontend-dev-guidelines/resources/component-patterns.md +502 -0
  92. package/skills/frontend-dev-guidelines/resources/data-fetching.md +767 -0
  93. package/skills/frontend-dev-guidelines/resources/file-organization.md +502 -0
  94. package/skills/frontend-dev-guidelines/resources/loading-and-error-states.md +501 -0
  95. package/skills/frontend-dev-guidelines/resources/performance.md +406 -0
  96. package/skills/frontend-dev-guidelines/resources/routing-guide.md +364 -0
  97. package/skills/frontend-dev-guidelines/resources/styling-guide.md +428 -0
  98. package/skills/frontend-dev-guidelines/resources/typescript-standards.md +418 -0
  99. package/skills/gcp-cloud-run/SKILL.md +288 -0
  100. package/skills/git-pushing/SKILL.md +33 -0
  101. package/skills/git-pushing/scripts/smart_commit.sh +19 -0
  102. package/skills/github-workflow-automation/SKILL.md +846 -0
  103. package/skills/html-injection-testing/SKILL.md +498 -0
  104. package/skills/idor-testing/SKILL.md +442 -0
  105. package/skills/inngest/SKILL.md +55 -0
  106. package/skills/javascript-mastery/SKILL.md +645 -0
  107. package/skills/kaizen/SKILL.md +730 -0
  108. package/skills/langfuse/SKILL.md +238 -0
  109. package/skills/langgraph/SKILL.md +287 -0
  110. package/skills/linux-privilege-escalation/SKILL.md +504 -0
  111. package/skills/llm-app-patterns/SKILL.md +760 -0
  112. package/skills/metasploit-framework/SKILL.md +478 -0
  113. package/skills/multi-agent-brainstorming/SKILL.md +256 -0
  114. package/skills/neon-postgres/SKILL.md +56 -0
  115. package/skills/nextjs-supabase-auth/SKILL.md +56 -0
  116. package/skills/nosql-expert/SKILL.md +111 -0
  117. package/skills/pentest-checklist/SKILL.md +334 -0
  118. package/skills/pentest-commands/SKILL.md +438 -0
  119. package/skills/plaid-fintech/SKILL.md +50 -0
  120. package/skills/planning-with-files/SKILL.md +211 -0
  121. package/skills/planning-with-files/examples.md +202 -0
  122. package/skills/planning-with-files/reference.md +218 -0
  123. package/skills/planning-with-files/scripts/check-complete.sh +44 -0
  124. package/skills/planning-with-files/scripts/init-session.sh +120 -0
  125. package/skills/planning-with-files/templates/findings.md +95 -0
  126. package/skills/planning-with-files/templates/progress.md +114 -0
  127. package/skills/planning-with-files/templates/task_plan.md +132 -0
  128. package/skills/privilege-escalation-methods/SKILL.md +333 -0
  129. package/skills/production-code-audit/SKILL.md +540 -0
  130. package/skills/prompt-caching/SKILL.md +61 -0
  131. package/skills/prompt-engineering/SKILL.md +171 -0
  132. package/skills/prompt-library/SKILL.md +322 -0
  133. package/skills/rag-engineer/SKILL.md +90 -0
  134. package/skills/rag-implementation/SKILL.md +63 -0
  135. package/skills/react-ui-patterns/SKILL.md +289 -0
  136. package/skills/red-team-tools/SKILL.md +310 -0
  137. package/skills/scanning-tools/SKILL.md +589 -0
  138. package/skills/shodan-reconnaissance/SKILL.md +503 -0
  139. package/skills/slack-bot-builder/SKILL.md +264 -0
  140. package/skills/smtp-penetration-testing/SKILL.md +500 -0
  141. package/skills/social-content/SKILL.md +807 -0
  142. package/skills/software-architecture/SKILL.md +75 -0
  143. package/skills/sql-injection-testing/SKILL.md +448 -0
  144. package/skills/sqlmap-database-pentesting/SKILL.md +400 -0
  145. package/skills/ssh-penetration-testing/SKILL.md +488 -0
  146. package/skills/stripe-integration/SKILL.md +69 -0
  147. package/skills/subagent-driven-development/SKILL.md +240 -0
  148. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
  149. package/skills/subagent-driven-development/implementer-prompt.md +78 -0
  150. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  151. package/skills/tavily-web/SKILL.md +36 -0
  152. package/skills/telegram-bot-builder/SKILL.md +254 -0
  153. package/skills/test-driven-development/SKILL.md +371 -0
  154. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  155. package/skills/test-fixing/SKILL.md +119 -0
  156. package/skills/top-web-vulnerabilities/SKILL.md +543 -0
  157. package/skills/trigger-dev/SKILL.md +67 -0
  158. package/skills/twilio-communications/SKILL.md +295 -0
  159. package/skills/upstash-qstash/SKILL.md +68 -0
  160. package/skills/verification-before-completion/SKILL.md +139 -0
  161. package/skills/voice-agents/SKILL.md +68 -0
  162. package/skills/voice-ai-development/SKILL.md +302 -0
  163. package/skills/windows-privilege-escalation/SKILL.md +496 -0
  164. package/skills/wireshark-analysis/SKILL.md +497 -0
  165. package/skills/wordpress-penetration-testing/SKILL.md +485 -0
  166. package/skills/workflow-automation/SKILL.md +68 -0
  167. package/skills/xss-html-injection/SKILL.md +499 -0
  168. package/skills/zapier-make-patterns/SKILL.md +67 -0
@@ -0,0 +1,256 @@
1
+ ---
2
+ name: multi-agent-brainstorming
3
+ description: >
4
+ Use this skill when a design or idea requires higher confidence,
5
+ risk reduction, or formal review. This skill orchestrates a
6
+ structured, sequential multi-agent design review where each agent
7
+ has a strict, non-overlapping role. It prevents blind spots,
8
+ false confidence, and premature convergence.
9
+ ---
10
+
11
+ # Multi-Agent Brainstorming (Structured Design Review)
12
+
13
+ ## Purpose
14
+
15
+ Transform a single-agent design into a **robust, review-validated design**
16
+ by simulating a formal peer-review process using multiple constrained agents.
17
+
18
+ This skill exists to:
19
+ - surface hidden assumptions
20
+ - identify failure modes early
21
+ - validate non-functional constraints
22
+ - stress-test designs before implementation
23
+ - prevent idea swarm chaos
24
+
25
+ This is **not parallel brainstorming**.
26
+ It is **sequential design review with enforced roles**.
27
+
28
+ ---
29
+
30
+ ## Operating Model
31
+
32
+ - One agent designs.
33
+ - Other agents review.
34
+ - No agent may exceed its mandate.
35
+ - Creativity is centralized; critique is distributed.
36
+ - Decisions are explicit and logged.
37
+
38
+ The process is **gated** and **terminates by design**.
39
+
40
+ ---
41
+
42
+ ## Agent Roles (Non-Negotiable)
43
+
44
+ Each agent operates under a **hard scope limit**.
45
+
46
+ ### 1️⃣ Primary Designer (Lead Agent)
47
+
48
+ **Role:**
49
+ - Owns the design
50
+ - Runs the standard `brainstorming` skill
51
+ - Maintains the Decision Log
52
+
53
+ **May:**
54
+ - Ask clarification questions
55
+ - Propose designs and alternatives
56
+ - Revise designs based on feedback
57
+
58
+ **May NOT:**
59
+ - Self-approve the final design
60
+ - Ignore reviewer objections
61
+ - Invent requirements post-lock
62
+
63
+ ---
64
+
65
+ ### 2️⃣ Skeptic / Challenger Agent
66
+
67
+ **Role:**
68
+ - Assume the design will fail
69
+ - Identify weaknesses and risks
70
+
71
+ **May:**
72
+ - Question assumptions
73
+ - Identify edge cases
74
+ - Highlight ambiguity or overconfidence
75
+ - Flag YAGNI violations
76
+
77
+ **May NOT:**
78
+ - Propose new features
79
+ - Redesign the system
80
+ - Offer alternative architectures
81
+
82
+ Prompting guidance:
83
+ > “Assume this design fails in production. Why?”
84
+
85
+ ---
86
+
87
+ ### 3️⃣ Constraint Guardian Agent
88
+
89
+ **Role:**
90
+ - Enforce non-functional and real-world constraints
91
+
92
+ Focus areas:
93
+ - performance
94
+ - scalability
95
+ - reliability
96
+ - security & privacy
97
+ - maintainability
98
+ - operational cost
99
+
100
+ **May:**
101
+ - Reject designs that violate constraints
102
+ - Request clarification of limits
103
+
104
+ **May NOT:**
105
+ - Debate product goals
106
+ - Suggest feature changes
107
+ - Optimize beyond stated requirements
108
+
109
+ ---
110
+
111
+ ### 4️⃣ User Advocate Agent
112
+
113
+ **Role:**
114
+ - Represent the end user
115
+
116
+ Focus areas:
117
+ - cognitive load
118
+ - usability
119
+ - clarity of flows
120
+ - error handling from user perspective
121
+ - mismatch between intent and experience
122
+
123
+ **May:**
124
+ - Identify confusing or misleading aspects
125
+ - Flag poor defaults or unclear behavior
126
+
127
+ **May NOT:**
128
+ - Redesign architecture
129
+ - Add features
130
+ - Override stated user goals
131
+
132
+ ---
133
+
134
+ ### 5️⃣ Integrator / Arbiter Agent
135
+
136
+ **Role:**
137
+ - Resolve conflicts
138
+ - Finalize decisions
139
+ - Enforce exit criteria
140
+
141
+ **May:**
142
+ - Accept or reject objections
143
+ - Require design revisions
144
+ - Declare the design complete
145
+
146
+ **May NOT:**
147
+ - Invent new ideas
148
+ - Add requirements
149
+ - Reopen locked decisions without cause
150
+
151
+ ---
152
+
153
+ ## The Process
154
+
155
+ ### Phase 1 — Single-Agent Design
156
+
157
+ 1. Primary Designer runs the **standard `brainstorming` skill**
158
+ 2. Understanding Lock is completed and confirmed
159
+ 3. Initial design is produced
160
+ 4. Decision Log is started
161
+
162
+ No other agents participate yet.
163
+
164
+ ---
165
+
166
+ ### Phase 2 — Structured Review Loop
167
+
168
+ Agents are invoked **one at a time**, in the following order:
169
+
170
+ 1. Skeptic / Challenger
171
+ 2. Constraint Guardian
172
+ 3. User Advocate
173
+
174
+ For each reviewer:
175
+ - Feedback must be explicit and scoped
176
+ - Objections must reference assumptions or decisions
177
+ - No new features may be introduced
178
+
179
+ Primary Designer must:
180
+ - Respond to each objection
181
+ - Revise the design if required
182
+ - Update the Decision Log
183
+
184
+ ---
185
+
186
+ ### Phase 3 — Integration & Arbitration
187
+
188
+ The Integrator / Arbiter reviews:
189
+ - the final design
190
+ - the Decision Log
191
+ - unresolved objections
192
+
193
+ The Arbiter must explicitly decide:
194
+ - which objections are accepted
195
+ - which are rejected (with rationale)
196
+
197
+ ---
198
+
199
+ ## Decision Log (Mandatory Artifact)
200
+
201
+ The Decision Log must record:
202
+
203
+ - Decision made
204
+ - Alternatives considered
205
+ - Objections raised
206
+ - Resolution and rationale
207
+
208
+ No design is considered valid without a completed log.
209
+
210
+ ---
211
+
212
+ ## Exit Criteria (Hard Stop)
213
+
214
+ You may exit multi-agent brainstorming **only when all are true**:
215
+
216
+ - Understanding Lock was completed
217
+ - All reviewer agents have been invoked
218
+ - All objections are resolved or explicitly rejected
219
+ - Decision Log is complete
220
+ - Arbiter has declared the design acceptable
221
+ -
222
+ If any criterion is unmet:
223
+ - Continue review
224
+ - Do NOT proceed to implementation
225
+ If this skill was invoked by a routing or orchestration layer, you MUST report the final disposition explicitly as one of: APPROVED, REVISE, or REJECT, with a brief rationale.
226
+ ---
227
+
228
+ ## Failure Modes This Skill Prevents
229
+
230
+ - Idea swarm chaos
231
+ - Hallucinated consensus
232
+ - Overconfident single-agent designs
233
+ - Hidden assumptions
234
+ - Premature implementation
235
+ - Endless debate
236
+
237
+ ---
238
+
239
+ ## Key Principles
240
+
241
+ - One designer, many reviewers
242
+ - Creativity is centralized
243
+ - Critique is constrained
244
+ - Decisions are explicit
245
+ - Process must terminate
246
+
247
+ ---
248
+
249
+ ## Final Reminder
250
+
251
+ This skill exists to answer one question with confidence:
252
+
253
+ > “If this design fails, did we do everything reasonable to catch it early?”
254
+
255
+ If the answer is unclear, **do not exit this skill**.
256
+
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: neon-postgres
3
+ description: "Expert patterns for Neon serverless Postgres, branching, connection pooling, and Prisma/Drizzle integration Use when: neon database, serverless postgres, database branching, neon postgres, postgres serverless."
4
+ source: vibeship-spawner-skills (Apache 2.0)
5
+ ---
6
+
7
+ # Neon Postgres
8
+
9
+ ## Patterns
10
+
11
+ ### Prisma with Neon Connection
12
+
13
+ Configure Prisma for Neon with connection pooling.
14
+
15
+ Use two connection strings:
16
+ - DATABASE_URL: Pooled connection for Prisma Client
17
+ - DIRECT_URL: Direct connection for Prisma Migrate
18
+
19
+ The pooled connection uses PgBouncer for up to 10K connections.
20
+ Direct connection required for migrations (DDL operations).
21
+
22
+
23
+ ### Drizzle with Neon Serverless Driver
24
+
25
+ Use Drizzle ORM with Neon's serverless HTTP driver for
26
+ edge/serverless environments.
27
+
28
+ Two driver options:
29
+ - neon-http: Single queries over HTTP (fastest for one-off queries)
30
+ - neon-serverless: WebSocket for transactions and sessions
31
+
32
+
33
+ ### Connection Pooling with PgBouncer
34
+
35
+ Neon provides built-in connection pooling via PgBouncer.
36
+
37
+ Key limits:
38
+ - Up to 10,000 concurrent connections to pooler
39
+ - Connections still consume underlying Postgres connections
40
+ - 7 connections reserved for Neon superuser
41
+
42
+ Use pooled endpoint for application, direct for migrations.
43
+
44
+
45
+ ## ⚠️ Sharp Edges
46
+
47
+ | Issue | Severity | Solution |
48
+ |-------|----------|----------|
49
+ | Issue | high | See docs |
50
+ | Issue | high | See docs |
51
+ | Issue | high | See docs |
52
+ | Issue | medium | See docs |
53
+ | Issue | medium | See docs |
54
+ | Issue | low | See docs |
55
+ | Issue | medium | See docs |
56
+ | Issue | high | See docs |
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: nextjs-supabase-auth
3
+ description: "Expert integration of Supabase Auth with Next.js App Router Use when: supabase auth next, authentication next.js, login supabase, auth middleware, protected route."
4
+ source: vibeship-spawner-skills (Apache 2.0)
5
+ ---
6
+
7
+ # Next.js + Supabase Auth
8
+
9
+ You are an expert in integrating Supabase Auth with Next.js App Router.
10
+ You understand the server/client boundary, how to handle auth in middleware,
11
+ Server Components, Client Components, and Server Actions.
12
+
13
+ Your core principles:
14
+ 1. Use @supabase/ssr for App Router integration
15
+ 2. Handle tokens in middleware for protected routes
16
+ 3. Never expose auth tokens to client unnecessarily
17
+ 4. Use Server Actions for auth operations when possible
18
+ 5. Understand the cookie-based session flow
19
+
20
+ ## Capabilities
21
+
22
+ - nextjs-auth
23
+ - supabase-auth-nextjs
24
+ - auth-middleware
25
+ - auth-callback
26
+
27
+ ## Requirements
28
+
29
+ - nextjs-app-router
30
+ - supabase-backend
31
+
32
+ ## Patterns
33
+
34
+ ### Supabase Client Setup
35
+
36
+ Create properly configured Supabase clients for different contexts
37
+
38
+ ### Auth Middleware
39
+
40
+ Protect routes and refresh sessions in middleware
41
+
42
+ ### Auth Callback Route
43
+
44
+ Handle OAuth callback and exchange code for session
45
+
46
+ ## Anti-Patterns
47
+
48
+ ### ❌ getSession in Server Components
49
+
50
+ ### ❌ Auth State in Client Without Listener
51
+
52
+ ### ❌ Storing Tokens Manually
53
+
54
+ ## Related Skills
55
+
56
+ Works well with: `nextjs-app-router`, `supabase-backend`
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: nosql-expert
3
+ description: "Expert guidance for distributed NoSQL databases (Cassandra, DynamoDB). Focuses on mental models, query-first modeling, single-table design, and avoiding hot partitions in high-scale systems."
4
+ ---
5
+
6
+ # NoSQL Expert Patterns (Cassandra & DynamoDB)
7
+
8
+ ## Overview
9
+
10
+ This skill provides professional mental models and design patterns for **distributed wide-column and key-value stores** (specifically Apache Cassandra and Amazon DynamoDB).
11
+
12
+ Unlike SQL (where you model data entities), or document stores (like MongoDB), these distributed systems require you to **model your queries first**.
13
+
14
+ ## When to Use
15
+
16
+ - **Designing for Scale**: Moving beyond simple single-node databases to distributed clusters.
17
+ - **Technology Selection**: Evaluating or using **Cassandra**, **ScyllaDB**, or **DynamoDB**.
18
+ - **Performance Tuning**: Troubleshooting "hot partitions" or high latency in existing NoSQL systems.
19
+ - **Microservices**: Implementing "database-per-service" patterns where highly optimized reads are required.
20
+
21
+ ## The Mental Shift: SQL vs. Distributed NoSQL
22
+
23
+ | Feature | SQL (Relational) | Distributed NoSQL (Cassandra/DynamoDB) |
24
+ | :--- | :--- | :--- |
25
+ | **Data modeling** | Model Entities + Relationships | Model **Queries** (Access Patterns) |
26
+ | **Joins** | CPU-intensive, at read time | **Pre-computed** (Denormalized) at write time |
27
+ | **Storage cost** | Expensive (minimize duplication) | Cheap (duplicate data for read speed) |
28
+ | **Consistency** | ACID (Strong) | **BASE (Eventual)** / Tunable |
29
+ | **Scalability** | Vertical (Bigger machine) | **Horizontal** (More nodes/shards) |
30
+
31
+ > **The Golden Rule:** In SQL, you design the data model to answer *any* query. In NoSQL, you design the data model to answer *specific* queries efficiently.
32
+
33
+ ## Core Design Patterns
34
+
35
+ ### 1. Query-First Modeling (Access Patterns)
36
+
37
+ You typically cannot "add a query later" without migration or creating a new table/index.
38
+
39
+ **Process:**
40
+ 1. **List all Entities** (User, Order, Product).
41
+ 2. **List all Access Patterns** ("Get User by Email", "Get Orders by User sorted by Date").
42
+ 3. **Design Table(s)** specifically to serve those patterns with a single lookup.
43
+
44
+ ### 2. The Partition Key is King
45
+
46
+ Data is distributed across physical nodes based on the **Partition Key (PK)**.
47
+ - **Goal:** Even distribution of data and traffic.
48
+ - **Anti-Pattern:** Using a low-cardinality PK (e.g., `status="active"` or `gender="m"`) creates **Hot Partitions**, limiting throughput to a single node's capacity.
49
+ - **Best Practice:** Use high-cardinality keys (User IDs, Device IDs, Composite Keys).
50
+
51
+ ### 3. Clustering / Sort Keys
52
+
53
+ Within a partition, data is sorted on disk by the **Clustering Key (Cassandra)** or **Sort Key (DynamoDB)**.
54
+ - This allows for efficient **Range Queries** (e.g., `WHERE user_id=X AND date > Y`).
55
+ - It effectively pre-sorts your data for specific retrieval requirements.
56
+
57
+ ### 4. Single-Table Design (Adjacency Lists)
58
+
59
+ *Primary use: DynamoDB (but concepts apply elsewhere)*
60
+
61
+ Storing multiple entity types in one table to enable pre-joined reads.
62
+
63
+ | PK (Partition) | SK (Sort) | Data Fields... |
64
+ | :--- | :--- | :--- |
65
+ | `USER#123` | `PROFILE` | `{ name: "Ian", email: "..." }` |
66
+ | `USER#123` | `ORDER#998` | `{ total: 50.00, status: "shipped" }` |
67
+ | `USER#123` | `ORDER#999` | `{ total: 12.00, status: "pending" }` |
68
+
69
+ - **Query:** `PK="USER#123"`
70
+ - **Result:** Fetches User Profile AND all Orders in **one network request**.
71
+
72
+ ### 5. Denormalization & Duplication
73
+
74
+ Don't be afraid to store the same data in multiple tables to serve different query patterns.
75
+ - **Table A:** `users_by_id` (PK: uuid)
76
+ - **Table B:** `users_by_email` (PK: email)
77
+
78
+ *Trade-off: You must manage data consistency across tables (often using eventual consistency or batch writes).*
79
+
80
+ ## Specific Guidance
81
+
82
+ ### Apache Cassandra / ScyllaDB
83
+
84
+ - **Primary Key Structure:** `((Partition Key), Clustering Columns)`
85
+ - **No Joins, No Aggregates:** Do not try to `JOIN` or `GROUP BY`. Pre-calculate aggregates in a separate counter table.
86
+ - **Avoid `ALLOW FILTERING`:** If you see this in production, your data model is wrong. It implies a full cluster scan.
87
+ - **Writes are Cheap:** Inserts and Updates are just appends to the LSM tree. Don't worry about write volume as much as read efficiency.
88
+ - **Tombstones:** Deletes are expensive markers. Avoid high-velocity delete patterns (like queues) in standard tables.
89
+
90
+ ### AWS DynamoDB
91
+
92
+ - **GSI (Global Secondary Index):** Use GSIs to create alternative views of your data (e.g., "Search Orders by Date" instead of by User).
93
+ - *Note:* GSIs are eventually consistent.
94
+ - **LSI (Local Secondary Index):** Sorts data differently *within* the same partition. Must be created at table creation time.
95
+ - **WCU / RCU:** Understand capacity modes. Single-table design helps optimize consumed capacity units.
96
+ - **TTL:** Use Time-To-Live attributes to automatically expire old data (free delete) without creating tombstones.
97
+
98
+ ## Expert Checklist
99
+
100
+ Before finalizing your NoSQL schema:
101
+
102
+ - [ ] **Access Pattern Coverage:** Does every query pattern map to a specific table or index?
103
+ - [ ] **Cardinality Check:** Does the Partition Key have enough unique values to spread traffic evenly?
104
+ - [ ] **Split Partition Risk:** For any single partition (e.g., a single user's orders), will it grow indefinitely? (If > 10GB, you need to "shard" the partition, e.g., `USER#123#2024-01`).
105
+ - [ ] **Consistency Requirement:** Can the application tolerate eventual consistency for this read pattern?
106
+
107
+ ## Common Anti-Patterns
108
+
109
+ ❌ **Scatter-Gather:** Querying *all* partitions to find one item (Scan).
110
+ ❌ **Hot Keys:** Putting all "Monday" data into one partition.
111
+ ❌ **Relational Modeling:** Creating `Author` and `Book` tables and trying to join them in code. (Instead, embed Book summaries in Author, or duplicate Author info in Books).