ai, agents, deep dive,

Deep Dive: Inside cursor/plugins, a Schema-Validated Marketplace and a Hook-Driven Ralph Loop

Cui Cui Follow Nov 27, 2026 · 4 mins read
Deep Dive: Inside cursor/plugins, a Schema-Validated Marketplace and a Hook-Driven Ralph Loop
Share this

cursor/plugins is described as “Cursor plugin specification and official plugins”. This post is a source reading at commit b7b93c3: I cloned the repo and read README.md, .cursor-plugin/marketplace.json, schemas/plugin.schema.json, schemas/marketplace.schema.json, scripts/validate-plugins.mjs, .github/workflows/validate-plugins.yml, create-plugin/ and ralph-loop/. Facts come from that code; interpretation is marked.

Companion tutorial: how to scaffold and validate your own plugin is on Cui.Guru: Scaffold and validate a Cursor plugin.

The workflow in motion

Animated workflow: a plugin directory is registered in marketplace.json, the validator checks each plugin.json against a JSON schema with Ajv, then checks names and versions, and CI runs the same script so the plugin is marketplace-ready.

Architecture

The README describes a multi-plugin marketplace: the root .cursor-plugin/marketplace.json lists all plugins and each plugin directory has its own .cursor-plugin/plugin.json. A parallel .claude-plugin/marketplace.json exists at the root too, and the validator checks it for name and version consistency. The Cursor marketplace file lists 160 plugins.

The core design idea

Interpretation: the repo keeps the contract small and machine-checked. A plugin needs only a name; component types are paths or globs (hooks and MCP servers may also be inline objects), so the manifest is mostly an index and the files themselves carry behaviour. The schema is strict (additionalProperties: false), so a typo in a key is an error rather than silently ignored, and the single validator is the gate that CI runs on pull requests touching manifests, schemas or scripts.

A second idea shows in ralph-loop: behaviour comes from hooks, not from a daemon. Its hooks.json registers an afterAgentResponse hook and a stop hook. The stop hook’s header comment says that when the agent finishes a turn it decides whether to feed the same prompt back or let the session end.

Source excerpts

The manifest schema, from schemas/plugin.schema.json:

"required": ["name"],
"additionalProperties": false,
"properties": {
  "name": {
    "type": "string",
    "minLength": 1,
    "pattern": "^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$",

The name check in scripts/validate-plugins.mjs:

if (pluginJson.name && pluginJson.name !== entry.name) {
  fail(
    `Plugin "${entry.name}": marketplace name does not match plugin.json name "${pluginJson.name}"`
  );
}

Hook registration, from ralph-loop/hooks/hooks.json:

{
  "version": 1,
  "hooks": {
    "afterAgentResponse": [{ "command": "./hooks/capture-response.sh" }],
    "stop": [{ "command": "./hooks/stop-hook.sh", "loop_limit": null }]
  }
}

The loop decision, from ralph-loop/hooks/stop-hook.sh. It stops when no state file exists, when the completion flag is set, when state is corrupted or the prompt is empty, or when max_iterations is reached (a value of 0 means no limit); otherwise it increments the counter and returns the prompt:

if [[ $MAX_ITERATIONS -gt 0 ]] && [[ $ITERATION -ge $MAX_ITERATIONS ]]; then
  echo "Ralph loop: max iterations ($MAX_ITERATIONS) reached." >&2
  rm -f "$STATE_FILE" "$DONE_FLAG"
  exit 0
fi
...
jq -n --arg msg "$FOLLOWUP" '{"followup_message": $msg}'

The ralph-loop README explains the effect: the prompt never changes, the code does, and the agent sees its own previous edits in the working tree and git history.

Takeaways

  • Make the plugin contract a JSON schema and run it in CI; one small script is the manifest-validation gate (the workflow also checks generated pstack trees and runs pstack script tests).
  • Index components by path, so adding a skill or rule needs no manifest edit beyond the directory defaults.
  • Check cross-file invariants (name equality, version agreement) that a schema alone cannot express.
  • Hooks can drive agent loops: a stop hook that returns a follow-up message continues the session, and exiting silently ends it.
  • Always bound loops with an iteration limit and a completion signal.

Want help packaging your team’s agent workflows as plugins? Get in touch.

Join Newsletter
Get the latest news right in your inbox. We never spam!
Cui
Written by Cui Follow
Hi, I am Z, the coder for cuizhanming.com!

Click to load Disqus comments