> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-add-new-agent.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Difyプラグイン開発用コマンドラインインターフェース

<Note> ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/develop-plugin/getting-started/cli)を参照してください。</Note>

コマンドラインインターフェース（CLI）を使用してDifyプラグインのセットアップとパッケージ化を行います。CLIは、初期化からパッケージ化まで、プラグイン開発ワークフローを効率的に管理する方法を提供します。

このガイドでは、Difyプラグイン開発におけるCLIの使用方法について説明します。

## 前提条件

始める前に、以下がインストールされていることを確認してください：

* Pythonバージョン ≥ 3.12
* Dify CLI
* Homebrew（Macユーザーの場合）

## Difyプラグインプロジェクトの作成

<Tabs>
  <Tab title="Mac">
    ```bash theme={null}
    brew tap langgenius/dify
    brew install dify
    ```
  </Tab>

  <Tab title="Linux">
    [Dify GitHubリリースページ](https://github.com/langgenius/dify-plugin-daemon/releases)から最新のDify CLIを取得してください

    ```bash theme={null}
    # Download dify-plugin-darwin-arm64
    chmod +x dify-plugin-darwin-arm64
    mv dify-plugin-darwin-arm64 dify
    sudo mv dify /usr/local/bin/
    ```
  </Tab>
</Tabs>

これでDify CLIのインストールが完了しました。以下のコマンドを実行してインストールを確認できます：

```bash theme={null}
dify version
```

以下のコマンドを使用して新しいDifyプラグインプロジェクトを作成できます：

```bash theme={null}
dify plugin init
```

プロンプトが表示されたら、必要なフィールドを入力してください：

```bash theme={null}
Edit profile of the plugin
Plugin name (press Enter to next step): hello-world
Author (press Enter to next step): langgenius
Description (press Enter to next step): hello world example
Repository URL (Optional) (press Enter to next step): Repository URL (Optional)
  Enable multilingual README: [✔] English is required by default

Languages to generate:
    English: [✔] (required)
  → 简体中文 (Simplified Chinese): [✔]
    日本語 (Japanese): [✘]
    Português (Portuguese - Brazil): [✘]

Controls:
  ↑/↓ Navigate • Space/Tab Toggle selection • Enter Next step
```

`python`を選択してEnterキーを押し、Pythonプラグインテンプレートで続行します。

```bash theme={null}
Select the type of plugin you want to create, and press `Enter` to continue
Before starting, here's some basic knowledge about Plugin types in Dify:

- Tool: Tool Providers like Google Search, Stable Diffusion, etc. Used to perform specific tasks.
- Model: Model Providers like OpenAI, Anthropic, etc. Use their models to enhance AI capabilities.
- Endpoint: Similar to Service API in Dify and Ingress in Kubernetes. Extend HTTP services as endpoints with custom logi
- Agent Strategy: Implement your own agent strategies like Function Calling, ReAct, ToT, CoT, etc.

Based on the ability you want to extend, Plugins are divided into four types: Tool, Model, Extension, and Agent Strategy

- Tool: A tool provider that can also implement endpoints. For example, building a Discord Bot requires both Sending and
- Model: Strictly for model providers, no other extensions allowed.
- Extension: For simple HTTP services that extend functionality.
- Agent Strategy: Implement custom agent logic with a focused approach.

We've provided templates to help you get started. Choose one of the options below:
-> tool
  agent-strategy
  llm
  text-embedding
  rerank
  tts
  speech2text
  moderation
  extension
```

デフォルトのdifyバージョンを入力します。空白のままにすると最新バージョンが使用されます：

```bash theme={null}
Edit minimal Dify version requirement, leave it blank by default
Minimal Dify version (press Enter to next step): 
```

準備完了です！CLIは指定したプラグイン名で新しいディレクトリを作成し、プラグインの基本構造をセットアップします。

```bash theme={null}
cd hello-world
```

## プラグインの実行

hello-worldディレクトリにいることを確認してください

```bash theme={null}
cp .env.example .env
```

`.env`ファイルを編集して、APIキーやその他の設定などのプラグインの環境変数を設定します。これらの変数はDifyダッシュボードで確認できます。Dify環境にログインし、右上の「プラグイン」アイコンをクリックしてから、デバッグアイコン（または虫のようなもの）をクリックします。ポップアップウィンドウで「APIキー」と「ホストアドレス」をコピーします。（キーとホストアドレスの取得インターフェースを示すローカルの対応するスクリーンショットを参照してください）

```bash theme={null}
INSTALL_METHOD=remote
REMOTE_INSTALL_HOST=debug-plugin.dify.dev
REMOTE_INSTALL_PORT=5003
REMOTE_INSTALL_KEY=********-****-****-****-************
```

以下のコマンドを使用して、プラグインをローカルで実行できます：

```bash theme={null}
pip install -r requirements.txt
python -m main
```

***

[このページを編集する](https://github.com/langgenius/dify-docs/edit/main/en/develop-plugin/getting-started/cli.mdx) | [問題を報告する](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)
