specweave 0.3.13 → 0.4.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 (112) hide show
  1. package/CLAUDE.md +17 -1
  2. package/README.md +1 -1
  3. package/bin/install-all.sh +9 -2
  4. package/bin/install-hooks.sh +57 -0
  5. package/dist/cli/commands/init.d.ts.map +1 -1
  6. package/dist/cli/commands/init.js +55 -0
  7. package/dist/cli/commands/init.js.map +1 -1
  8. package/dist/core/agent-model-manager.d.ts +52 -0
  9. package/dist/core/agent-model-manager.d.ts.map +1 -0
  10. package/dist/core/agent-model-manager.js +120 -0
  11. package/dist/core/agent-model-manager.js.map +1 -0
  12. package/dist/core/cost-tracker.d.ts +108 -0
  13. package/dist/core/cost-tracker.d.ts.map +1 -0
  14. package/dist/core/cost-tracker.js +281 -0
  15. package/dist/core/cost-tracker.js.map +1 -0
  16. package/dist/core/model-selector.d.ts +57 -0
  17. package/dist/core/model-selector.d.ts.map +1 -0
  18. package/dist/core/model-selector.js +115 -0
  19. package/dist/core/model-selector.js.map +1 -0
  20. package/dist/core/phase-detector.d.ts +62 -0
  21. package/dist/core/phase-detector.d.ts.map +1 -0
  22. package/dist/core/phase-detector.js +229 -0
  23. package/dist/core/phase-detector.js.map +1 -0
  24. package/dist/types/cost-tracking.d.ts +43 -0
  25. package/dist/types/cost-tracking.d.ts.map +1 -0
  26. package/dist/types/cost-tracking.js +8 -0
  27. package/dist/types/cost-tracking.js.map +1 -0
  28. package/dist/types/model-selection.d.ts +53 -0
  29. package/dist/types/model-selection.d.ts.map +1 -0
  30. package/dist/types/model-selection.js +12 -0
  31. package/dist/types/model-selection.js.map +1 -0
  32. package/dist/utils/cost-reporter.d.ts +58 -0
  33. package/dist/utils/cost-reporter.d.ts.map +1 -0
  34. package/dist/utils/cost-reporter.js +224 -0
  35. package/dist/utils/cost-reporter.js.map +1 -0
  36. package/dist/utils/pricing-constants.d.ts +70 -0
  37. package/dist/utils/pricing-constants.d.ts.map +1 -0
  38. package/dist/utils/pricing-constants.js +71 -0
  39. package/dist/utils/pricing-constants.js.map +1 -0
  40. package/package.json +1 -1
  41. package/src/agents/architect/AGENT.md +3 -0
  42. package/src/agents/code-reviewer.md +156 -0
  43. package/src/agents/data-scientist/AGENT.md +181 -0
  44. package/src/agents/database-optimizer/AGENT.md +147 -0
  45. package/src/agents/devops/AGENT.md +3 -0
  46. package/src/agents/diagrams-architect/AGENT.md +3 -0
  47. package/src/agents/docs-writer/AGENT.md +3 -0
  48. package/src/agents/kubernetes-architect/AGENT.md +142 -0
  49. package/src/agents/ml-engineer/AGENT.md +150 -0
  50. package/src/agents/mlops-engineer/AGENT.md +201 -0
  51. package/src/agents/network-engineer/AGENT.md +149 -0
  52. package/src/agents/observability-engineer/AGENT.md +213 -0
  53. package/src/agents/payment-integration/AGENT.md +35 -0
  54. package/src/agents/performance/AGENT.md +3 -0
  55. package/src/agents/performance-engineer/AGENT.md +153 -0
  56. package/src/agents/pm/AGENT.md +3 -0
  57. package/src/agents/qa-lead/AGENT.md +3 -0
  58. package/src/agents/security/AGENT.md +3 -0
  59. package/src/agents/sre/AGENT.md +3 -0
  60. package/src/agents/tdd-orchestrator/AGENT.md +169 -0
  61. package/src/agents/tech-lead/AGENT.md +3 -0
  62. package/src/commands/specweave.costs.md +261 -0
  63. package/src/commands/specweave.ml-pipeline.md +292 -0
  64. package/src/commands/specweave.monitor-setup.md +501 -0
  65. package/src/commands/specweave.slo-implement.md +1055 -0
  66. package/src/commands/specweave.sync-github.md +1 -1
  67. package/src/commands/specweave.tdd-cycle.md +199 -0
  68. package/src/commands/specweave.tdd-green.md +842 -0
  69. package/src/commands/specweave.tdd-red.md +135 -0
  70. package/src/commands/specweave.tdd-refactor.md +165 -0
  71. package/src/skills/SKILLS-INDEX.md +18 -10
  72. package/src/skills/billing-automation/SKILL.md +559 -0
  73. package/src/skills/distributed-tracing/SKILL.md +438 -0
  74. package/src/skills/e2e-playwright/README.md +1 -1
  75. package/src/skills/e2e-playwright/package.json +1 -1
  76. package/src/skills/gitops-workflow/SKILL.md +285 -0
  77. package/src/skills/gitops-workflow/references/argocd-setup.md +134 -0
  78. package/src/skills/gitops-workflow/references/sync-policies.md +131 -0
  79. package/src/skills/grafana-dashboards/SKILL.md +369 -0
  80. package/src/skills/helm-chart-scaffolding/SKILL.md +544 -0
  81. package/src/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
  82. package/src/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
  83. package/src/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
  84. package/src/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
  85. package/src/skills/k8s-manifest-generator/SKILL.md +511 -0
  86. package/src/skills/k8s-manifest-generator/assets/configmap-template.yaml +296 -0
  87. package/src/skills/k8s-manifest-generator/assets/deployment-template.yaml +203 -0
  88. package/src/skills/k8s-manifest-generator/assets/service-template.yaml +171 -0
  89. package/src/skills/k8s-manifest-generator/references/deployment-spec.md +753 -0
  90. package/src/skills/k8s-manifest-generator/references/service-spec.md +724 -0
  91. package/src/skills/k8s-security-policies/SKILL.md +334 -0
  92. package/src/skills/k8s-security-policies/assets/network-policy-template.yaml +177 -0
  93. package/src/skills/k8s-security-policies/references/rbac-patterns.md +187 -0
  94. package/src/skills/ml-pipeline-workflow/SKILL.md +245 -0
  95. package/src/skills/paypal-integration/SKILL.md +467 -0
  96. package/src/skills/pci-compliance/SKILL.md +466 -0
  97. package/src/skills/prometheus-configuration/SKILL.md +392 -0
  98. package/src/skills/slo-implementation/SKILL.md +329 -0
  99. package/src/skills/stripe-integration/SKILL.md +442 -0
  100. package/src/skills/tdd-workflow/SKILL.md +378 -0
  101. package/src/templates/README.md.template +1 -1
  102. package/src/skills/bmad-method-expert/SKILL.md +0 -626
  103. package/src/skills/bmad-method-expert/scripts/analyze-project.js +0 -318
  104. package/src/skills/bmad-method-expert/scripts/check-setup.js +0 -208
  105. package/src/skills/bmad-method-expert/scripts/generate-template.js +0 -1149
  106. package/src/skills/bmad-method-expert/scripts/validate-documents.js +0 -340
  107. package/src/skills/context-optimizer/SKILL.md +0 -588
  108. package/src/skills/figma-designer/SKILL.md +0 -149
  109. package/src/skills/figma-implementer/SKILL.md +0 -148
  110. package/src/skills/figma-mcp-connector/SKILL.md +0 -136
  111. package/src/skills/figma-to-code/SKILL.md +0 -128
  112. package/src/skills/spec-kit-expert/SKILL.md +0 -1010
