How to create a Claude Code plugin and a local marketplace: how I share agents, skills and hooks across every project
A Claude Code plugin is a folder that bundles skills, subagents and hooks, with a .claude-plugin/plugin.json manifest. To get it in every project, put it in a local marketplace, meaning a folder that holds .claude-plugin/marketplace.json, then run claude plugin marketplace add and claude plugin install <plugin>@<marketplace>. That is how I have shared my development chain since October: one versioned source, installed once, and every fix reaches all my repositories.
The problem: copied configuration that drifts
Before the plugin, my chain lived loose in ~/.claude: one skill and four subagents, with no git history. The check scripts were copied into three repositories. When I took stock, the copies had already drifted: a fix made in one repository did not exist in the other two.
The Claude Code documentation is clear about it: a skill, a subagent or a hook works fine on its own. A plugin is for when you want several of those pieces shipped as one unit, installed with one command and updated in one place. That was exactly my case: agents, skills, three hooks and their scripts, which only make sense together.
The structure: a repository that is also a marketplace
My plugin is called pipeline and lives in a git repository that also acts as a marketplace, named naelo. Here is what it holds:
naelo-pipeline/
.claude-plugin/marketplace.json # the catalog: name, owner, list of plugins
plugins/pipeline/
.claude-plugin/plugin.json # the manifest: name, version, description
skills/build/SKILL.md # becomes the /pipeline:build command
skills/init/SKILL.md # becomes /pipeline:init
agents/tests.md # subagent pipeline:tests
agents/code.md # subagent pipeline:code
agents/reviewer.md # subagent pipeline:reviewer
hooks/hooks.json # the hooks, in the same shape as settings.json
scripts/ # the scripts the hooks and skills callThe marketplace.json file requires three fields: name, owner and a plugins array. Each entry gives a name and a source, here the relative path ./plugins/pipeline, written from the marketplace root.
- The prefix is automatic. Everything the plugin adds carries its name as a prefix: the skill in
skills/build/runs as/pipeline:build, therevieweragent is namedpipeline:reviewer. You cannot mistake them for your personal commands. - The same name everywhere. Keep the entry name in
marketplace.jsonidentical to thenameinplugin.json. The documentation lists that mismatch as a common cause of failed installs. - No hard-coded paths. A hook does not know where the plugin will be installed. It calls its scripts through
${CLAUDE_PLUGIN_ROOT}, in double quotes so the path stays one word for the shell.
Each agent declares its model and tools in its header: the agents that write tests and code run on Sonnet, the reviewer on Opus with read-only tools; I explain that choice, and what made it change, in the article on each subagent's model. The split of roles is detailed in the article on writing tests before the code.
Install once, edit in place
Three commands, run once per machine:
claude plugin validate ./naelo-pipeline
claude plugin marketplace add ./naelo-pipeline
claude plugin install pipeline@naeloThe install defaults to user scope: the plugin is enabled in every project on the machine. And because the marketplace is a local folder with a relative source, Claude Code reads the plugin files straight from that folder. An edit takes effect at the next session, or right away with /reload-plugins, with no version bump.
That is what makes the plugin pleasant day to day: I fix a skill in the repository, reload, and every project has the fix. Before committing a change, two checks: claude plugin validate . for the structure, and a test-all.sh script that runs the tests of the plugin's hooks and scripts.
What broke, and the rules I took from it
- Hooks apply everywhere. The hooks of an enabled plugin fire as soon as the session loads the plugin, not only when you use its skills. Installed at user scope, my hook that blocks a session from ending red would have bothered repositories that asked for nothing. Rule written into the plugin's design document: every hook first checks that a
.claude/pipeline.jsonfile exists in the project, otherwise it exits without doing anything. Those hooks are detailed in the article on Claude Code hooks. - The plugin does not know your repositories. It cannot tell whether a project tests with Jest, Vitest or pytest. Each repository that adopts the chain declares its commands in
.claude/pipeline.json: full check, fast check, a command to test one file, a time limit. The/pipeline:initcommand writes that file. This contract is what replaced the copied scripts. - The plugin's scripts are still code that breaks. On the day the plugin was created, the first real run exposed a defect: the check script computed its git tree fingerprint including files that were never committed. So the full checks ran again every time, for nothing. The case is recorded as a postmortem in the plugin repository, with the planned fix and the test to add.
- Every plugin weighs on the context. The name and description of each skill and each agent stay in Claude's context on every turn, even when the plugin is not used. Short, precise descriptions pay off.
One last limit: a local marketplace stays on your machine. A cloud session, on claude.ai/code for instance, does not load the plugins from your local settings. For team use, push the marketplace to a git host.
What the plugin added on top: a shared ledger
One effect I had not planned: the plugin repository became the right place to measure the chain. Each run writes into ledger/<repository>/ one cost line per agent, one outcome line per task, and a postmortem when a task is still blocked after two review rounds.
Because those ledgers are versioned in one place for every project, the /pipeline:retro command reads them together and proposes changes to the chain (the full loop is described here). A lesson learned on one app helps the others, which was impossible with scattered copies.
How to start
- Start from what you already have. If you have skills in
~/.claude/skills/or agents in.claude/agents/that you copy from project to project, those are your first candidates. - Create the plugin folder with
.claude-plugin/plugin.json(onlynameis required), thenskills/,agents/andhooks/hooks.jsonas needed. During development, the--plugin-diroption loads the plugin from its folder, with no marketplace. - Add the marketplace when you want the plugin in every project: a
marketplace.jsonnext to it, thenclaude plugin validate,claude plugin marketplace addandclaude plugin install. - Protect the repositories that asked for nothing from your very first hook, with an exit condition at the top of the script.
One detail that surprises people: a CLAUDE.md placed at the plugin root is not loaded. A plugin's instructions are written as skills. My general rules therefore stay in my global CLAUDE.md, whose content I detail in the article on CLAUDE.md best practices.
Article written with the help of AI, from my daily practice and my projects.
The whole notebook