← 返回 Skills 市场
camera-2018

AstrBot plugin dev skill

作者 若月千鸮 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
93
总下载
1
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install astrbot-plugin-dev-skill
功能描述
Guide for developing AstrBot plugins that match the AstrBot main repo, pass astr-plugin-reviewer checks, and cover commands, filters, hooks, LLM integrations...
使用说明 (SKILL.md)

AstrBot Plugin Development

Use this skill to write AstrBot plugins in a reviewer-first way: align with astr-plugin-reviewer hard checks, then follow the current AstrBot repository APIs and docs.

Start Here

Before writing code, always read these two references first:

Then load only the references you need:

Default Workflow

  1. Create or verify main.py and metadata.yaml first.
  2. Treat metadata.yaml as the source of truth for plugin identity. Prefer desc plus repo, and never keep both desc and description.
  3. In main.py, define a class that inherits Star. Prefer AstrBot's auto-discovery; do not introduce the deprecated @register decorator unless you are maintaining old code.
  4. Import filter exactly with from astrbot.api.event import filter to avoid reviewer failures and naming confusion.
  5. Import the logger exactly with from astrbot.api import logger.
  6. Keep network I/O async. Prefer httpx or aiohttp; do not use requests, blocking sleeps, or other blocking network calls.
  7. If the plugin needs persistent files, prefer StarTools.get_data_dir(). It returns a Path.
  8. If you implement LLM hooks, LLM tools, direct LLM calls, or agents, follow the exact signatures and restrictions in references/advanced-features.md.
  9. Before finishing, run a self-check against references/reviewer-checklist.md. If the user wants marketplace publishing, also ensure the publish JSON matches metadata.yaml exactly.

Minimal Template

from pathlib import Path

from astrbot.api import logger
from astrbot.api.event import AstrMessageEvent, filter
from astrbot.api.star import Context, Star, StarTools


class MyPlugin(Star):
    def __init__(self, context: Context):
        super().__init__(context)
        self.data_dir: Path = StarTools.get_data_dir()

    @filter.command("helloworld")
    async def helloworld(self, event: AstrMessageEvent):
        """回复一个简单问候。"""
        logger.info(f"helloworld triggered by {event.get_sender_id()}")
        yield event.plain_result(f"Hello, {event.get_sender_name()}!")

    async def terminate(self):
        """Called when the plugin is unloaded or disabled."""

Note: The @register decorator is deprecated in newer versions of AstrBot. Please use metadata.yaml to define plugin metadata. AstrBot automatically detects the plugin class inheriting from Star.

Core Workflows

1. Project Setup and Metadata

A complete plugin requires metadata.yaml for identification, requirements.txt for dependencies, and optionally logo.png, _conf_schema.json, and a README.md.

  • Plugin names should start with astrbot_plugin_, be lowercase, have no spaces, and be short.
  • See references/project-structure.md for mandatory files, dev environment setup, and publishing.

2. Registering Commands and Filters

Commands are registered using @filter.command(name). AstrBot auto-parses command parameters by type hints. You can also use command groups, command aliases, and filter by event type, platform, or user permission.

  • See references/core-api.md for full list of filters, hooks, the platform compatibility matrix, and event propagation control.

3. Handling Messages and Responses

AstrBot uses a message-chain system. You can respond with plain text, images, or a mix of components. Proactive messages are supported via unified_msg_origin and MessageChain.

4. Advanced Integrations

  • Configuration: Use _conf_schema.json for user settings.
  • LLM Tools: Register tools via @filter.llm_tool or FunctionTool.
  • LLM Direct Calls: Use self.context.llm_generate() to call LLMs directly.
  • Agent / Multi-Agent: Use self.context.tool_loop_agent() for tool-loop agents.
  • Stateful Interaction: Use session_waiter for multi-step prompts with custom session filters.
  • T2I: Render text or HTML/Jinja2 templates to images.
  • Conversation & Persona Managers: Access LLM conversation history and persona settings when needed.

