@wipal/agent-team 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/.claude/rules/common/general-rules.md +141 -0
- package/.claude/rules/lessons/lessons.md +91 -0
- package/.claude/rules/role-rules/dev-fe-rules.md +146 -0
- package/.claude/rules/role-rules/sa-rules.md +226 -0
- package/.claude/skills/SKILL-INDEX.md +299 -0
- package/.claude/skills/community/security-validator/SKILL.md +392 -0
- package/.claude/skills/core/agent-creation/SKILL.md +338 -0
- package/.claude/skills/core/code-review/SKILL.md +154 -0
- package/.claude/skills/core/git-automation/SKILL.md +93 -0
- package/.claude/skills/core/retrospect-work/SKILL.md +172 -0
- package/.claude/skills/domain/architecture/adr-writing/SKILL.md +254 -0
- package/.claude/skills/domain/architecture/adr-writing/references/adr-best-practices.md +257 -0
- package/.claude/skills/domain/architecture/adr-writing/references/adr-examples.md +246 -0
- package/.claude/skills/domain/architecture/adr-writing/references/adr-template.md +160 -0
- package/.claude/skills/domain/architecture/architecture-patterns/SKILL.md +316 -0
- package/.claude/skills/domain/architecture/architecture-patterns/references/event-driven.md +393 -0
- package/.claude/skills/domain/architecture/architecture-patterns/references/microservices.md +315 -0
- package/.claude/skills/domain/architecture/architecture-patterns/references/monolith.md +321 -0
- package/.claude/skills/domain/architecture/architecture-patterns/references/serverless.md +457 -0
- package/.claude/skills/domain/architecture/performance-engineering/SKILL.md +227 -0
- package/.claude/skills/domain/architecture/performance-engineering/references/benchmarking.md +336 -0
- package/.claude/skills/domain/architecture/performance-engineering/references/caching-strategies.md +284 -0
- package/.claude/skills/domain/architecture/performance-engineering/references/optimization.md +298 -0
- package/.claude/skills/domain/architecture/security-architecture/SKILL.md +206 -0
- package/.claude/skills/domain/architecture/security-architecture/references/auth-patterns.md +209 -0
- package/.claude/skills/domain/architecture/security-architecture/references/compliance.md +246 -0
- package/.claude/skills/domain/architecture/security-architecture/references/threat-modeling.md +219 -0
- package/.claude/skills/domain/architecture/system-design/SKILL.md +227 -0
- package/.claude/skills/domain/architecture/system-design/references/distributed-systems.md +231 -0
- package/.claude/skills/domain/architecture/system-design/references/resilience.md +344 -0
- package/.claude/skills/domain/architecture/system-design/references/scalability.md +303 -0
- package/.claude/skills/domain/architecture/tech-selection/SKILL.md +192 -0
- package/.claude/skills/domain/architecture/tech-selection/references/build-vs-buy.md +258 -0
- package/.claude/skills/domain/architecture/tech-selection/references/evaluation-framework.md +203 -0
- package/.claude/skills/domain/architecture/tech-selection/references/tech-radar.md +257 -0
- package/.claude/skills/domain/backend/api-design/SKILL.md +121 -0
- package/.claude/skills/domain/backend/database-design/SKILL.md +156 -0
- package/.claude/skills/domain/backend/performance-be/SKILL.md +210 -0
- package/.claude/skills/domain/backend/security/SKILL.md +138 -0
- package/.claude/skills/domain/backend/testing-be/SKILL.md +203 -0
- package/.claude/skills/domain/devops/ci-cd/SKILL.md +188 -0
- package/.claude/skills/domain/devops/containerization/SKILL.md +177 -0
- package/.claude/skills/domain/devops/deployment/SKILL.md +198 -0
- package/.claude/skills/domain/devops/infrastructure-as-code/SKILL.md +178 -0
- package/.claude/skills/domain/devops/monitoring/SKILL.md +163 -0
- package/.claude/skills/domain/frontend/accessibility/SKILL.md +179 -0
- package/.claude/skills/domain/frontend/frontend-design/SKILL.md +138 -0
- package/.claude/skills/domain/frontend/performance-fe/SKILL.md +195 -0
- package/.claude/skills/domain/frontend/state-management/SKILL.md +190 -0
- package/.claude/skills/domain/frontend/testing-fe/SKILL.md +193 -0
- package/.claude/skills/domain/product/requirements-gathering/SKILL.md +136 -0
- package/.claude/skills/domain/product/roadmap-planning/SKILL.md +169 -0
- package/.claude/skills/domain/product/sprint-planning/SKILL.md +151 -0
- package/.claude/skills/domain/product/stakeholder-communication/SKILL.md +162 -0
- package/.claude/skills/domain/product/user-stories/SKILL.md +141 -0
- package/.claude/skills/domain/quality/bug-reporting/SKILL.md +150 -0
- package/.claude/skills/domain/quality/regression-testing/SKILL.md +178 -0
- package/.claude/skills/domain/quality/test-automation/SKILL.md +185 -0
- package/.claude/skills/domain/quality/test-planning/SKILL.md +177 -0
- package/.claude/skills/leadership/code-review-advanced/SKILL.md +167 -0
- package/.claude/skills/leadership/mentoring/SKILL.md +151 -0
- package/.claude/skills/leadership/technical-debt/SKILL.md +166 -0
- package/.claude/skills/leadership/technical-decision/SKILL.md +160 -0
- package/.claude/skills/security-reports/.gitkeep +0 -0
- package/.claude/skills/skills-registry.yaml +441 -0
- package/README.md +232 -0
- package/bin/agent-team.js +107 -0
- package/package.json +51 -0
- package/src/commands/add.js +227 -0
- package/src/commands/init.js +136 -0
- package/src/commands/list.js +66 -0
- package/src/commands/remove.js +71 -0
- package/src/commands/switch.js +53 -0
- package/src/index.js +11 -0
- package/src/interactive/prompts.js +153 -0
- package/src/server/api/agents.js +150 -0
- package/src/server/api/roles.js +97 -0
- package/src/server/api/skills.js +79 -0
- package/src/server/index.js +78 -0
- package/src/ui/agents.html +174 -0
- package/src/ui/css/styles.css +470 -0
- package/src/ui/index.html +107 -0
- package/src/ui/roles.html +371 -0
- package/src/ui/skills.html +332 -0
- package/src/utils/file-utils.js +193 -0
- package/src/utils/skill-resolver.js +594 -0
- package/src/utils/skill-scanner.js +154 -0
- package/templates/CLAUDE.md.tmpl +42 -0
- package/templates/knowledge.md.tmpl +31 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Compliance Frameworks
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Compliance requirements vary by industry and region. This reference covers common frameworks and their key requirements.
|
|
5
|
+
|
|
6
|
+
## Major Compliance Frameworks
|
|
7
|
+
|
|
8
|
+
### GDPR (EU Data Protection)
|
|
9
|
+
```
|
|
10
|
+
Scope: Personal data of EU residents
|
|
11
|
+
|
|
12
|
+
Key Requirements:
|
|
13
|
+
- Lawful basis for processing
|
|
14
|
+
- Data subject rights (access, deletion, portability)
|
|
15
|
+
- Data protection by design
|
|
16
|
+
- Privacy notices
|
|
17
|
+
- Data breach notification (72 hours)
|
|
18
|
+
- Data Protection Officer (for large-scale processing)
|
|
19
|
+
|
|
20
|
+
Technical Measures:
|
|
21
|
+
- Encryption at rest and in transit
|
|
22
|
+
- Access controls
|
|
23
|
+
- Audit logging
|
|
24
|
+
- Data minimization
|
|
25
|
+
- Pseudonymization
|
|
26
|
+
|
|
27
|
+
Documentation:
|
|
28
|
+
- Processing activities record
|
|
29
|
+
- Privacy impact assessments
|
|
30
|
+
- Data retention policies
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### SOC 2 (Service Organization Control)
|
|
34
|
+
```
|
|
35
|
+
Scope: Service providers handling customer data
|
|
36
|
+
|
|
37
|
+
Trust Service Criteria:
|
|
38
|
+
1. Security (Common Criteria)
|
|
39
|
+
2. Availability
|
|
40
|
+
3. Processing Integrity
|
|
41
|
+
4. Confidentiality
|
|
42
|
+
5. Privacy
|
|
43
|
+
|
|
44
|
+
Key Controls:
|
|
45
|
+
- Access control
|
|
46
|
+
- Encryption
|
|
47
|
+
- Monitoring
|
|
48
|
+
- Incident response
|
|
49
|
+
- Change management
|
|
50
|
+
- Risk assessment
|
|
51
|
+
|
|
52
|
+
Types:
|
|
53
|
+
- Type I: Point-in-time
|
|
54
|
+
- Type II: Period (6-12 months)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### HIPAA (US Healthcare)
|
|
58
|
+
```
|
|
59
|
+
Scope: Protected Health Information (PHI)
|
|
60
|
+
|
|
61
|
+
Rules:
|
|
62
|
+
- Privacy Rule: Use and disclosure
|
|
63
|
+
- Security Rule: Technical safeguards
|
|
64
|
+
- Breach Notification Rule
|
|
65
|
+
|
|
66
|
+
Technical Safeguards:
|
|
67
|
+
- Access controls
|
|
68
|
+
- Audit controls
|
|
69
|
+
- Integrity controls
|
|
70
|
+
- Transmission security (encryption)
|
|
71
|
+
- Authentication
|
|
72
|
+
|
|
73
|
+
Administrative Safeguards:
|
|
74
|
+
- Security officer
|
|
75
|
+
- Risk analysis
|
|
76
|
+
- Training
|
|
77
|
+
- Incident procedures
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### PCI DSS (Payment Cards)
|
|
81
|
+
```
|
|
82
|
+
Scope: Credit card data
|
|
83
|
+
|
|
84
|
+
Requirements (12 total):
|
|
85
|
+
1. Firewall configuration
|
|
86
|
+
2. Default passwords changed
|
|
87
|
+
3. Stored data protection
|
|
88
|
+
4. Encryption in transit
|
|
89
|
+
5. Anti-virus software
|
|
90
|
+
6. Secure systems
|
|
91
|
+
7. Need-to-know access
|
|
92
|
+
8. Unique user IDs
|
|
93
|
+
9. Physical access control
|
|
94
|
+
10. Access logging
|
|
95
|
+
11. Security testing
|
|
96
|
+
12. Information security policy
|
|
97
|
+
|
|
98
|
+
Compliance Levels:
|
|
99
|
+
- Level 1: >6M transactions/year (audit)
|
|
100
|
+
- Level 2: 1-6M transactions (self-assessment)
|
|
101
|
+
- Level 3: 20K-1M transactions (self-assessment)
|
|
102
|
+
- Level 4: <20K transactions (self-assessment)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### ISO 27001 (Information Security)
|
|
106
|
+
```
|
|
107
|
+
Scope: Information Security Management System (ISMS)
|
|
108
|
+
|
|
109
|
+
Structure:
|
|
110
|
+
- 114 controls in Annex A
|
|
111
|
+
- Organizational controls
|
|
112
|
+
- People controls
|
|
113
|
+
- Physical controls
|
|
114
|
+
- Technological controls
|
|
115
|
+
|
|
116
|
+
Implementation:
|
|
117
|
+
1. Scope definition
|
|
118
|
+
2. Risk assessment
|
|
119
|
+
3. Control selection
|
|
120
|
+
4. Policy documentation
|
|
121
|
+
5. Implementation
|
|
122
|
+
6. Internal audit
|
|
123
|
+
7. Certification audit
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Compliance Checklist Template
|
|
127
|
+
|
|
128
|
+
### Data Protection
|
|
129
|
+
```
|
|
130
|
+
- [ ] Data inventory completed
|
|
131
|
+
- [ ] Data classification scheme
|
|
132
|
+
- [ ] Retention policies defined
|
|
133
|
+
- [ ] Deletion procedures documented
|
|
134
|
+
- [ ] Encryption implemented
|
|
135
|
+
- [ ] Access controls in place
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Access Control
|
|
139
|
+
```
|
|
140
|
+
- [ ] Role-based access implemented
|
|
141
|
+
- [ ] Principle of least privilege
|
|
142
|
+
- [ ] Multi-factor authentication
|
|
143
|
+
- [ ] Access review process
|
|
144
|
+
- [ ] Privileged access management
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Audit & Monitoring
|
|
148
|
+
```
|
|
149
|
+
- [ ] Audit logging enabled
|
|
150
|
+
- [ ] Log retention defined
|
|
151
|
+
- [ ] Monitoring alerts configured
|
|
152
|
+
- [ ] Incident response procedures
|
|
153
|
+
- [ ] Regular security reviews
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Documentation
|
|
157
|
+
```
|
|
158
|
+
- [ ] Security policies documented
|
|
159
|
+
- [ ] Risk assessments completed
|
|
160
|
+
- [ ] Processing activities recorded
|
|
161
|
+
- [ ] Training records maintained
|
|
162
|
+
- [ ] Vendor assessments completed
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Cross-Compliance Mapping
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
Control Area | GDPR | SOC2 | HIPAA | PCI | ISO27001
|
|
169
|
+
----------------------|------|------|-------|-----|----------
|
|
170
|
+
Access Control | ✓ | ✓ | ✓ | ✓ | ✓
|
|
171
|
+
Encryption | ✓ | ✓ | ✓ | ✓ | ✓
|
|
172
|
+
Audit Logging | ✓ | ✓ | ✓ | ✓ | ✓
|
|
173
|
+
Incident Response | ✓ | ✓ | ✓ | ✓ | ✓
|
|
174
|
+
Risk Assessment | ✓ | ✓ | ✓ | ✓ | ✓
|
|
175
|
+
Data Minimization | ✓ | - | ✓ | ✓ | ✓
|
|
176
|
+
Vendor Management | ✓ | ✓ | ✓ | ✓ | ✓
|
|
177
|
+
Training | ✓ | ✓ | ✓ | ✓ | ✓
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Compliance in Architecture
|
|
181
|
+
|
|
182
|
+
### Data Residency
|
|
183
|
+
```
|
|
184
|
+
GDPR: EU data in EU (or adequate protection)
|
|
185
|
+
China: Data localization required
|
|
186
|
+
Russia: Personal data in Russia
|
|
187
|
+
|
|
188
|
+
Architecture Impact:
|
|
189
|
+
- Region-specific deployments
|
|
190
|
+
- Data replication controls
|
|
191
|
+
- Cross-border transfer mechanisms
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Right to Deletion
|
|
195
|
+
```
|
|
196
|
+
GDPR Article 17: Right to erasure
|
|
197
|
+
|
|
198
|
+
Implementation:
|
|
199
|
+
- Soft delete with retention period
|
|
200
|
+
- Hard delete capability
|
|
201
|
+
- Backup handling
|
|
202
|
+
- Cascade to related systems
|
|
203
|
+
- Verification mechanism
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Audit Trail Requirements
|
|
207
|
+
```
|
|
208
|
+
What to log:
|
|
209
|
+
- Who (user/service)
|
|
210
|
+
- What (action)
|
|
211
|
+
- When (timestamp)
|
|
212
|
+
- Where (IP, system)
|
|
213
|
+
- Result (success/failure)
|
|
214
|
+
|
|
215
|
+
Retention:
|
|
216
|
+
- HIPAA: 6 years
|
|
217
|
+
- SOX: 7 years
|
|
218
|
+
- PCI: 1 year
|
|
219
|
+
- GDPR: As needed for purpose
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Compliance Tools
|
|
223
|
+
|
|
224
|
+
### Assessment Tools
|
|
225
|
+
```
|
|
226
|
+
- Compliance frameworks (NIST CSF)
|
|
227
|
+
- Gap analysis tools
|
|
228
|
+
- Risk assessment templates
|
|
229
|
+
- Vendor questionnaires (SIG, CAIQ)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Monitoring Tools
|
|
233
|
+
```
|
|
234
|
+
- SIEM (Security Information & Event Management)
|
|
235
|
+
- DLP (Data Loss Prevention)
|
|
236
|
+
- Cloud security posture management
|
|
237
|
+
- Compliance dashboards
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Documentation Tools
|
|
241
|
+
```
|
|
242
|
+
- GRC platforms (Governance, Risk, Compliance)
|
|
243
|
+
- Policy management systems
|
|
244
|
+
- Evidence collection tools
|
|
245
|
+
- Audit management systems
|
|
246
|
+
```
|
package/.claude/skills/domain/architecture/security-architecture/references/threat-modeling.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Threat Modeling
|
|
2
|
+
|
|
3
|
+
## What is Threat Modeling?
|
|
4
|
+
A structured approach to identifying, assessing, and addressing security threats.
|
|
5
|
+
|
|
6
|
+
## STRIDE Framework
|
|
7
|
+
|
|
8
|
+
### Spoofing
|
|
9
|
+
```
|
|
10
|
+
Definition: Pretending to be something/someone else
|
|
11
|
+
|
|
12
|
+
Examples:
|
|
13
|
+
- Fake login page
|
|
14
|
+
- Compromised credentials
|
|
15
|
+
- Session hijacking
|
|
16
|
+
- IP spoofing
|
|
17
|
+
|
|
18
|
+
Mitigations:
|
|
19
|
+
- Strong authentication (MFA)
|
|
20
|
+
- Certificate validation
|
|
21
|
+
- Session tokens with expiration
|
|
22
|
+
- Anti-phishing measures
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Tampering
|
|
26
|
+
```
|
|
27
|
+
Definition: Unauthorized modification of data
|
|
28
|
+
|
|
29
|
+
Examples:
|
|
30
|
+
- SQL injection
|
|
31
|
+
- Parameter tampering
|
|
32
|
+
- File modification
|
|
33
|
+
- Man-in-the-middle
|
|
34
|
+
|
|
35
|
+
Mitigations:
|
|
36
|
+
- Input validation
|
|
37
|
+
- Parameterized queries
|
|
38
|
+
- Digital signatures
|
|
39
|
+
- Integrity checks (hashes)
|
|
40
|
+
- TLS for transit
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Repudiation
|
|
44
|
+
```
|
|
45
|
+
Definition: Ability to deny actions
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
- "I didn't make that transaction"
|
|
49
|
+
- "Someone else used my account"
|
|
50
|
+
- Log deletion
|
|
51
|
+
|
|
52
|
+
Mitigations:
|
|
53
|
+
- Comprehensive audit logging
|
|
54
|
+
- Digital signatures
|
|
55
|
+
- Non-repudiation services
|
|
56
|
+
- Timestamped logs
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Information Disclosure
|
|
60
|
+
```
|
|
61
|
+
Definition: Unauthorized access to information
|
|
62
|
+
|
|
63
|
+
Examples:
|
|
64
|
+
- Data breach
|
|
65
|
+
- Error message leakage
|
|
66
|
+
- Side-channel attacks
|
|
67
|
+
- Insecure storage
|
|
68
|
+
|
|
69
|
+
Mitigations:
|
|
70
|
+
- Encryption (at rest, in transit)
|
|
71
|
+
- Access controls
|
|
72
|
+
- Data masking
|
|
73
|
+
- Secure error handling
|
|
74
|
+
- Minimal data exposure
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Denial of Service
|
|
78
|
+
```
|
|
79
|
+
Definition: Preventing legitimate access
|
|
80
|
+
|
|
81
|
+
Examples:
|
|
82
|
+
- DDoS attacks
|
|
83
|
+
- Resource exhaustion
|
|
84
|
+
- Application crashes
|
|
85
|
+
- Locking accounts
|
|
86
|
+
|
|
87
|
+
Mitigations:
|
|
88
|
+
- Rate limiting
|
|
89
|
+
- Load balancing
|
|
90
|
+
- Auto-scaling
|
|
91
|
+
- Resource quotas
|
|
92
|
+
- Circuit breakers
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Elevation of Privilege
|
|
96
|
+
```
|
|
97
|
+
Definition: Gaining unauthorized capabilities
|
|
98
|
+
|
|
99
|
+
Examples:
|
|
100
|
+
- SQL injection to admin
|
|
101
|
+
- Exploiting vulnerabilities
|
|
102
|
+
- Token manipulation
|
|
103
|
+
- Horizontal/vertical escalation
|
|
104
|
+
|
|
105
|
+
Mitigations:
|
|
106
|
+
- Principle of least privilege
|
|
107
|
+
- Role validation
|
|
108
|
+
- Security patches
|
|
109
|
+
- Input validation
|
|
110
|
+
- API authorization
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Threat Modeling Process
|
|
114
|
+
|
|
115
|
+
### Step 1: Identify Assets
|
|
116
|
+
```
|
|
117
|
+
What are we protecting?
|
|
118
|
+
- User data
|
|
119
|
+
- Financial data
|
|
120
|
+
- Intellectual property
|
|
121
|
+
- System availability
|
|
122
|
+
- Reputation
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Step 2: Create Architecture Diagram
|
|
126
|
+
```
|
|
127
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
128
|
+
│ Users │────▶│ Web │────▶│ API │
|
|
129
|
+
│ │ │ App │ │ Server │
|
|
130
|
+
└─────────┘ └─────────┘ └────┬────┘
|
|
131
|
+
│
|
|
132
|
+
▼
|
|
133
|
+
┌─────────┐
|
|
134
|
+
│Database │
|
|
135
|
+
└─────────┘
|
|
136
|
+
|
|
137
|
+
Mark trust boundaries and data flows.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Step 3: Identify Threats
|
|
141
|
+
```
|
|
142
|
+
For each component and data flow:
|
|
143
|
+
1. Apply STRIDE
|
|
144
|
+
2. Identify specific threats
|
|
145
|
+
3. Assess likelihood and impact
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Step 4: Document Threats
|
|
149
|
+
```
|
|
150
|
+
| ID | Threat | STRIDE | Likelihood | Impact | Mitigation |
|
|
151
|
+
|----|--------|--------|------------|--------|------------|
|
|
152
|
+
| T1 | SQL injection | T | High | High | Parameterized queries |
|
|
153
|
+
| T2 | Credential theft | S | Medium | High | MFA, monitoring |
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Step 5: Prioritize and Plan
|
|
157
|
+
```
|
|
158
|
+
Risk = Likelihood × Impact
|
|
159
|
+
|
|
160
|
+
Priority 1: High likelihood, high impact
|
|
161
|
+
Priority 2: Medium likelihood, high impact
|
|
162
|
+
Priority 3: Low likelihood, high impact
|
|
163
|
+
...
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## DREAD Assessment
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
Score 1-10 for each:
|
|
170
|
+
D - Damage potential
|
|
171
|
+
R - Reproducibility
|
|
172
|
+
E - Exploitability
|
|
173
|
+
A - Affected users
|
|
174
|
+
D - Discoverability
|
|
175
|
+
|
|
176
|
+
Risk Score = (D+R+E+A+D) / 5
|
|
177
|
+
|
|
178
|
+
High: 8-10
|
|
179
|
+
Medium: 5-7
|
|
180
|
+
Low: 1-4
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Common Threats by Architecture
|
|
184
|
+
|
|
185
|
+
### Web Application
|
|
186
|
+
```
|
|
187
|
+
- XSS (Cross-Site Scripting)
|
|
188
|
+
- CSRF (Cross-Site Request Forgery)
|
|
189
|
+
- SQL Injection
|
|
190
|
+
- Session hijacking
|
|
191
|
+
- Brute force attacks
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### API
|
|
195
|
+
```
|
|
196
|
+
- Broken authentication
|
|
197
|
+
- Excessive data exposure
|
|
198
|
+
- Rate limiting bypass
|
|
199
|
+
- Injection attacks
|
|
200
|
+
- Improper asset management
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Microservices
|
|
204
|
+
```
|
|
205
|
+
- Service-to-service auth
|
|
206
|
+
- Secrets management
|
|
207
|
+
- Network eavesdropping
|
|
208
|
+
- Container vulnerabilities
|
|
209
|
+
- API gateway bypass
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Cloud
|
|
213
|
+
```
|
|
214
|
+
- Misconfigured resources
|
|
215
|
+
- Inadequate access controls
|
|
216
|
+
- Data exfiltration
|
|
217
|
+
- Insider threats
|
|
218
|
+
- Supply chain attacks
|
|
219
|
+
```
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: system-design
|
|
3
|
+
description: |
|
|
4
|
+
Use when designing distributed systems, understanding scalability patterns,
|
|
5
|
+
or making architecture decisions that involve multiple components.
|
|
6
|
+
Covers CAP theorem, consistency patterns, scalability strategies, and resilience patterns.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
category: architecture
|
|
9
|
+
tags:
|
|
10
|
+
- distributed-systems
|
|
11
|
+
- scalability
|
|
12
|
+
- resilience
|
|
13
|
+
- system-design
|
|
14
|
+
depends_on: []
|
|
15
|
+
recommends:
|
|
16
|
+
- architecture-patterns
|
|
17
|
+
- adr-writing
|
|
18
|
+
used_by:
|
|
19
|
+
- tech-selection
|
|
20
|
+
- architecture-patterns
|
|
21
|
+
- performance-engineering
|
|
22
|
+
- security-architecture
|
|
23
|
+
references:
|
|
24
|
+
- references/distributed-systems.md
|
|
25
|
+
- references/scalability.md
|
|
26
|
+
- references/resilience.md
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
# System Design
|
|
30
|
+
|
|
31
|
+
## Core Principle
|
|
32
|
+
**Design for failure, scale horizontally, and keep things simple until you need complexity.**
|
|
33
|
+
|
|
34
|
+
## When to Use This Skill
|
|
35
|
+
|
|
36
|
+
### Trigger Conditions
|
|
37
|
+
- Designing a new system or service
|
|
38
|
+
- Evaluating architecture for scalability
|
|
39
|
+
- Planning for high availability
|
|
40
|
+
- Reviewing system resilience
|
|
41
|
+
- Making technology decisions for infrastructure
|
|
42
|
+
|
|
43
|
+
### Keywords
|
|
44
|
+
- "design a system"
|
|
45
|
+
- "architecture for"
|
|
46
|
+
- "scalability"
|
|
47
|
+
- "high availability"
|
|
48
|
+
- "distributed system"
|
|
49
|
+
- "fault tolerance"
|
|
50
|
+
- "disaster recovery"
|
|
51
|
+
|
|
52
|
+
## Core Concepts
|
|
53
|
+
|
|
54
|
+
### 1. CAP Theorem
|
|
55
|
+
In distributed systems, you can only guarantee 2 of 3:
|
|
56
|
+
- **Consistency** - All nodes see same data at same time
|
|
57
|
+
- **Availability** - System always responds (may be stale data)
|
|
58
|
+
- **Partition Tolerance** - System continues despite network failures
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
CAP Theorem
|
|
62
|
+
│
|
|
63
|
+
┌───────┴───────┐
|
|
64
|
+
│ │
|
|
65
|
+
┌──┴──┐ ┌──┴──┐
|
|
66
|
+
│ C │ │ A │
|
|
67
|
+
└──┬──┘ └──┬──┘
|
|
68
|
+
│ ┌───┐ │
|
|
69
|
+
└────┤ P ├──────┘
|
|
70
|
+
└───┘
|
|
71
|
+
|
|
72
|
+
C + P = CP Systems (MongoDB, Redis, HBase)
|
|
73
|
+
A + P = AP Systems (Cassandra, DynamoDB, CouchDB)
|
|
74
|
+
C + A = CA Systems (RDBMS - not truly distributed)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Scalability Patterns
|
|
78
|
+
|
|
79
|
+
| Pattern | Description | Use Case |
|
|
80
|
+
|---------|-------------|----------|
|
|
81
|
+
| **Horizontal** | Add more machines | Web servers, stateless services |
|
|
82
|
+
| **Vertical** | Bigger machines | Databases (until sharding) |
|
|
83
|
+
| **Sharding** | Partition data | Large datasets, high write volume |
|
|
84
|
+
| **Read Replicas** | Copy for reads | Read-heavy workloads |
|
|
85
|
+
|
|
86
|
+
### 3. Consistency Patterns
|
|
87
|
+
|
|
88
|
+
| Pattern | Description | Trade-off |
|
|
89
|
+
|---------|-------------|-----------|
|
|
90
|
+
| **Strong** | Immediate consistency | Higher latency |
|
|
91
|
+
| **Eventual** | Converge over time | Stale reads possible |
|
|
92
|
+
| **Causal** | Preserve causality | Complex implementation |
|
|
93
|
+
|
|
94
|
+
### 4. Availability Patterns
|
|
95
|
+
|
|
96
|
+
| Pattern | Description | Use Case |
|
|
97
|
+
|---------|-------------|----------|
|
|
98
|
+
| **Active-Active** | All nodes serve traffic | Maximum availability |
|
|
99
|
+
| **Active-Passive** | Failover to standby | Simpler, lower cost |
|
|
100
|
+
| **Multi-Region** | Geographic distribution | Disaster recovery |
|
|
101
|
+
|
|
102
|
+
## Design Process
|
|
103
|
+
|
|
104
|
+
### Step 1: Requirements Gathering
|
|
105
|
+
```
|
|
106
|
+
Functional Requirements:
|
|
107
|
+
- What does the system do?
|
|
108
|
+
- Who are the users?
|
|
109
|
+
- What are the use cases?
|
|
110
|
+
|
|
111
|
+
Non-Functional Requirements:
|
|
112
|
+
- Scale: How many users/requests?
|
|
113
|
+
- Performance: What latency?
|
|
114
|
+
- Availability: What uptime SLA?
|
|
115
|
+
- Consistency: Strong vs eventual?
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Step 2: Capacity Estimation
|
|
119
|
+
```
|
|
120
|
+
Traffic Estimation:
|
|
121
|
+
- Daily Active Users (DAU)
|
|
122
|
+
- Requests per second (RPS)
|
|
123
|
+
- Read vs Write ratio
|
|
124
|
+
|
|
125
|
+
Storage Estimation:
|
|
126
|
+
- Data size per entity
|
|
127
|
+
- Growth rate
|
|
128
|
+
- Retention period
|
|
129
|
+
|
|
130
|
+
Bandwidth Estimation:
|
|
131
|
+
- Request/response sizes
|
|
132
|
+
- Peak vs average traffic
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Step 3: High-Level Design
|
|
136
|
+
```
|
|
137
|
+
1. Define system interfaces (API)
|
|
138
|
+
2. Create component diagram
|
|
139
|
+
3. Identify data flow
|
|
140
|
+
4. Choose data stores
|
|
141
|
+
5. Define communication patterns
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Step 4: Deep Dive
|
|
145
|
+
```
|
|
146
|
+
For each component:
|
|
147
|
+
- Algorithm choice
|
|
148
|
+
- Data model
|
|
149
|
+
- Scaling strategy
|
|
150
|
+
- Failure handling
|
|
151
|
+
- Monitoring needs
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Common System Design Templates
|
|
155
|
+
|
|
156
|
+
### 1. Web Application
|
|
157
|
+
```
|
|
158
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
159
|
+
│ Client │───▶│ LB │───▶│ API │───▶│ DB │
|
|
160
|
+
│ (Web) │ │ │ │ Server │ │ │
|
|
161
|
+
└─────────┘ └─────────┘ └─────────┘ └─────────┘
|
|
162
|
+
│
|
|
163
|
+
▼
|
|
164
|
+
┌─────────┐
|
|
165
|
+
│ Cache │
|
|
166
|
+
│ (Redis) │
|
|
167
|
+
└─────────┘
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 2. Real-time System
|
|
171
|
+
```
|
|
172
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
173
|
+
│ Client │◀──▶│WebSocket│───▶│ Message │───▶│ Workers │
|
|
174
|
+
│ │ │ Server │ │ Queue │ │ │
|
|
175
|
+
└─────────┘ └─────────┘ └─────────┘ └─────────┘
|
|
176
|
+
│
|
|
177
|
+
▼
|
|
178
|
+
┌─────────┐
|
|
179
|
+
│ DB │
|
|
180
|
+
└─────────┘
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 3. Microservices
|
|
184
|
+
```
|
|
185
|
+
┌─────────┐ ┌─────────────────────────────────────┐
|
|
186
|
+
│ Gateway │───▶│ Service Mesh │
|
|
187
|
+
└─────────┘ │ ┌───────┐ ┌───────┐ ┌───────┐ │
|
|
188
|
+
│ │ Svc A │ │ Svc B │ │ Svc C │ │
|
|
189
|
+
│ └───┬───┘ └───┬───┘ └───┬───┘ │
|
|
190
|
+
└──────┼─────────┼─────────┼────────┘
|
|
191
|
+
│ │ │
|
|
192
|
+
▼ ▼ ▼
|
|
193
|
+
┌─────┐ ┌─────┐ ┌─────┐
|
|
194
|
+
│ DB1 │ │ DB2 │ │ DB3 │
|
|
195
|
+
└─────┘ └─────┘ └─────┘
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Rules
|
|
199
|
+
|
|
200
|
+
### DO
|
|
201
|
+
- ✅ Start simple, add complexity as needed
|
|
202
|
+
- ✅ Design for failure (circuit breakers, retries)
|
|
203
|
+
- ✅ Use caching strategically
|
|
204
|
+
- ✅ Plan for horizontal scaling
|
|
205
|
+
- ✅ Monitor everything
|
|
206
|
+
- ✅ Document decisions
|
|
207
|
+
|
|
208
|
+
### DON'T
|
|
209
|
+
- ❌ Over-engineer for scale you don't have
|
|
210
|
+
- ❌ Ignore operational concerns
|
|
211
|
+
- ❌ Skip capacity planning
|
|
212
|
+
- ❌ Forget about security
|
|
213
|
+
- ❌ Make everything distributed
|
|
214
|
+
|
|
215
|
+
## Output
|
|
216
|
+
|
|
217
|
+
When using this skill, produce:
|
|
218
|
+
1. **System Design Document** - High-level architecture
|
|
219
|
+
2. **Component Diagram** - Visual representation
|
|
220
|
+
3. **Data Flow Diagram** - How data moves
|
|
221
|
+
4. **Capacity Estimates** - Resource requirements
|
|
222
|
+
5. **ADR** - Key decisions documented
|
|
223
|
+
|
|
224
|
+
## Related Skills
|
|
225
|
+
- `architecture-patterns` - Specific architecture styles
|
|
226
|
+
- `tech-selection` - Technology choices
|
|
227
|
+
- `performance-engineering` - Optimization strategies
|