wp-plugin-architecture

Architect WordPress plugin folder layouts with PSR-4 and prefixed hooks.

21|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill wp-plugin-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wp-plugin-architecture
Source: https://github.com/Lonsdale201/wp-agent-skills/tree/main/plugin-scaffold/wp-plugin-architecture
Command: npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill wp-plugin-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designs and reviews the internal architecture of a WordPress plugin — folder layout, PSR-4 one-class-per-file discipline, Schema/Constants placement, composition-root vs singleton decisions, conditional asset enqueueing, script config via wp_add_inline_script, and prefixed custom-hook naming. Use when scaffolding includes/src, reviewing class organization, asset enqueue code, repeated strings, or "should I make this a singleton" decisions.

Core Features & Use Cases

  • Two organization strategies: By-type and By-feature, with guidance on when to choose each.
  • Centralization of constants and hooks: promote code reuse and reduce typos.
  • Asset enqueueing best practices: correct hooks, gating, dependencies, cache busting, and inline scripts.
  • Hook naming conventions: consistent prefixing to avoid collisions.

Quick Start

Choose an organization strategy (By-type or By-feature) for your plugin and implement centralized constants and proper hook naming.

Frequently Asked Questions about wp-plugin-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best way to structure a WordPress plugin to ensure scalable code organization?

Organize WordPress plugin folders using By-type or By-feature strategies, enforce PSR-4 one-class-per-file discipline, and centralize constants and hooks to promote reuse and reduce typos.

How do I enqueue assets correctly in a custom WordPress plugin?

Enqueue WordPress plugin assets conditionally using correct hooks, dependency gating, cache busting, and script configuration via wp_add_inline_script to optimize loading.

When should I use a singleton versus a composition root in WordPress plugin architecture?

Evaluate WordPress plugin singleton versus composition-root decisions by auditing class organization and dependency injection needs to enforce scalable structure without unnecessary single-instance constraints.

How does PSR-4 autoloading apply to organizing WordPress plugin classes?

PSR-4 compatibility in WordPress plugins enforces one-class-per-file discipline within includes/src folders, mapping namespace paths to file systems for automated class loading.

Why should I prefix custom hooks in my WordPress plugin?

Prefixing custom hooks with the WordPress plugin slug enforces consistent naming conventions and prevents hook collisions with other plugins or themes sharing identical hook names.

Does this WordPress plugin architecture approach work for auditing existing code?

Yes, this WordPress plugin architecture approach audits existing code by evaluating folder layout, constants placement, hook prefixing, and asset enqueue decisions to enforce structural consistency.