# Create Component

> Create a New WP Rig Component

- Skill: `comeonoliver/create-component` (Agent Skill)
- Install (CLI): `npx skillmds@latest add comeonoliver/create-component`
- Raw SKILL.md: https://api.skillmd.com/api/skills/comeonoliver/create-component/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Web & Frontend
- Author: ComeOnOliver (https://skillmd.com/u/comeonoliver)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/comeonoliver/create-component

---

# Create a New WP Rig Component

This skill provides the recipe to scaffold and register a new theme component.

## Step 1: Use the Scaffolding Script

WP Rig provides a dedicated script to create the component directory and initial class file.

```bash
npm run create-rig-component "Your Feature Name"
```

This will:
1. Create a folder in `inc/Your_Feature_Name/`.
2. Generate `Component.php` inside it, implementing `Component_Interface`.
3. **Automatically Register** the new component in `inc/Theme.php` by adding it to the `get_default_components()` method.

## Step 2: Implement Hooks

After scaffolding, the component is already wired and ready. Open your new `inc/Your_Feature_Name/Component.php` and use the `initialize()` method to add WordPress hooks.

```php
public function initialize() {
	add_action( 'wp_enqueue_scripts', array( $this, 'action_enqueue_scripts' ) );
}
```

## Best Practices

- Always use `npm run create-rig-component` instead of manual creation.
- Ensure the namespace matches `WP_Rig\WP_Rig\{Feature}`.
- Implement only the interfaces you need (e.g., `Templating_Component_Interface` if you provide template tags).
- If the scaffolding script fails to auto-wire (check command output), manually add `new Your_Feature_Name\Component(),` to `inc/Theme.php`.

