Skip to content

epic(cli): add --as-plugin flag to cast for claude code plugin output #134

@kriscoleman

Description

@kriscoleman

epic(cli): add --claude-plugin flag to cast for claude code plugin output

Add a new --claude-plugin flag to ailloy cast that packages a mold's rendered output as a Claude Code plugin and writes it to Claude's plugin discovery location. This opens a third distribution channel — alongside project install (cast) and author tooling (plugin generate) — aimed at end users who want to install a published Ailloy mold as a Claude Code plugin without authoring overhead.

Note: the flag was originally proposed as --as-plugin and renamed to --claude-plugin during implementation. Ailloy is tool-agnostic (Claude Code, Cursor, OpenCode, Codex, …), so the target tool needs to be explicit in the flag name. The renamed surface leaves room for future per-tool plugin formats (--cursor-plugin, --opencode-plugin, …) without flag-name churn. The override flags --plugin-name / --plugin-version stayed generic so they can apply to any future plugin format.

Why

Today there are two consumer paths for a mold:

  1. ailloy cast — renders blanks with flux variables and installs them at their declared destinations. Project-install path.
  2. ailloy plugin generate — bundles a mold into Claude Code plugin format using a custom Transformer. Does not render flux templates and does not handle skills, AGENTS.md, or workflows. Author-facing tool.

There is no path for a user who wants the simplicity of "install this mold as a Claude Code plugin" with full flux rendering and the same blank coverage cast already provides. --claude-plugin fills that gap.

Key Design Decisions

  • Layering: pure derivation in ailloy. Molds do not need to be plugin-aware. plugin.json is synthesized from mold.yaml.
  • Internals: cast delegates to a new pkg/plugin/Packager. The existing plugin generate command and its Transformer are untouched for now.
  • Flag surface: --claude-plugin, plus optional --plugin-name and --plugin-version overrides. The --plugin-* flags are generic so they can apply to future per-tool plugin formats.
  • Output location: .claude/plugins/<slug>/ by default, ~/.claude/plugins/<slug>/ with --global.
  • Interactions: --with-workflows is silently skipped (warn); --set / --values work normally; CLAUDE.md @AGENTS.md import prompt is skipped (AGENTS.md is bundled inside the plugin instead).
  • Overwrite: re-running cast replaces the contents of the target plugin directory only; sibling plugin directories are untouched.

Acceptance Criteria

  • --claude-plugin flag added to ailloy cast (boolean)
  • --plugin-name <name> and --plugin-version <ver> flags added, validated to require a plugin output flag
  • New pkg/plugin/packager.go with Packager, RenderedFile, ManifestInput types and Package(...) method
  • Path translation table implemented per spec (.claude/commands/commands/, .claude/skills/skills/, .claude/agents/agents/, .claude/hooks/hooks/, AGENTS.md and README.md to plugin root, workflows dropped, unrecognized paths dropped with debug log)
  • .claude-plugin/plugin.json synthesized from mold.yaml with flag overrides; missing version defaults to 0.1.0; missing author/description omitted (no empty strings)
  • Slugification of plugin name (lowercase, non-alphanumeric → -, trim, error on empty result)
  • --global routes to ~/.claude/plugins/<slug>/; project-local cast routes to .claude/plugins/<slug>/
  • --with-workflows + --claude-plugin → warn-and-skip workflows
  • Cast skips the CLAUDE.md @AGENTS.md import prompt when --claude-plugin is set; AGENTS.md is bundled inside the plugin
  • Re-running cast overwrites the target plugin directory's contents only, never sibling directories
  • Path collisions between two CastDest entries error and name both sources
  • Unit tests for Packager (path translation, manifest synthesis, wipe semantics, missing-field handling, target-is-file error)
  • Unit tests for new flag validation in cast (overrides without --claude-plugin error, slugification cases)
  • Integration tests covering: full layout assertion against a fixture mold, workflow-skip warning, flux-rendering propagation (--set), re-cast wipe behavior, --global routing via temp HOME
  • Test fixture mold (commands + skill + AGENTS.md + README + one flux-templated file)
  • User-facing docs updated (docs/cast-claude-plugin.md)

Notes

  • Out of scope: deprecating ailloy plugin generate (deferred — may be revisited once --claude-plugin proves itself), plugin marketplace/signing/registry concerns, smart-merge on re-cast, workflow blanks inside plugins, mold-side plugin: metadata blocks.
  • Open question: exact Claude Code plugin discovery paths for project-local vs global plugins. The implementation assumes .claude/plugins/<slug>/ and ~/.claude/plugins/<slug>/.
  • Brainstormed via /superpowers:brainstorm 2026-05-01.
  • Branch: kriscoleman/cast-plugin-flag. PR: feat: add --claude-plugin flag to cast for claude code plugin output #136.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions