Skip to content

Commit f24cb9e

Browse files
committed
Add create-mattermost-plugin skill to plugin-development plugin
Adds a new skill that scaffolds Mattermost plugins by cloning the starter template, customizing module paths and plugin metadata, and initializing a git repository with an initial commit.
1 parent e6ab9e4 commit f24cb9e

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

  • plugins/plugin-development/skills/create-mattermost-plugin
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: create-mattermost-plugin
3+
description: Create a new Mattermost plugin from the starter template in the current directory. Use when creating a new plugin from scratch, scaffolding a Mattermost plugin, or bootstrapping a plugin project.
4+
user-invocable: true
5+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6+
---
7+
8+
# Create Mattermost Plugin
9+
10+
Scaffold a new Mattermost plugin by cloning the [starter template](https://github.com/mattermost/mattermost-plugin-starter-template) into the current directory and customizing it.
11+
12+
The **plugin name** is the current folder name (e.g. if pwd is `/home/user/mattermost-plugin-foo`, the plugin name is `mattermost-plugin-foo`).
13+
The **Go module path** is `github.com/mattermost/<plugin-name>`.
14+
15+
## Step 1: Pre-flight
16+
17+
Check if pwd has files beyond dotfiles. If non-empty, warn the user with `AskUserQuestion` and let them choose to proceed or abort.
18+
19+
## Step 2: Clone template into pwd
20+
21+
```bash
22+
TMPDIR=$(mktemp -d)
23+
git clone --depth 1 https://github.com/mattermost/mattermost-plugin-starter-template "$TMPDIR"
24+
rm -rf "$TMPDIR/.git"
25+
cp -a "$TMPDIR"/. ./
26+
rm -rf "$TMPDIR"
27+
```
28+
29+
## Step 3: Customize (follow README "Getting Started" steps)
30+
31+
Derive values:
32+
33+
- `PLUGIN_NAME` = basename of pwd (e.g. `mattermost-plugin-foo`)
34+
- `MODULE_PATH` = `github.com/mattermost/$PLUGIN_NAME`
35+
- `PLUGIN_ID` = `com.mattermost.$PLUGIN_NAME` (dots replaced for the id portion after `com.mattermost.`)
36+
37+
1. **Edit `plugin.json`**: set `id`, `name`, `description` (use the plugin name as a sensible default for name/description, the user can refine later). Update `homepage_url` and `support_url` to point to `https://$MODULE_PATH` and `https://$MODULE_PATH/issues`.
38+
39+
2. **Replace the old module path everywhere**: Use `Grep` to find all files containing `github.com/mattermost/mattermost-plugin-starter-template`, then `Edit` each with `replace_all` to substitute the new `MODULE_PATH`.
40+
41+
## Step 4: Git init & first commit
42+
43+
1. Run `git init` if `.git` doesn't exist
44+
2. `git add -A && git commit -m "Initial plugin scaffold from mattermost-plugin-starter-template"`
45+
46+
## Step 5: Summary
47+
48+
Print what was created and remind the user to run `make` to build.

0 commit comments

Comments
 (0)