@@ -0,0 +1,466 @@
1
+ ---
2
+ name: pci-compliance
3
+ description: Implement PCI DSS compliance requirements for secure handling of payment card data and payment systems. Use when securing payment processing, achieving PCI compliance, or implementing payment card security measures.
4
+ ---
5
+
6
+ # PCI Compliance
7
+
8
+ Master PCI DSS (Payment Card Industry Data Security Standard) compliance for secure payment processing and handling of cardholder data.
9
+
10
+ ## When to Use This Skill
11
+
12
+ - Building payment processing systems
13
+ - Handling credit card information
14
+ - Implementing secure payment flows
15
+ - Conducting PCI compliance audits
16
+ - Reducing PCI compliance scope
17
+ - Implementing tokenization and encryption
18
+ - Preparing for PCI DSS assessments
19
+
20
+ ## PCI DSS Requirements (12 Core Requirements)
21
+
22
+ ### Build and Maintain Secure Network
23
+ 1. Install and maintain firewall configuration
24
+ 2. Don't use vendor-supplied defaults for passwords
25
+
26
+ ### Protect Cardholder Data
27
+ 3. Protect stored cardholder data
28
+ 4. Encrypt transmission of cardholder data across public networks
29
+
30
+ ### Maintain Vulnerability Management
31
+ 5. Protect systems against malware
32
+ 6. Develop and maintain secure systems and applications
33
+
34
+ ### Implement Strong Access Control
35
+ 7. Restrict access to cardholder data by business need-to-know
36
+ 8. Identify and authenticate access to system components
37
+ 9. Restrict physical access to cardholder data
38
+
39
+ ### Monitor and Test Networks
40
+ 10. Track and monitor all access to network resources and cardholder data
41
+ 11. Regularly test security systems and processes
42
+
43
+ ### Maintain Information Security Policy
44
+ 12. Maintain a policy that addresses information security
45
+
46
+ ## Compliance Levels
47
+
48
+ **Level 1**: > 6 million transactions/year (annual ROC required)
49
+ **Level 2**: 1-6 million transactions/year (annual SAQ)
50
+ **Level 3**: 20,000-1 million e-commerce transactions/year
51
+ **Level 4**: < 20,000 e-commerce or < 1 million total transactions
52
+
53
+ ## Data Minimization (Never Store)
54
+
55
+ ```python
56
+ # NEVER STORE THESE
57
+ PROHIBITED_DATA = {
58
+ 'full_track_data': 'Magnetic stripe data',
59
+ 'cvv': 'Card verification code/value',
60
+ 'pin': 'PIN or PIN block'
61
+ }
62
+
63
+ # CAN STORE (if encrypted)
64
+ ALLOWED_DATA = {
65
+ 'pan': 'Primary Account Number (card number)',
66
+ 'cardholder_name': 'Name on card',
67
+ 'expiration_date': 'Card expiration',
68
+ 'service_code': 'Service code'
69
+ }
70
+
71
+ class PaymentData:
72
+ """Safe payment data handling."""
73
+
74
+ def __init__(self):
75
+ self.prohibited_fields = ['cvv', 'cvv2', 'cvc', 'pin']
76
+
77
+ def sanitize_log(self, data):
78
+ """Remove sensitive data from logs."""
79
+ sanitized = data.copy()
80
+
81
+ # Mask PAN
82
+ if 'card_number' in sanitized:
83
+ card = sanitized['card_number']
84
+ sanitized['card_number'] = f"{card[:6]}{'*' * (len(card) - 10)}{card[-4:]}"
85
+
86
+ # Remove prohibited data
87
+ for field in self.prohibited_fields:
88
+ sanitized.pop(field, None)
89
+
90
+ return sanitized
91
+
92
+ def validate_no_prohibited_storage(self, data):
93
+ """Ensure no prohibited data is being stored."""
94
+ for field in self.prohibited_fields:
95
+ if field in data:
96
+ raise SecurityError(f"Attempting to store prohibited field: {field}")
97
+ ```
98
+
99
+ ## Tokenization
100
+
101
+ ### Using Payment Processor Tokens
102
+ ```python
103
+ import stripe
104
+
105
+ class TokenizedPayment:
106
+ """Handle payments using tokens (no card data on server)."""
107
+
108
+ @staticmethod
109
+ def create_payment_method_token(card_details):
110
+ """Create token from card details (client-side only)."""
111
+ # THIS SHOULD ONLY BE DONE CLIENT-SIDE WITH STRIPE.JS
112
+ # NEVER send card details to your server
113
+
114
+ """
115
+ // Frontend JavaScript
116
+ const stripe = Stripe('pk_...');
117
+
118
+ const {token, error} = await stripe.createToken({
119
+ card: {
120
+ number: '4242424242424242',
121
+ exp_month: 12,
122
+ exp_year: 2024,
123
+ cvc: '123'
124
+ }
125
+ });
126
+
127
+ // Send token.id to server (NOT card details)
128
+ """
129
+ pass
130
+
131
+ @staticmethod
132
+ def charge_with_token(token_id, amount):
133
+ """Charge using token (server-side)."""
134
+ # Your server only sees the token, never the card number
135
+ stripe.api_key = "sk_..."
136
+
137
+ charge = stripe.Charge.create(
138
+ amount=amount,
139
+ currency="usd",
140
+ source=token_id, # Token instead of card details
141
+ description="Payment"
142
+ )
143
+
144
+ return charge
145
+
146
+ @staticmethod
147
+ def store_payment_method(customer_id, payment_method_token):
148
+ """Store payment method as token for future use."""
149
+ stripe.Customer.modify(
150
+ customer_id,
151
+ source=payment_method_token
152
+ )
153
+
154
+ # Store only customer_id and payment_method_id in your database
155
+ # NEVER store actual card details
156
+ return {
157
+ 'customer_id': customer_id,
158
+ 'has_payment_method': True
159
+ # DO NOT store: card number, CVV, etc.
160
+ }
161
+ ```
162
+
163
+ ### Custom Tokenization (Advanced)
164
+ ```python
165
+ import secrets
166
+ from cryptography.fernet import Fernet
167
+
168
+ class TokenVault:
169
+ """Secure token vault for card data (if you must store it)."""
170
+
171
+ def __init__(self, encryption_key):
172
+ self.cipher = Fernet(encryption_key)
173
+ self.vault = {} # In production: use encrypted database
174
+
175
+ def tokenize(self, card_data):
176
+ """Convert card data to token."""
177
+ # Generate secure random token
178
+ token = secrets.token_urlsafe(32)
179
+
180
+ # Encrypt card data
181
+ encrypted = self.cipher.encrypt(json.dumps(card_data).encode())
182
+
183
+ # Store token -> encrypted data mapping
184
+ self.vault[token] = encrypted
185
+
186
+ return token
187
+
188
+ def detokenize(self, token):
189
+ """Retrieve card data from token."""
190
+ encrypted = self.vault.get(token)
191
+ if not encrypted:
192
+ raise ValueError("Token not found")
193
+
194
+ # Decrypt
195
+ decrypted = self.cipher.decrypt(encrypted)
196
+ return json.loads(decrypted.decode())
197
+
198
+ def delete_token(self, token):
199
+ """Remove token from vault."""
200
+ self.vault.pop(token, None)
201
+ ```
202
+
203
+ ## Encryption
204
+
205
+ ### Data at Rest
206
+ ```python
207
+ from cryptography.hazmat.primitives.ciphers.aead import AESGCM
208
+ import os
209
+
210
+ class EncryptedStorage:
211
+ """Encrypt data at rest using AES-256-GCM."""
212
+
213
+ def __init__(self, encryption_key):
214
+ """Initialize with 256-bit key."""
215
+ self.key = encryption_key # Must be 32 bytes
216
+
217
+ def encrypt(self, plaintext):
218
+ """Encrypt data."""
219
+ # Generate random nonce
220
+ nonce = os.urandom(12)
221
+
222
+ # Encrypt
223
+ aesgcm = AESGCM(self.key)
224
+ ciphertext = aesgcm.encrypt(nonce, plaintext.encode(), None)
225
+
226
+ # Return nonce + ciphertext
227
+ return nonce + ciphertext
228
+
229
+ def decrypt(self, encrypted_data):
230
+ """Decrypt data."""
231
+ # Extract nonce and ciphertext
232
+ nonce = encrypted_data[:12]
233
+ ciphertext = encrypted_data[12:]
234
+
235
+ # Decrypt
236
+ aesgcm = AESGCM(self.key)
237
+ plaintext = aesgcm.decrypt(nonce, ciphertext, None)
238
+
239
+ return plaintext.decode()
240
+
241
+ # Usage
242
+ storage = EncryptedStorage(os.urandom(32))
243
+ encrypted_pan = storage.encrypt("4242424242424242")
244
+ # Store encrypted_pan in database
245
+ ```
246
+
247
+ ### Data in Transit
248
+ ```python
249
+ # Always use TLS 1.2 or higher
250
+ # Flask/Django example
251
+ app.config['SESSION_COOKIE_SECURE'] = True # HTTPS only
252
+ app.config['SESSION_COOKIE_HTTPONLY'] = True
253
+ app.config['SESSION_COOKIE_SAMESITE'] = 'Strict'
254
+
255
+ # Enforce HTTPS
256
+ from flask_talisman import Talisman
257
+ Talisman(app, force_https=True)
258
+ ```
259
+
260
+ ## Access Control
261
+
262
+ ```python
263
+ from functools import wraps
264
+ from flask import session
265
+
266
+ def require_pci_access(f):
267
+ """Decorator to restrict access to cardholder data."""
268
+ @wraps(f)
269
+ def decorated_function(*args, **kwargs):
270
+ user = session.get('user')
271
+
272
+ # Check if user has PCI access role
273
+ if not user or 'pci_access' not in user.get('roles', []):
274
+ return {'error': 'Unauthorized access to cardholder data'}, 403
275
+
276
+ # Log access attempt
277
+ audit_log(
278
+ user=user['id'],
279
+ action='access_cardholder_data',
280
+ resource=f.__name__
281
+ )
282
+
283
+ return f(*args, **kwargs)
284
+
285
+ return decorated_function
286
+
287
+ @app.route('/api/payment-methods')
288
+ @require_pci_access
289
+ def get_payment_methods():
290
+ """Retrieve payment methods (restricted access)."""
291
+ # Only accessible to users with pci_access role
292
+ pass
293
+ ```
294
+
295
+ ## Audit Logging
296
+
297
+ ```python
298
+ import logging
299
+ from datetime import datetime
300
+
301
+ class PCIAuditLogger:
302
+ """PCI-compliant audit logging."""
303
+
304
+ def __init__(self):
305
+ self.logger = logging.getLogger('pci_audit')
306
+ # Configure to write to secure, append-only log
307
+
308
+ def log_access(self, user_id, resource, action, result):
309
+ """Log access to cardholder data."""
310
+ entry = {
311
+ 'timestamp': datetime.utcnow().isoformat(),
312
+ 'user_id': user_id,
313
+ 'resource': resource,
314
+ 'action': action,
315
+ 'result': result,
316
+ 'ip_address': request.remote_addr
317
+ }
318
+
319
+ self.logger.info(json.dumps(entry))
320
+
321
+ def log_authentication(self, user_id, success, method):
322
+ """Log authentication attempt."""
323
+ entry = {
324
+ 'timestamp': datetime.utcnow().isoformat(),
325
+ 'user_id': user_id,
326
+ 'event': 'authentication',
327
+ 'success': success,
328
+ 'method': method,
329
+ 'ip_address': request.remote_addr
330
+ }
331
+
332
+ self.logger.info(json.dumps(entry))
333
+
334
+ # Usage
335
+ audit = PCIAuditLogger()
336
+ audit.log_access(user_id=123, resource='payment_methods', action='read', result='success')
337
+ ```
338
+
339
+ ## Security Best Practices
340
+
341
+ ### Input Validation
342
+ ```python
343
+ import re
344
+
345
+ def validate_card_number(card_number):
346
+ """Validate card number format (Luhn algorithm)."""
347
+ # Remove spaces and dashes
348
+ card_number = re.sub(r'[\s-]', '', card_number)
349
+
350
+ # Check if all digits
351
+ if not card_number.isdigit():
352
+ return False
353
+
354
+ # Luhn algorithm
355
+ def luhn_checksum(card_num):
356
+ def digits_of(n):
357
+ return [int(d) for d in str(n)]
358
+
359
+ digits = digits_of(card_num)
360
+ odd_digits = digits[-1::-2]
361
+ even_digits = digits[-2::-2]
362
+ checksum = sum(odd_digits)
363
+ for d in even_digits:
364
+ checksum += sum(digits_of(d * 2))
365
+ return checksum % 10
366
+
367
+ return luhn_checksum(card_number) == 0
368
+
369
+ def sanitize_input(user_input):
370
+ """Sanitize user input to prevent injection."""
371
+ # Remove special characters
372
+ # Validate against expected format
373
+ # Escape for database queries
374
+ pass
375
+ ```
376
+
377
+ ## PCI DSS SAQ (Self-Assessment Questionnaire)
378
+
379
+ ### SAQ A (Least Requirements)
380
+ - E-commerce using hosted payment page
381
+ - No card data on your systems
382
+ - ~20 questions
383
+
384
+ ### SAQ A-EP
385
+ - E-commerce with embedded payment form
386
+ - Uses JavaScript to handle card data
387
+ - ~180 questions
388
+
389
+ ### SAQ D (Most Requirements)
390
+ - Store, process, or transmit card data
391
+ - Full PCI DSS requirements
392
+ - ~300 questions
393
+
394
+ ## Compliance Checklist
395
+
396
+ ```python
397
+ PCI_COMPLIANCE_CHECKLIST = {
398
+ 'network_security': [
399
+ 'Firewall configured and maintained',
400
+ 'No vendor default passwords',
401
+ 'Network segmentation implemented'
402
+ ],
403
+ 'data_protection': [
404
+ 'No storage of CVV, track data, or PIN',
405
+ 'PAN encrypted when stored',
406
+ 'PAN masked when displayed',
407
+ 'Encryption keys properly managed'
408
+ ],
409
+ 'vulnerability_management': [
410
+ 'Anti-virus installed and updated',
411
+ 'Secure development practices',
412
+ 'Regular security patches',
413
+ 'Vulnerability scanning performed'
414
+ ],
415
+ 'access_control': [
416
+ 'Access restricted by role',
417
+ 'Unique IDs for all users',
418
+ 'Multi-factor authentication',
419
+ 'Physical security measures'
420
+ ],
421
+ 'monitoring': [
422
+ 'Audit logs enabled',
423
+ 'Log review process',
424
+ 'File integrity monitoring',
425
+ 'Regular security testing'
426
+ ],
427
+ 'policy': [
428
+ 'Security policy documented',
429
+ 'Risk assessment performed',
430
+ 'Security awareness training',
431
+ 'Incident response plan'
432
+ ]
433
+ }
434
+ ```
435
+
436
+ ## Resources
437
+
438
+ - **references/data-minimization.md**: Never store prohibited data
439
+ - **references/tokenization.md**: Tokenization strategies
440
+ - **references/encryption.md**: Encryption requirements
441
+ - **references/access-control.md**: Role-based access
442
+ - **references/audit-logging.md**: Comprehensive logging
443
+ - **assets/pci-compliance-checklist.md**: Complete checklist
444
+ - **assets/encrypted-storage.py**: Encryption utilities
445
+ - **scripts/audit-payment-system.sh**: Compliance audit script
446
+
447
+ ## Common Violations
448
+
449
+ 1. **Storing CVV**: Never store card verification codes
450
+ 2. **Unencrypted PAN**: Card numbers must be encrypted at rest
451
+ 3. **Weak Encryption**: Use AES-256 or equivalent
452
+ 4. **No Access Controls**: Restrict who can access cardholder data
453
+ 5. **Missing Audit Logs**: Must log all access to payment data
454
+ 6. **Insecure Transmission**: Always use TLS 1.2+
455
+ 7. **Default Passwords**: Change all default credentials
456
+ 8. **No Security Testing**: Regular penetration testing required
457
+
458
+ ## Reducing PCI Scope
459
+
460
+ 1. **Use Hosted Payments**: Stripe Checkout, PayPal, etc.
461
+ 2. **Tokenization**: Replace card data with tokens
462
+ 3. **Network Segmentation**: Isolate cardholder data environment
463
+ 4. **Outsource**: Use PCI-compliant payment processors
464
+ 5. **No Storage**: Never store full card details
465
+
466
+ By minimizing systems that touch card data, you reduce compliance burden significantly.