name: claude-plugin:structure-refactor
description: >-
Fix a claude-plugin marketplace repo's directory structure toward the
standard layout. Dry-run by default (plan only, no writes); --apply
performs changes. Scope --mp/--mandatory fixes mandatory items M1-M6
only (create dirs, git mv, minimal marketplace.json/plugin.json
skeletons); --op/--recommended adds recommended R1-R5 fixes (empty
placeholder stubs + naming correction + README link backfill). Idempotent.
Supports both mono (plugins/<p>/skills/) and single (repo-root
skills/) layouts — auto-detected, or forced with --single / --mono;
it fixes toward the detected mode's golden layout and never converts
single↔mono (that is an out-of-scope, guarded no-op).
Use when the user
says "fix my claude-plugin repo structure", "make this marketplace repo
standard", "/claude-plugin:structure-refactor". Sister skills:
claude-plugin:structure-check (finds what this fixes),
claude-plugin:rename-repo (renames the repo to the team convention).
Under --op, R1 guides are generated by delegating to /devx:visualize
and GitHub Pages is auto-activated (github.com + GHE); R2 usage samples
remain placeholder stubs.
compatibility:
tools: Read, Glob, Grep, Write, Edit, Bash
metadata:
model_recommendation:
tier: sonnet
reason: "structure correction: dir creation + git mv history-preserving moves + JSON skeletons + placeholder stubs; bounded multi-file write, no deep reasoning"
claude: prefer
non_claude: advisory-only
claude-plugin Structure Refactorer
Help
If arg #1 is -h, --help, or help, read references/help.md and output
its content verbatim, then stop. No filesystem changes.
Step 1: Parse Args + Resolve Path
Positional [repo-path] (default = current dir). Flags:
--apply— execute changes. Absent → dry-run (plan only, no writes).--mandatory/--mp— scope = M1-M6 only (default scope).--recommended/--op— scope = M1-M6 + R1-R5.--single/--mono— force the target layout mode, overriding auto-detection (Step 2). Mutually exclusive; if both given, last wins.--mpand--optogether → error + usage, stop.
Confirm the path exists. test -d <path>/.git: not a git repo → warn (moves
fall back to mv). Dirty tree → show the dry-run plan and require an explicit
--apply before writing (never auto-apply on a dirty tree).
Step 2: Detect Mode + Compute Plugin Roots + Evaluate Current ↔ Target
Read references/structure-spec.md (embedded SSOT) for layout modes, mode detection/override, and mandatory items by mode.
- Detect the current mode (priority: flag → manifest
plugins[].source→ filesystem → defaultmono). - Conversion guard — forced mode ≠ detected current layout → out of scope (rules in spec → "Mode override = layout conversion").
- Compute the plugin-root set:
mono→ eachplugins/*/;single→ repo root./(exactly one). - Discover skills and run M1-M6 / R1-R5 evaluation over the roots to compute the current → target diff.
Step 3: Build the Plan
Read references/plan-and-report-templates.md. Produce an ordered change
list, each tagged with its driving check ID (M1-M6, and R1-R5 only when
scope is --op). Paths are plugin-root relative — single targets root
./ (no plugins/ dir ever created); mono targets plugins/<p>/.
Already-correct items produce no action (idempotent). The plan header states
the detected/forced mode; an unsupported conversion produces only the
[convert] warning line.
Step 4: Dry-run or Apply
- Dry-run (default): print the plan only. Touch nothing.
- Conversion required (forced mode ≠ detected): print the
[convert]warning and stop — even under--apply, write nothing. --apply: execute the plan in order following the Apply rules (mkdir → move → skeleton, fully listed inreferences/plan-and-report-templates.md);--opadds R1-R5 — seereferences/op-rules.md.
Step 5: Report
Use the completion report template in
references/plan-and-report-templates.md — end with [OK]/[FAIL] + a
key=value summary, then the next-action hint:
- after a dry-run:
Next: /claude-plugin:structure-refactor <path> --apply [--op] - after
--apply:Next: /claude-plugin:structure-check <path>(re-verify)
Constraints
See references/constraints.md for the full Never/Always rule set (dry-run default, idempotency, git mv preference, mode-conversion guard, soft-fail behaviors).