cc-os/plugins/cc-architect/workflows/create-plugin.md

152 lines
4.4 KiB
Markdown
Raw Permalink Normal View History

# Workflow: Create Plugin
Create a new Claude Code plugin from scratch with complete structure.
## Who should do this work
| Phase | Model | Why |
|-------|-------|-----|
| Scope clarification | Main | User interaction required |
| Scaffolding | Haiku | Mechanical file/directory creation |
| Skill creation | Sonnet | Content drafting (delegates to skill workflows) |
| Config creation | Haiku | Template-based file creation |
| Validation | Opus | Final quality decisions |
## When to use
- Creating new Claude Code plugin from scratch
- Plugin directory doesn't exist yet
## Before you start
If concept unclear, brainstorm: `references/brainstorming/workflow.md`
## Dependencies (optional)
Initial skill creation delegates to `${CLAUDE_PLUGIN_ROOT}/workflows/plugin-add-skill.md`.
## Inputs required
- **plugin_name** - kebab-case
- **plugin_purpose** - Problem this solves
- **include_skill** - yes/no (default yes)
- **skill_name** - If including skill (defaults to plugin_name)
For descriptions: Read `${CLAUDE_PLUGIN_ROOT}/references/layout/descriptions.md` - "when/why" formula, not implementation.
## Task document
Create: `.claude/plugin-data/plugin-architect/tasks/new-plugin-<plugin-name>-<date>.md`
---
## Pattern consideration
See `references/tool-patterns/catalog.md`.
| Question | If Yes |
|----------|--------|
| Plugin concept unclear? | Brainstorm first |
| Skills modify files? | Skills need verification (delegated to skill-architect) |
| Plugin creates files in user projects? | Follow [plugin-data-convention](../references/conventions/plugin-data-convention.md) |
| Maintained long-term? | Include reversion protection scaffolding |
| Orchestrate 2+ workflows with synthesis? | Consider [Role-Workflow pattern](../references/tool-patterns/role-workflow-pattern.md) |
---
## Subtasks
### 1. Clarify scope
Subagent: Main with user.
**Do:**
- Confirm plugin name and purpose
- Ask if needs initial skill (most do)
- Write to task doc: `## Scope`
---
### 2. Scaffold plugin structure
Subagent: Haiku.
Read: Task doc (scope), `${CLAUDE_PLUGIN_ROOT}/references/layout/plugin-structure.md`
**Do:**
- **Detect author name:**
```bash
git config user.name
```
- If returns a name: use it for `author.name` in plugin.json
- If empty/fails: inform user and tell them to set it:
```
Git author name not configured. Set it with:
git config --global user.name "Your Name"
```
Then prompt user for their name to continue.
- Create `../<plugin-name>/` in marketplace
- Create `.claude-plugin/plugin.json` with required fields including author
- Create empty `skills/` directory
- Reversion protection: `.decisions/` directory
- Note in task doc: "Skills create their own invariants.md and examples/golden/"
- Register in `marketplace.json` using the Ruby config script:
```bash
ruby ${CLAUDE_PLUGIN_ROOT}/scripts/plugin_config/plugin_config.rb register \
--plugin=<plugin-name> \
--marketplace_file=<path-to-marketplace.json>
```
If exit code is non-zero, fall back to manual JSON editing and note in task doc.
- Write to task doc: `## Scaffolded Files`
---
### 3. Create initial skill (if requested)
Subagent: Depends on availability.
**Do:**
- Use `${CLAUDE_PLUGIN_ROOT}/workflows/plugin-add-skill.md`
- Pass: plugin_path, skill_name, skill_purpose
---
### 4. Create config workflow and command (optional)
Subagent: Haiku.
Read: Task doc, `templates/config-workflow.tmpl`, `templates/config-command.tmpl`
**Do:**
- Ask user if plugin needs configuration (most don't initially)
- If yes:
- Create `workflows/config.md` from template
- Create `<plugin-path>/commands/config.md` from template
- Replace `{{plugin_name}}` placeholders with actual plugin name
- Write to task doc: `## Config Files Created`
- Remind user:
- "Customize the config workflow for your plugin's specific settings"
- "Common customizations: API keys, file paths, feature toggles, output formats"
- "Config is stored in `.claude/plugin-data/<plugin-name>/config.json`"
---
### 5. Finalize and report
Subagent: Main.
**Do:**
```bash
ruby ${CLAUDE_PLUGIN_ROOT}/scripts/plugin_config/plugin_config.rb validate \
--plugin_path=<plugin-path>
```
Exits 0 if all structural checks pass, 1 if any fail (see JSON `issues` array for details).
- Fix validation errors
- Verify structure matches Claude Code spec
- Summarize created
- Suggest next steps
---
## Reflection
Friction? Read `references/self-improvement/friction-reflection.md` and add to task doc.