architect/security-architecture/SKILL.md
--- name: security-architecture description: Use this skill whenever the architect subagent is asked to review security, design authentication or authorization, assess threats, define a security model, handle sensitive data, or evaluate compliance requirements. Triggers on: "security architecture", "auth design", "authentication strategy", "threat model", "security review", "how do we secure", "data protection", "compliance", "GDPR", "SOC2", "zero trust". Always use this skill when security is i
npx skillsauth add achreftlili/deep-dev-skills architect/security-architectureInstall 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.
Embed security into architecture from the start — not as an afterthought. Produce threat-aware designs with clear, implementable security controls.
For every system, identify threats across these 6 categories:
| Threat | Question to ask | Example | |--------|----------------|---------| | Spoofing | Can someone pretend to be another user/service? | Weak auth tokens | | Tampering | Can data be modified in transit or at rest? | No request signing | | Repudiation | Can actions be denied? No audit trail? | Missing audit logs | | Information Disclosure | Can sensitive data leak? | Over-permissive API | | Denial of Service | Can the system be overwhelmed? | No rate limiting | | Elevation of Privilege | Can a user access more than allowed? | Broken authorization |
Produce a threat table for the system:
| Threat | Component | Risk (H/M/L) | Mitigation | |--------|-----------|--------------|------------| | Spoofing | API Gateway | High | JWT with short expiry + refresh tokens | | DoS | Public endpoints | Medium | Rate limiting per IP + per user |
| Scenario | Recommended approach | |----------|---------------------| | User-facing web/mobile app | OAuth2 + OIDC with a provider (Auth0, Cognito, Clerk) | | Service-to-service (internal) | mTLS or signed JWTs with short TTL | | Third-party API access | API keys with scopes | | Machine-to-machine | Client credentials flow (OAuth2) |
Never build your own auth from scratch. Use a proven identity provider.
Choose the right model:
| Model | Use when | |-------|----------| | RBAC (Role-Based) | Clear user roles, relatively static permissions | | ABAC (Attribute-Based) | Fine-grained rules based on resource + user attributes | | ReBAC (Relationship-Based) | Google Docs-style sharing, ownership chains |
Principle of Least Privilege: every user, service, and process gets only what it needs — nothing more.
Define authorization at the resource level, not just the route level.
Internet → WAF → Load Balancer → API Gateway → Services (private subnet)
↓
Databases (no public access)
| Regulation | Key requirements | |-----------|----------------| | GDPR | Data minimization, right to deletion, DPA, breach notification 72h | | SOC2 | Security, availability, confidentiality controls + audit trail | | PCI-DSS | Cardholder data never stored raw; tokenize everything | | HIPAA | Encryption at rest + transit, BAA with vendors, audit logs |
.env files in repostesting
Set up Vitest 2.x with TypeScript for unit and component testing using test/describe/it, vi.fn/vi.mock/vi.spyOn, component testing with Testing Library, coverage (v8/istanbul), workspace config, and snapshot testing.
testing
Set up pytest 8.x with Python for unit and integration testing using fixtures (scope, autouse, parametrize), async tests (pytest-asyncio), mocking (unittest.mock, pytest-mock), coverage (pytest-cov), conftest.py patterns, and markers.
testing
Set up Playwright 1.49+ with TypeScript for E2E testing using page object model, fixtures, test.describe/test blocks, assertions, selectors, network mocking, CI configuration, and trace viewer.
testing
Set up Jest 30+ with TypeScript for unit tests, integration tests, mocking (jest.fn, jest.mock, jest.spyOn), coverage configuration, custom matchers, snapshot testing, and setup/teardown patterns.