Agent Native

threat-model-generation

This skill generates a STRIDE-based threat model by analyzing a repository's architecture, components, and data flows.

by FactoryOfficial publisherNot reviewed

Identity proven by GitHub's verified organisation badge (Factory-AI)

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode
License
MIT (permissive)
Pin
21a74depinned Oct 9, 2026
Context cost
about 2,000 tokenswhen the skill loads
GitHub stars
8on factory-ai/skills
Scripts
None found

What it does

“Generate a STRIDE-based security threat model for a repository. Use when setting up security monitoring, after architecture changes, or for security audits.”
The author's description, from SKILL.md

Generated summary from the skill's own text

This skill generates a STRIDE-based threat model by analyzing a repository's architecture, components, and data flows. It produces a comprehensive threat model document and security configuration file that identify potential vulnerabilities across six threat categories (spoofing, tampering, repudiation, information disclosure, denial of service, elevation of privilege). The output helps security teams prioritize testing and establish baselines for ongoing security monitoring.

When to use it

  • Setting up security monitoring for a new repository or after architecture changes
  • Periodic security audits or compliance reviews requiring threat documentation
  • When security team requests updated threat model to reflect code changes
  • Establishing baseline security posture before implementing automated vulnerability scanning

When not to

  • Running continuous automated vulnerability scans or fixing existing security issues
  • When only quick security guidance is needed without comprehensive documentation
  • For real-time threat detection or incident response during active attacks

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add factory-ai/skills --skill threat-model-generation

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install factory-ai/skills threat-model-generation@21a74dec467a1424e3e067712d004cd987d6a0ce

Installs the commit we checked (21a74de).

Copy by hand

Download the folder at 21a74de and put it in .claude/skills/threat-model-generation for Claude Code and in .agents/skills/threat-model-generation for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at 21a74de

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "threat-model-generation" by Factory.

Source, pinned to commit 21a74dec467a1424e3e067712d004cd987d6a0ce:
https://github.com/factory-ai/skills/tree/21a74dec467a1424e3e067712d004cd987d6a0ce/skills/threat-model-generation

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/threat-model-generation/ for Claude Code and .agents/skills/threat-model-generation/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/factory/threat-model-generation

SKILL.md at the pin

---
name: threat-model-generation
description: Generate a STRIDE-based security threat model for a repository. Use when setting up security monitoring, after architecture changes, or for security audits.
version: 1.0.0
tags: [security, threat-model, stride]
---

# Threat Model Generation

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.

## When to Use This Skill

- **First-time setup** - New repository needs initial threat model
- **Architecture changes** - Significant changes to components, APIs, or data flows
- **Security audit** - Periodic review or compliance requirement
- **Manual request** - Security team requests updated threat model

## Inputs

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                               |

## Instructions

Follow these steps in order:

### Step 1: Analyze Repository Structure

Scan the codebase to understand the system:

1. **Identify languages and frameworks**

   - Check `package.json`, `requirements.txt`, `go.mod`, `Cargo.toml`, etc.
   - Note the primary tech stack (e.g., Next.js, Django, Go microservices)

2. **Map components and services**

   - Look for `apps/`, `services/`, `packages/` directories
   - Identify entry points: API routes, CLI commands, web handlers
   - Note databases, caches, message queues

3. **Identify external interfaces**

   - HTTP endpoints (REST, GraphQL)
   - File upload handlers
   - Webhook receivers
   - OAuth/SSO integrations
   - CLI commands that accept user input

4. **Trace data flows**
   - How does user input enter the system?
   - Where is sensitive data stored?
   - What external services are called?

### Step 2: Identify Trust Boundaries

Define security zones:

1. **Public Zone** (untrusted)

   - All external HTTP endpoints
   - Public APIs without authentication
   - User-uploaded files

2. **Authenticated Zone** (partially trusted)

   - Endpoints requiring valid session/token
   - User-specific data access
   - Rate-limited APIs

