# D1337 Module System

## Overview

Modules are plug-and-play extensions that add new capabilities to agents without modifying core files. Drop a module folder into `installed/`, reference it in an agent's `skills:` frontmatter, and it's live.

## Directory Structure

```
.agent/modules/
├── README.md                    # This file
├── module-template/             # Template for creating new modules
│   ├── SKILL.md                 # Module definition template
│   └── scripts/                 # Module scripts directory
├── installed/                   # Active modules (drop folders here)
└── registry.md                  # Available module catalog
```

## Creating a Module

1. Copy `module-template/` to `installed/<your-module-name>/`
2. Edit `SKILL.md` with your module's instructions
3. Add scripts to `scripts/` directory
4. Reference the module in target agent's `skills:` frontmatter

### Module SKILL.md Format

```yaml
---
name: module-name
description: Short description of what the module does
version: 1.0.0
type: module
requires: [python3]              # System dependencies
agent-bindings: [penetration-tester]  # Recommended agents
---

# Module Name

## Purpose
What this module enables.

## Usage
How the agent should use this module.

## Scripts
Available automation scripts in scripts/ directory.
```

## How Loading Works

1. Agent activated → frontmatter `skills:` parsed
2. If skill path points to `modules/installed/<name>` → load module's SKILL.md
3. Module scripts available at `.agent/modules/installed/<name>/scripts/`
4. Agent applies module knowledge to current task

## Example: Adding a Nmap Module

```bash
# 1. Create module from template
cp -r .agent/modules/module-template .agent/modules/installed/nmap-recon

# 2. Edit SKILL.md with nmap instructions
# 3. Add nmap wrapper scripts to scripts/
# 4. Add to penetration-tester frontmatter: skills: ..., modules/installed/nmap-recon
```

## Rules

- Module folder name = module identifier
- SKILL.md is MANDATORY in every module
- Scripts must be self-contained (no external dependencies beyond `requires`)
- Modules MUST NOT modify core agent files
- One module = one capability domain
