# Create plugin

> Create plugin is an open-source agent skill for developer tools. Guides an agent to write Marko PHP plugins that intercept public methods with Before. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/marko-php/marko/tree/develop/packages/claude-plugins/plugins/marko-skills/skills/create-plugin
- **Repository:** https://github.com/marko-php/marko
- **GitHub stars:** 416
- **License:** MIT
- **Skill name:** create-plugin
- **Collection:** https://github.com/marko-php/marko
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-02

## About

This skill walks an agent through building a Marko plugin, a class that wraps a public method on another class so behavior can change without subclassing or replacing the class. It covers the two supported interception points, Before and After, and explains how return values control whether the original method runs, receives replaced arguments, or is short-circuited. It also describes how to receive the intercepted instance through a Subject parameter and how sortOrder sets the execution sequence among plugins.

The workflow has the agent identify a public, non-final target method, copy the plugin class and test templates from the skill's assets folder, fill in the host module's namespace from its composer.json autoload mapping, and place the file under src/Plugins. The skill says plugins are discovered automatically, so no module registration is needed. It finishes with a verification step that relies on LSP diagnostics and a find_plugins_targeting MCP tool.

The skill expects a Marko PHP project and a host module to put the plugin in. It points to a separate skill for full class replacement with Preferences and another for event listeners.

## When your agent uses it

> Create a Marko plugin — a class that intercepts methods on another class to modify behavior without subclassing. **Use this skill whenever the user wants to add a plugin, intercept a method, or extend a class's behavior.** Concrete triggers: "add a plugin for the OrderService", "intercept the save method on User", "extend the behavior of X without changing it", "modify Y's return value before it's returned", "I need a plugin", "create a Before/After plugin". Plugins use the #[Plugin], #[Before], #[After] attributes.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/marko-php/marko/tree/HEAD/packages/claude-plugins/plugins/marko-skills/skills/create-plugin)
- [License: MIT](https://github.com/marko-php/marko/tree/HEAD/packages/claude-plugins/plugins/marko-skills/skills/create-plugin)

## Features

- **Before and After hooks:** Explains the two interception points and how each one affects the target method call.
- **Return value semantics:** Describes how null, array and other return values from a Before hook change argument passing or short-circuit the call.
- **Subject parameter access:** Shows how to receive the intercepted instance and avoid recursive calls on it.
- **Plugin execution ordering:** Covers the sortOrder attribute argument and how it sequences plugins.
- **Template-based scaffolding:** Provides plugin class and test templates with placeholders for vendor, module and target class.
- **Namespace and placement rules:** Guides matching the host module's psr-4 namespace and placing the file under src/Plugins.

## Good for

- Add a plugin that logs calls to a repository's save method
- Modify the return value of a service method before it reaches callers
- Short-circuit a method with a cached result inside a Marko module
- Write Before plugin that validates arguments passed to a class method
- Create a plugin test covering pass-through and argument modification

## Install

### Claude Code

This skill ships in the `marko-skills` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add marko-php/marko
/plugin install marko-skills@marko
```

Or copy only this skill to `~/.claude/skills/create-plugin`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/marko-php/marko.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/create-plugin &&
cp -R "$tmp/packages/claude-plugins/plugins/marko-skills/skills/create-plugin" ~/.claude/skills/create-plugin &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/create-plugin` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/create-plugin` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/marko-php/marko.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/create-plugin &&
cp -R "$tmp/packages/claude-plugins/plugins/marko-skills/skills/create-plugin" ~/.agents/skills/create-plugin &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/create-plugin` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/create-plugin` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/marko-php/marko.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/create-plugin &&
cp -R "$tmp/packages/claude-plugins/plugins/marko-skills/skills/create-plugin" ~/.cursor/skills/create-plugin &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/create-plugin` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/marko-php/marko.git --path packages/claude-plugins/plugins/marko-skills/skills/create-plugin
```

Or copy the folder to `~/.gemini/skills/create-plugin` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/create-plugin`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/marko-php/marko.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/create-plugin &&
cp -R "$tmp/packages/claude-plugins/plugins/marko-skills/skills/create-plugin" ~/.copilot/skills/create-plugin &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/create-plugin` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/marko-php/marko.git
```

Then copy `marko/packages/claude-plugins/plugins/marko-skills/skills/create-plugin` into your agent's skills folder as `create-plugin`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does the skill need before Create plugin can be used?

It assumes a Marko PHP project with an existing host module, and the target class's method must be public and the class not final.

### Does the skill require registering the plugin?

No. The skill states that plugins under a module's src directory are auto-discovered and must not be registered in module.php.

### Can Create plugin replace a whole class?

No. The skill directs total replacement to a separate Preference skill, since plugins only intercept methods.

### What tools does Create plugin use to verify the plugin?

It asks the agent to resolve LSP diagnostics from marko-lsp and then call the find_plugins_targeting MCP tool to confirm discovery.

### How do I install Create plugin in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/create-plugin to use it in all your projects, or to .claude/skills/create-plugin in one project. Or install the marko-skills plugin, which includes it: /plugin marketplace add marko-php/marko, then /plugin install marko-skills@marko.

### Does Create plugin run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Create plugin?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Create plugin?

The closest alternatives to Create plugin are Writing plugins, Create module, Moodle hooks API, Moodle plugin development and Minecraft plugin development.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Writing plugins](https://ai-powered.com/skills/writing-plugins-xiaolai): Writing plugins is an open-source agent skill for developer tools.
- [Create module](https://ai-powered.com/skills/create-module): Create module is an open-source agent skill for developer tools.
- [Moodle hooks API](https://ai-powered.com/skills/moodle-hooks-api): Moodle hooks API is an open-source agent skill for developer tools.
- [Moodle plugin development](https://ai-powered.com/skills/moodle-plugin-development): Moodle plugin development is an open-source agent skill for developer tools.
- [Minecraft plugin development](https://ai-powered.com/skills/minecraft-plugin-development): Minecraft plugin development is an open-source agent skill for developer tools.
- [Writing hooks](https://ai-powered.com/skills/writing-hooks-xiaolai): Writing hooks is an open-source agent skill for developer tools.
- [Plugin creator](https://ai-powered.com/skills/plugin-creator): Plugin creator is a free agent skill for developer tools.
- [Skill creator](https://ai-powered.com/skills/skill-creator): Skill creator is a free agent skill for ai models and llm tooling.

---
Source: https://ai-powered.com/skills/create-plugin
