npx skills add ...
npx skills add factory-ai/factory-plugins --skill threat-model-generation
npx skills add factory-ai/factory-plugins --skill threat-model-generation
Generate a STRIDE-based security threat model for a repository. Use when setting up security monitoring, after architecture changes, or for security audits.
The same skill content is published under more than one repo. The install counts are split across them; any of these commands works.
Generate a comprehensive security threat model for a repository using the STRIDE methodology. This skill analyzes the codebase architecture and produces an LLM-optimized threat model document that other security skills can reference.
Before running this skill, gather or confirm:
| Input | Description | Required |
|---|---|---|
| Repository path | Root directory to analyze | Yes (default: current directory) |
| Existing threat model | Path to existing .factory/threat-model.md if updating | No |
| Compliance requirements | Frameworks to consider (SOC2, GDPR, HIPAA, etc.) | No |
| Security contacts | Email addresses for security team notifications | No |
Follow these steps in order:
Scan the codebase to understand the system:
Identify languages and frameworks
package.json, requirements.txt, go.mod, Cargo.toml, etc.Map components and services
apps/, services/, packages/ directoriesIdentify external interfaces
Trace data flows
Define security zones:
Public Zone (untrusted)
Authenticated Zone (partially trusted)
Internal Zone (trusted)
Document where trust boundaries exist and what validates transitions between zones.
Classify data by sensitivity:
PII (Personally Identifiable Information)
Credentials & Secrets
Business-Critical Data
For each major component, analyze threats in all six categories:
For each identified threat:
Create a library of code patterns specific to this codebase's tech stack:
Include patterns for:
Create two files:
.factory/threat-model.mdUse the template in stride-template.md to generate a comprehensive threat model with:
The document should be written in natural language with code examples, optimized for LLM comprehension.
.factory/security-config.jsonGenerate configuration metadata:
Customize based on:
The skill is complete when:
.factory/threat-model.md exists with all sections populated.factory/security-config.json exists with valid JSONRun these checks before completing:
Generate initial threat model:
Update existing threat model after architecture change:
Generate with compliance requirements:
stride-template.md (in this skill directory)# Verify threat model exists and is non-empty
test -s .factory/threat-model.md && echo "✓ Threat model exists"
# Verify config is valid JSON
cat .factory/security-config.json | jq . > /dev/null && echo "✓ Config is valid JSON"
# Check threat model has key sections
grep -q "## 1. System Overview" .factory/threat-model.md && echo "✓ Has System Overview"
grep -q "## 5. Threat Analysis" .factory/threat-model.md && echo "✓ Has Threat Analysis"
grep -q "## 6. Vulnerability Pattern Library" .factory/threat-model.md && echo "✓ Has Pattern Library"Generate a threat model for this repository using the threat-model-generation skill.Update the threat model - we added a new payments service in services/payments/.Generate a threat model for this repository. We need to comply with SOC2 and GDPR.