See references/advanced-features.md for examples.

Elegant Design Patterns

Follow these patterns for robust, user-friendly plugins:

  • Use unified logging via from astrbot.api import logger.
  • Handle errors gracefully to avoid bot crashes.
  • Use KV storage or the plugin data directory for persistence.
  • Ensure all I/O operations are non-blocking.
  • Access platform instances, loaded plugins, and protocol-level APIs only when necessary.

See references/patterns.md for detailed code patterns.

安全使用建议
This is a coherent, instruction-only developer guide for AstrBot plugins. Before using it: (1) Treat the guide as documentation-only — it won’t install or run code itself. (2) When you implement a plugin following these docs, review any third-party packages you add to requirements.txt and avoid embedding secrets in metadata or source; prefer the documented _conf_schema.json for user-supplied API keys. (3) Pay attention to the reviewer checklist and hook/send semantics to avoid runtime failures. (4) If you plan to publish, verify the repository URL and metadata.yaml contents match marketplace expectations and audit any network or LLM calls your plugin makes (those calls will run in the plugin, not in this guide).
功能分析
Type: OpenClaw Skill Name: astrbot-plugin-dev-skill Version: 1.0.0 The skill bundle is a comprehensive development guide and reference set for creating AstrBot plugins. It provides clear instructions, API documentation, and best practices (e.g., using async I/O, official logging, and designated data directories) across files like SKILL.md and various reference markdown files. No malicious intent, data exfiltration, or harmful prompt injections were detected.
能力评估
Purpose & Capability
The skill's name and description match its contents: a reviewer-first guide and reference set for building AstrBot plugins. All required artifacts (metadata.yaml, main.py, _conf_schema.json, requirements.txt) and coding patterns described are appropriate for that purpose.
Instruction Scope
Runtime instructions are limited to developer guidance: file layouts, import conventions, hook signatures, and reviewer checklist. The SKILL.md and referenced files do not ask the agent to read unrelated system files, exfiltrate data, or call external endpoints beyond normal plugin behavior. They reference only plugin-local paths and AstrBot runtime APIs.
Install Mechanism
There is no install spec and no code files to execute. As an instruction-only skill, it does not pull code or write to disk at install time, which is the lowest-risk configuration.
Credentials
No environment variables, credentials, or config paths are requested by the skill. The guidance explains how plugins may accept API keys via _conf_schema.json (user-provided) but the skill itself does not require or request secrets.
Persistence & Privilege
The skill is not always-enabled and does not request persistent system presence. It is user-invocable and permits model invocation (normal for skills), and it contains no instructions to modify other skills or global agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install astrbot-plugin-dev-skill
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /astrbot-plugin-dev-skill 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release: AstrBot plugin development workflow guide. - Introduces comprehensive SKILL.md guiding AstrBot plugin development in alignment with `astr-plugin-reviewer` requirements and AstrBot repo standards. - Details essential workflows for project setup, metadata, commands, filters, message handling, LLM/agent integrations, and advanced plugin features. - Provides minimal plugin code template and key best practices for reviewer compliance. - Emphasizes reviewer-first, auto-discovery workflows and non-blocking async patterns for network and I/O operations.
元数据
Slug astrbot-plugin-dev-skill
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

AstrBot plugin dev skill 是什么?

Guide for developing AstrBot plugins that match the AstrBot main repo, pass astr-plugin-reviewer checks, and cover commands, filters, hooks, LLM integrations... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 93 次。

如何安装 AstrBot plugin dev skill?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install astrbot-plugin-dev-skill」即可一键安装,无需额外配置。

AstrBot plugin dev skill 是免费的吗?

是的,AstrBot plugin dev skill 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

AstrBot plugin dev skill 支持哪些平台?

AstrBot plugin dev skill 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 AstrBot plugin dev skill?

由 若月千鸮(@camera-2018)开发并维护,当前版本 v1.0.0。

💬 留言讨论