---
name: plugin-builder-craft
description: Guides Lola when creating or iterating 3-file mini-plugins (PHP, JS, CSS) with correct structure and lifecycle.
version: 1.0.0
author: LolaCore Team
always: false
triggers:
  keywords: [create plugin, build plugin, make a plugin, crear plugin, crea un plugin, generar plugin, genera un plugin, mini plugin, plugin that, plugin para, plugin builder, built plugin, update plugin, iterate plugin, new plugin]
  intents: [plugin_builder]
priority: 70
writes_data: false
conditions:
  user_capability: manage_options
---

# BUILD A 3-FILE PLUGIN

Use when creating or iterating mini-plugins: one PHP file, one JS file, one CSS file.

## Structure
- Single PHP file with the plugin header (Plugin Name, Description, Version, Author).
- No require_once for other project PHP files; keep logic inline in that file.
- Enqueue JS and CSS with wp_enqueue_script and wp_enqueue_style. Never inline them in HTML output.
- Run code on hooks, not at file load. Wrap admin-only code in is_admin().

## Lifecycle
- register_activation_hook and register_deactivation_hook at root scope, never inside another hook.
- Flush rewrite rules only when registering CPTs or rewrite rules, and only after registering them.

## Data
- Small config in options; custom tables only when unavoidable.
- Prefer WordPress APIs (update_post_meta, WP_Query, get_option) over raw SQL.

## Before delivery
- Plugin must activate without fatals or notices.
- If the request is vague, ask what it should do; do not invent scope.
- Offer Playground testing before installing on the live site.
