Agent Skillsnetalertx/NetAlertX › plugin-development

plugin-development

GitHub

用于创建、运行和测试 NetAlertX 插件的开发技能,涵盖插件结构定义、配置管理、数据契约及执行流程。

.claude/skills/plugin-development/SKILL.md netalertx/NetAlertX

Trigger Scenarios

创建新插件 运行插件脚本 测试插件功能 开发插件特性

Install

npx skills add netalertx/NetAlertX --skill plugin-development -g -y
More Options

Non-standard path

npx skills add https://github.com/netalertx/NetAlertX/tree/main/.claude/skills/plugin-development -g -y

Use without installing

npx skills use netalertx/NetAlertX@plugin-development

指定 Agent (Claude Code)

npx skills add netalertx/NetAlertX --skill plugin-development -a claude-code -g -y

安装 repo 全部 skill

npx skills add netalertx/NetAlertX --all -g -y

预览 repo 内 skill

npx skills add netalertx/NetAlertX --list

SKILL.md

Frontmatter
{
    "name": "plugin-development",
    "description": "Create and run NetAlertX plugins. Use this when asked to create a plugin, run a plugin, test a plugin, or develop plugin functionality."
}

Plugin Development

Expected Workflow

  1. Read this skill and docs/PLUGINS_DEV.md for full context.
  2. Find or create the plugin in server/plugins/<code_name>/.
  3. Read the plugin's config.json and script to understand its functionality and settings.
  4. Run: python3 server/plugins/<code_name>/script.py
  5. Retrieve the result from /tmp/log/plugins/last_result.<PREF>.log quickly — the backend processes and deletes it almost immediately.

Plugin Structure

server/plugins/<code_name>/
├── config.json      # Manifest: settings, data contract, DB column mapping
├── script.py         # Main script (or equivalent, depending on data_source)
└── README.md         # Setup/usage docs
  • code_name must match the folder name.
  • unique_prefix drives every setting key and filename (e.g. ARPSCANARPSCAN_RUN, last_result.ARPSCAN.log). Uppercase letters only, no underscores/numbers, must be unique across all plugins.
  • Ensure sys.path includes /app/server/plugins and /app/server (as in server/plugins/__template/rename_me.py).

Settings Pattern

  • <PREF>_RUN: execution phase (see below). Should default to "disabled" for any non-core plugin.
  • <PREF>_RUN_SCHD: cron-like schedule — check a similar existing plugin for precedent (e.g. pihole_api_scan uses */5 * * * *) rather than inventing a new cadence.
  • <PREF>_CMD: script path.
  • <PREF>_RUN_TIMEOUT: timeout in seconds — enforced by the core plugin runner as the whole script's kill-timeout (server/plugin.py passes it straight to subprocess(..., timeout=...)). Not a safe per-HTTP-call timeout — don't reuse it for individual network calls in a loop, or one slow call can burn the whole budget and get the process killed before it writes its result file. Two correct alternatives: config.json's "timeoutMultiplier": true on a params[] entry for a config-declared, known-length loop (see arp_scan); plugin_helper.per_item_timeout() for a runtime-variable-length loop (see the _publisher_* plugins).
  • <PREF>_WATCH: columns to watch for changes.

Data Contract

from plugin_helper import Plugin_Objects

plugin_objects = Plugin_Objects(RESULT_FILE)
plugin_objects.add_object(...)       # once per discovered item
plugin_objects.write_result_file()   # exactly once, at the end

Full column spec: docs/PLUGINS_DEV_DATA_CONTRACT.md. Note helpVal1-4/watchedValue1-4 both preserve a real 0/False you pass explicitly — only an omitted (None) value defaults to "".

Execution Phases

Phase Trigger
once Once at startup
schedule On cron schedule
always_after_scan After every scan
before_name_updates Before name resolution
on_new_device When new device detected
on_notification When notification triggered

Plugin Formats

Format Purpose Phase
publisher Send notifications on_notification
dev scanner Create/manage devices schedule
name discovery Discover device names before_name_updates
importer Import from services schedule
system Core functionality schedule

Before Opening a PR

Check the plugin against the Conventions ChecklistRUN default, schedule precedent, RUN_TIMEOUT semantics, reusing core settings instead of duplicating them, description length (renders in the Settings UI — keep it short), and the multi-instance settings pattern (nested array + popup-form, see rest_import, not a hardcoded "primary"/"secondary" pair). Most plugin PR review comments trace back to one of these, and test/plugins/test_plugin_conventions.py mechanically enforces the RUN-default, description-length, hardcoded-default-drift, and RUN_TIMEOUT-reuse-in-loop items — run it after touching a plugin.

Starting Point

Copy server/plugins/__template/ and customize. Read docs/PLUGINS_DEV.md for the full development guide.

Version History

  • a686a01 Current 2026-09-03 06:46

Same Skill Collection

.claude/skills/pr-analysis/SKILL.md
.claude/skills/testing-workflow/SKILL.md
.gemini/skills/devcontainer-management/SKILL.md
.gemini/skills/logging-standards/SKILL.md
.gemini/skills/mcp-activation/SKILL.md
.gemini/skills/pr-analysis/SKILL.md
.gemini/skills/project-navigation/SKILL.md
.gemini/skills/settings/SKILL.md
.gemini/skills/skills-index/SKILL.md
.gemini/skills/testing-workflow/SKILL.md
.github/skills/api-development/SKILL.md
.github/skills/authentication/SKILL.md
.github/skills/code-standards/SKILL.md
.github/skills/database-patterns/SKILL.md
.github/skills/database-reset/SKILL.md
.github/skills/devcontainer-configs/SKILL.md
.github/skills/devcontainer-services/SKILL.md
.github/skills/devcontainer-setup/SKILL.md
.github/skills/docker-build/SKILL.md
.github/skills/docker-prune/SKILL.md
.github/skills/logging-standards/SKILL.md
.github/skills/mcp-activation/SKILL.md
.github/skills/plugin-run-development/SKILL.md
.github/skills/pr-analysis/SKILL.md
.github/skills/project-navigation/SKILL.md
.github/skills/sample-data/SKILL.md
.github/skills/settings-management/SKILL.md
.github/skills/skills-overview/SKILL.md
.github/skills/testing-workflow/SKILL.md

Metadata

Files
0
Version
a686a01
Hash
1b5200fa
Indexed
2026-09-03 06:46

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-06 13:05
浙ICP备14020137号-1 $お客様$