<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Template Testing — API Reference

## Validation Commands

```bash
# Validate single template
nuclei -t template.yaml -validate

# Validate directory
nuclei -t templates/ -validate

# Verbose validation
nuclei -t template.yaml -validate -v

# Stats after validation
nuclei -t templates/ -validate -stats
```

## Debug Commands

```bash
# Full debug
nuclei -t template.yaml -u http://target -debug

# Request debug
nuclei -t template.yaml -u http://target -dreq

# Response debug
nuclei -t template.yaml -u http://target -dresp

# Proxy through interceptor
nuclei -t template.yaml -u http://target -proxy http://127.0.0.1:8080
```

## Testing CLI Flags

| Flag | Description |
|------|-------------|
| `-validate` | Validate template syntax |
| `-v` | Verbose output |
| `-debug` | Full debug mode |
| `-dreq` | Dump requests |
| `-dresp` | Dump responses |
| `-proxy` | Proxy URL for inspection |
| `-stats` | Show template statistics |
| `-json` | JSON output format |
| `-silent` | Suppress banner |
| `-o` | Output file |
| `-timeout` | Request timeout |

## Template Quality Checklist

| Check | Required | Description |
|-------|----------|-------------|
| `id` | Yes | Unique template identifier |
| `info.name` | Yes | Human-readable name |
| `info.author` | Yes | Template author |
| `info.severity` | Yes | critical/high/medium/low/info |
| `info.description` | Recommended | What and why |
| `info.tags` | Recommended | Comma-separated tags |
| `metadata.max-request` | Recommended | Request count |
| `classification.cwe-id` | For CVEs | CWE identifier |
| `classification.cve-id` | For CVEs | CVE identifier |
| `matchers` | Yes | At least one matcher |
| `matchers-condition: and` | Recommended | Multi-layer matching |

## CI/CD Integration

```bash
# GitHub Actions nuclei step
- name: Validate Templates
  run: |
    nuclei -t templates/ -validate -v
    if [ $? -ne 0 ]; then
      echo "Template validation failed"
      exit 1
    fi

# GitLab CI nuclei job
validate-templates:
  image: projectdiscovery/nuclei:latest
  script:
    - nuclei -t templates/ -validate -v
```