3. **Internal Zone** (trusted)
   - Service-to-service communication
   - Admin-only endpoints
   - Database connections
   - Secrets management

Document where trust boundaries exist and what validates transitions between zones.

### Step 3: Inventory Critical Assets

Classify data by sensitivity:

1. **PII (Personally Identifiable Information)**

   - User emails, names, addresses, phone numbers
   - Document protection measures

2. **Credentials & Secrets**

   - Password hashes, API keys, OAuth tokens
   - JWT signing keys, encryption keys
   - Document rotation policies

3. **Business-Critical Data**
   - Transaction records, customer data
   - Proprietary algorithms, trade secrets
   - Document access controls

### Step 4: Apply STRIDE Analysis

For each major component, analyze threats in all six categories:

#### S - Spoofing Identity

- Can attackers impersonate users or services?
- Are authentication mechanisms secure?
- Look for: weak session handling, API key exposure, missing MFA

#### T - Tampering with Data

- Can attackers modify data in transit or at rest?
- Look for: SQL injection, XSS, mass assignment, missing input validation

#### R - Repudiation

- Can users deny actions they performed?
- Look for: missing audit logs, insufficient logging, no immutable trails

#### I - Information Disclosure

- Can attackers access data they shouldn't?
- Look for: IDOR, verbose errors, hardcoded secrets, data leaks in logs

#### D - Denial of Service

- Can attackers disrupt service availability?
- Look for: missing rate limits, resource exhaustion, algorithmic complexity

#### E - Elevation of Privilege

- Can attackers gain unauthorized access levels?
- Look for: missing authorization checks, role manipulation, privilege escalation

For each identified threat:

- Describe the attack scenario
- List vulnerable components
- Show code patterns to look for
- Note existing mitigations
- Identify gaps
- Assign severity (CRITICAL/HIGH/MEDIUM/LOW) and likelihood

### Step 5: Document Vulnerability Patterns

Create a library of code patterns specific to this codebase's tech stack:

```python
# Example: SQL Injection patterns for Python
# VULNERABLE
sql = f"SELECT * FROM users WHERE id = {user_id}"

# SAFE
cursor.execute("SELECT * FROM users WHERE id = ?", (user_id,))
```

Include patterns for:

- SQL injection
- XSS (Cross-Site Scripting)
- Command injection
- Path traversal
- Authentication bypass
- IDOR (Insecure Direct Object Reference)

### Step 6: Generate Output Files

Create two files:

#### 1. `.factory/threat-model.md`

Use the template in `stride-template.md` to generate a comprehensive threat model with:

- System overview with architecture description
- Trust boundaries and security zones
- Attack surface inventory
- Critical assets classification
- STRIDE threat analysis for each component
- Vulnerability pattern library
- Security testing strategy
- Assumptions and accepted risks
- Version changelog

The document should be written in **natural language** with code examples, optimized for LLM comprehension.

#### 2. `.factory/security-config.json`

Generate configuration metadata:

```json
{
  "threat_model_version": "1.0.0",
  "last_updated": "<ISO timestamp>",
  "security_team_contacts": [],
  "compliance_requirements": [],
  "scan_frequency": "on_commit",
  "severity_thresholds": {
    "block_merge": ["CRITICAL"],
    "require_review": ["HIGH", "CRITICAL"],
    "notify_security_team": ["CRITICAL"]
  },
  "vulnerability_patterns": {
    "enabled": [
      "sql_injection",
      "xss",
      "command_injection",
      "path_traversal",
      "auth_bypass",
      "idor"
    ],
    "custom_patterns_path": null
  }
}
```

Customize based on:

- Detected compliance requirements (from docs, configs, or user input)
- Security team contacts (if provided)
- Tech stack (enable relevant vulnerability patterns)

## Success Criteria

The skill is complete when:

- [ ] `.factory/threat-model.md` exists with all sections populated
- [ ] `.factory/security-config.json` exists with valid JSON
- [ ] All major components have STRIDE analysis
- [ ] Vulnerability patterns match the tech stack
- [ ] Document is written in natural language (LLM-readable)
- [ ] No placeholder text remains

