specwright/templates/skills/dev-team/architect/security-guidance/SKILL.md
# Security Guidance Skill > Skill: Security Guidance > Role: Architect > Created: 2026-01-09 > Version: 1.0.0 ## Purpose Provides security expertise and guidance across all aspects of application development. Identifies vulnerabilities, recommends security best practices, and ensures secure architecture and implementation patterns. ## When to Activate This Skill **Trigger Conditions:** - Authentication/authorization design - Data handling and storage decisions - API security review - Third-
npx skillsauth add michsindlinger/specwright specwright/templates/skills/dev-team/architect/security-guidanceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Skill: Security Guidance Role: Architect Created: 2026-01-09 Version: 1.0.0
Provides security expertise and guidance across all aspects of application development. Identifies vulnerabilities, recommends security best practices, and ensures secure architecture and implementation patterns.
Trigger Conditions:
Context Signals:
[TECH_STACK_SPECIFIC]
[TECH_STACK_SPECIFIC]
[TECH_STACK_SPECIFIC]
[TECH_STACK_SPECIFIC]
[TECH_STACK_SPECIFIC]
[MCP_TOOLS]
<!-- Populated during skill creation based on: 1. User's installed MCP servers 2. User's selection for this skill Recommended for this skill (examples): - security-scanner - Automated vulnerability scanning - secrets-detector - Find exposed secrets in code - [TECH_STACK_SPECIFIC] - Framework security tools Note: Skills work without MCP servers, but functionality may be limited -->Scenario: Design secure password storage
Implementation:
[TECH_STACK_SPECIFIC]
BAD - Plain text or weak hashing:
password = request.POST['password']
user.password = hashlib.md5(password).hexdigest() # INSECURE!
GOOD - Strong hashing with salt:
from bcrypt import hashpw, gensalt
# Storing password
password = request.POST['password']
user.password_hash = hashpw(password.encode('utf-8'), gensalt(rounds=12))
# Verifying password
def verify_password(user, password):
return hashpw(password.encode('utf-8'), user.password_hash) == user.password_hash
REQUIREMENTS:
- Use bcrypt, Argon2, or scrypt
- Minimum work factor/rounds: 12 for bcrypt
- Never store plain text passwords
- Salt is handled automatically by bcrypt
- Pepper (secret key) can be added for extra security
Scenario: Implement resource-level authorization
Implementation:
[TECH_STACK_SPECIFIC]
# Policy-based authorization
class PostPolicy:
def __init__(self, user, post):
self.user = user
self.post = post
def can_update(self):
return (
self.user.is_admin() or
self.post.author_id == self.user.id
)
def can_delete(self):
return self.user.is_admin()
# In controller
def update_post(request, post_id):
post = Post.find(post_id)
policy = PostPolicy(request.user, post)
if not policy.can_update():
return forbidden("You cannot update this post")
# Proceed with update
post.update(request.POST)
return success(post)
PRINCIPLES:
- Check authorization on every protected action
- Centralize authorization logic in policy classes
- Fail closed (deny by default)
- Log authorization failures
- Don't leak resource existence in error messages
Scenario: Configure security headers for API responses
Implementation:
[TECH_STACK_SPECIFIC]
# Security headers middleware
SECURITY_HEADERS = {
# Prevent clickjacking
'X-Frame-Options': 'DENY',
# XSS Protection
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
# Content Security Policy
'Content-Security-Policy': "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'",
# Force HTTPS
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
# Referrer Policy
'Referrer-Policy': 'strict-origin-when-cross-origin',
# Permissions Policy
'Permissions-Policy': 'geolocation=(), microphone=(), camera=()'
}
# CORS Configuration
CORS_CONFIG = {
'allowed_origins': ['https://app.example.com'],
'allowed_methods': ['GET', 'POST', 'PUT', 'DELETE'],
'allowed_headers': ['Content-Type', 'Authorization'],
'expose_headers': ['X-Request-ID'],
'max_age': 3600,
'allow_credentials': True
}
Scenario: Handle and store PII securely
Implementation:
[TECH_STACK_SPECIFIC]
# Encrypt sensitive fields
class User:
# Public fields
id = Column(Integer, primary_key=True)
email = Column(String, unique=True)
# Encrypted fields
ssn_encrypted = Column(LargeBinary)
phone_encrypted = Column(LargeBinary)
@property
def ssn(self):
if self.ssn_encrypted:
return decrypt(self.ssn_encrypted)
return None
@ssn.setter
def ssn(self, value):
self.ssn_encrypted = encrypt(value)
# Masking for logs/display
def masked_ssn(self):
if self.ssn:
return f"***-**-{self.ssn[-4:]}"
return None
# Logging - never log sensitive data
def log_user_action(user, action):
logger.info(f"User {user.id} performed {action}")
# DON'T: logger.info(f"User {user.email} SSN:{user.ssn}")
# Database queries - use parameterized queries
# GOOD:
User.query.filter(User.email == email).first()
# BAD (SQL Injection risk):
db.execute(f"SELECT * FROM users WHERE email = '{email}'")
PRINCIPLES:
- Encrypt PII at rest
- Mask/redact in logs and error messages
- Minimize PII collection (data minimization)
- Implement right to deletion (GDPR)
- Use parameterized queries always
- Audit access to sensitive data
Scenario: Securely manage API keys and credentials
Implementation:
[TECH_STACK_SPECIFIC]
# Environment-based secrets (development)
# .env (NOT in version control)
DATABASE_URL=postgresql://user:pass@localhost/db
API_KEY=sk_live_abc123xyz
JWT_SECRET=random-secret-string-here
# Code
import os
api_key = os.environ.get('API_KEY')
# Production secrets management
# Use cloud provider secret managers:
# - AWS Secrets Manager
# - Google Cloud Secret Manager
# - Azure Key Vault
# - HashiCorp Vault
# Accessing secrets in production
from cloud_secrets import get_secret
api_key = get_secret('api-key')
CHECKLIST:
✗ Never commit secrets to git
✗ Never hardcode secrets in code
✗ Never log secrets
✓ Use environment variables in development
✓ Use secret managers in production
✓ Rotate secrets regularly
✓ Use different secrets per environment
✓ Audit secret access
✓ Encrypt secrets at rest
# .gitignore
.env
.env.*
secrets/
credentials.json
*.pem
*.key
1. IDENTIFY: Security requirements and constraints
2. ASSESS: Current implementation or design
3. ANALYZE: Potential vulnerabilities and risks
4. RECOMMEND: Security improvements and best practices
5. PRIORITIZE: Risks by severity and likelihood
6. DOCUMENT: Security decisions and rationale
7. VALIDATE: Implementation against security standards
8. MONITOR: Ongoing security posture
tools
Session Handoff: Erstellt eine vollständige Zusammenfassung der aktuellen Session für einen sauberen Kontextwechsel. NUR bei explizitem Aufruf (/session-handoff). NICHT automatisch auslösen. Geeignet wenn der User die Session resetten will, den Kontext aufräumen will, oder bei ~120k Tokens angelangt ist.
development
Pre-Mortem Risk Analysis: Strukturierte Prospective-Hindsight-Übung um launch-blocking Risiken vor Commitment aufzudecken. Team stellt sich vor, das Produkt sei 14 Tage nach Launch gefloppt, und arbeitet rückwärts. Klassifiziert Risiken in Tigers (echt), Paper Tigers (hypothetisch), Elephants (unausgesprochen). Nutze diesen Skill vor Build-Commitment, bei zu hoher Stakeholder-Confidence, vor Major-Releases, oder wenn das Team vage Sorgen nicht artikulieren kann. Trigger: /pre-mortem, 'pre-mortem', 'risk analysis', 'was könnte schiefgehen', 'risiken vor launch'.
testing
Six-Sigma Atomicity Validator for create-spec stories
tools
UX pattern definition guidance for navigation, user flows, interactions, and accessibility