<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->

# API Reference — Building Yara Rule Development

## Agent Tools

| Tool | Description |
|---|---|
| Author Rule | `author_rule(name, strings, condition)` — Author a YARA rule skeleton. |
| Validate Rule | `validate_rule(rule_path)` — Validate a YARA rule file for syntax errors. |
| Scan File | `scan_file(rule_path, target_path)` — Scan a target file or directory with a YARA rule. |

## CLI Usage

```bash
# Author rule
node agent.js author --name "APT_Loader" --strings "LoadLibraryA" "VirtualAlloc" --condition "all of them"
```

```bash
# Validate
node agent.js validate --rule rules/apt_loader.yar
```

```bash
# Scan
node agent.js scan --rule rules/apt_loader.yar --target /tmp/samples/
```

## Output Format

All commands return JSON with the following structure:

```json
{
  "action": "<command_name>",
  "...": "command-specific fields"
}
```

## Error Handling

- Invalid input returns `{"error": "description"}` with non-zero exit code
- JSON parsing errors are caught and reported with context
- Missing required arguments trigger argparse help display