## Verification

Run these checks before completing:

```bash
# 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"
```

## Example Invocations

**Generate initial threat model:**

```
Generate a threat model for this repository using the threat-model-generation skill.
```

**Update existing threat model after architecture change:**

```
Update the threat model - we added a new payments service in services/payments/.
```

**Generate with compliance requirements:**

```
Generate a threat model for this repository. We need to comply with SOC2 and GDPR.
```

## References

- [STRIDE Threat Modeling](https://docs.microsoft.com/en-us/azure/security/develop/threat-modeling-tool-threats)
- [OWASP Threat Modeling](https://owasp.org/www-community/Threat_Modeling)
- Template: `stride-template.md` (in this skill directory)

From factory-ai/skills at 21a74de, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.

View SKILL.md on GitHub at 21a74de

Files

2 files, 18 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at 21a74de

Also in

The same SKILL.md content appears in these places too. We list it once and credit the oldest public source.

All 34 skills from Factory

More from Factory

  • autoresearch

    This skill runs an autonomous optimization loop to improve a measurable metric through systematic experimentation.

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 4K tokens · pinned 6 days ago

  • ban-type-assertions

    This skill enables the TypeScript ESLint rule that bans `as` type assertions in a package, replacing them with compiler-verified alternatives like Zod…

    Claude Code, Codex, Cursor +4 · about 1.6K tokens · pinned 6 days ago

  • browser-navigation

    This skill enables agents to automate browser interactions including navigation, form filling, element clicking, screenshots, and data extraction from web…

    Claude Code, Codex, Cursor +3 · about 2.5K tokens · pinned 6 days ago

  • create-pr

    Creates a pull request with Conventional Commits formatting, templated body, and optional ticket linking.

    Claude Code, Codex, Cursor +4 · about 2.2K tokens · pinned 6 days ago

  • droid-control

    Automate terminals, browsers, and desktop applications by routing to specialized drivers for recording, testing, and generating visual demonstrations.

    Claude Code · about 3.5K tokens · pinned 6 days ago

  • fix-knip-unused-exports

    Fixes knip unused export violations by identifying their type (test-only, dead barrel re-export, or internally-only-used) and applying the appropriate fix…

    Claude Code, Codex, Cursor +4 · about 2.4K tokens · pinned 6 days ago

All Security skills
  • claude-security

    Scans your repository for security issues using Claude, examines code changes or commits for vulnerabilities, and generates patch files to fix findings.

    by AnthropicOfficial publisher

    Claude Code · about 1K tokens · pinned 6 days ago

  • sensitive-logging-audit

    The skill helps audit and fix sensitive data leaks in Python SDK logging, exceptions, and telemetry by collecting candidate sinks, manually tracing values…

    by OpenAIOfficial publisher

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 970 tokens · pinned 6 days ago

  • security-audit

    This skill guides security audits of codebases, APIs, and services by finding vulnerabilities that cross real trust boundaries.

    by CloudflareOfficial publisher

    Contains scripts

    Claude Code · about 5.4K tokens · pinned 6 days ago

  • assess-patch-risk

    This skill analyzes patch artifacts to assess their program impact, regression risk, and suitability for automated merging.

    by OpenAIOfficial publisher

    Codex · about 2.3K tokens · pinned 6 days ago

  • attack-path-analysis

    This skill analyzes security findings to build explicit attack paths from source to sink, calibrates severity, and decides whether each finding is reportable.

    by OpenAIOfficial publisher

    Codex · about 2.1K tokens · pinned 6 days ago

  • deep-security-scan

    Performs exhaustive, multi-pass security analysis across a repository or scoped directory by running repeated independent security scans and aggregating…

    by OpenAIOfficial publisher

    Codex · about 3.4K tokens · pinned 6 days ago

Open roles at Factory

5 of 7 open roles on the jobs board

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use