AgentSkillsCN

dify-plugin

构建 Dify 插件(工具、触发器、扩展、模型、数据源、智能体策略)。适用于集成外部 API、添加 Webhook、实现模型提供商、连接数据源,或创建自定义智能体推理策略时使用。支持 Python SDK,并提供 YAML 配置。

SKILL.md
--- frontmatter
name: dify-plugin
description: Build Dify plugins (Tool, Trigger, Extension, Model, Datasource, Agent Strategy). Use when integrating external APIs, adding webhooks, implementing model providers, connecting data sources, or creating custom agent reasoning strategies. Supports Python SDK with YAML configurations.

Plugin Types Overview

  • Tool - Add capabilities: API calls, logic operations, file processing

    • Usage: Add capability to workflow/agent
    • Reference: tool-plugin.md
    • Example: tools/wikipedia, tools/github
  • Trigger - Start workflows from webhooks

    • Usage: Start workflow when webhook received
    • Reference: trigger-plugin.md
    • Example: triggers/github_trigger
  • Extension - Custom HTTP endpoints

    • Usage: Expose HTTP endpoint (OAuth, webhook)
    • Reference: extension-plugin.md
    • Example: extensions/slack_bot
  • Model - Add AI model providers

    • Usage: Add AI model to workflow/agent
    • Reference: model-plugin.md
    • Example: models/openai, models/anthropic
  • Datasource - Connect external storage

    • Usage: Import docs from cloud storage
    • Reference: datasource-plugin.md
    • Example: datasources/github
  • Agent Strategy - Custom agent reasoning

Development SOP

Phase 1: Understand Requirements

If there's not a proper plan for implementing the plugin and the plugin is not implemented yet, you should follow plan-for-plugin.md to prepare a plan before starting.

Phase 2: Initialize Project

If the development environment is not set up yet or the project is not initialized yet, you should refer to init-development-environement.md

Phase 3: Implement

If the plugin is not fully implemented yet, you should refer to implement-plugin.md

Phase 4: Test & Debug

For testing plugin locally, refer to testing.md For debugging plugin remotely, refer to remote-debug-plugin.md

Phase 5: Package & Deploy

bash
# Package the plugin
dify plugin package <path/to/plugin>

# Install to Dify instance (uses .credential from get_debug_key.py)
uv run python scripts/install_plugin.py dist/*.difypkg

The install_plugin.py script uploads and installs plugins via Dify API. It reuses the .credential file created by get_debug_key.py.

When the plugin is ready, you may ask user to try it.

Phase 6: Iterate & Release

Dev Branch (Testing):

  1. Update version in manifest.yaml with dev suffix (e.g., 0.1.0-dev.1)
  2. Package plugin: dify plugin package <path/to/plugin>
  3. Create GitHub pre-release with .difypkg file

Main Branch (Production):

  1. Update version in manifest.yaml with release number (e.g., 0.1.0)
  2. Package plugin: dify plugin package <path/to/plugin>
  3. Create GitHub release with .difypkg file

Troubleshooting

Please refer to common-issues-and-check.md for a detailed troubleshooting guide.

Plugin Structure Overview (tool Plugin for Example)

code
my-plugin/
├── manifest.yaml         # Plugin metadata
├── main.py               # Plugin Entry
├── pyproject.toml        # Dependencies
├── provider/
│   ├── provider.yaml     # Credentials + config
│   └── provider.py       # Validation logic
├── tools/                # Tool plugins
│   ├── tool.yaml
│   └── tool.py
└── _assets/
    └── icon.svg

References

Run tree on the root of the skill to see the structure.