code-style
БесплатноБез исполняемых скриптовНе проверенPHP coding standards and WordPress patterns for ActivityPub plugin. Use when writing PHP code, creating classes, implementing WordPress hooks, or structuring…
от Automattic★ 583 звезды на GitHubОб этом скилле
ActivityPub PHP Conventions
Plugin-specific conventions and architectural patterns for the ActivityPub plugin.
First rule: reuse before writing. Prefer WordPress core functions, then existing plugin helpers (includes/functions*.php, Sanitize, src/shared/), over any new implementation — and never swap a core-function-based check for bespoke logic. See "Reuse Core Functionality First" in docs/php-coding-standards.md.
Quick Reference
File Naming
class-{name}.php # Regular classes.
trait-{name}.php # Traits.
interface-{name}.php # Interfaces.
Namespace Pattern
namespace Activitypub;
namespace Activitypub\Transformer;
namespace Activitypub\Collection;
namespace Activitypub\Handler;
namespace Activitypub\Activity;
namespace Activitypub\Rest;
Text Domain
Always use 'activitypub' for translations:
\__( 'Text', 'activitypub' );
\_e( 'Text', 'activitypub' );
WordPress Global Functions
When in a namespace, always escape WordPress functions with backslash: \get_option(), \add_action(), etc.
Imports and Class References
Two symmetric rules, both enforced in review:
// Plugin classes: import with `use`, never reference inline.
use Activitypub\Collection\Outbox;
Outbox::add( $activity ); // ✅
\Activitypub\Collection\Outbox::add( $activity ); // ❌ no inline namespaces
// Global (WordPress/PHP) classes: reference inline with a backslash, never import.
$query = new \WP_Query( $args ); // ✅
class Command extends \WP_CLI_Command {} // ✅
use WP_Query; // ❌ no `use` for global classes
Comments
/* */for multi-line comments,//for single-line — not stacked//lines.- Place each comment at the line it documents, not as one block above a block of code. Detail is fine; split it per statement.
- Explain the non-obvious mechanic that makes a line necessary, never the bug or ticket behind it. A line that speaks for itself gets no comment.
Plugin Idioms
- No
try/catchortry/finally. Hook a filter around a call asadd_filter→ call →remove_filter, and report failures through return values (WP_Error,false). - "C2S" stays out of identifiers, file names and code comments; the official name is "ActivityPub API", and "client" is fine for the consuming side.
- Anything that leaves the server (REST responses, deliveries) is rendered with
$activity->to_array( false, false ): no per-item@context, nobto/bcc. Storage keepsto_array( true, true )for the round trip. - A few duplicated lines at two call sites beat a new helper; a whole duplicated method body across sibling classes does not.
Comprehensive Standards
See docs/php-coding-standards.md for complete WordPress coding standards.
See docs/php-class-structure.md for detailed directory organization.
Directory Structure
includes/
├── class-*.php # Core classes.
├── activity/ # Activity type classes.
├── collection/ # Collection classes.
├── handler/ # Activity handlers.
├── rest/ # REST API endpoints.
├── transformer/ # Content transformers.
└── wp-admin/ # Admin functionality.
integration/ # Third-party integrations (root level).
ActivityPub Architectural Patterns
Transformers
Convert WordPress content into ActivityPub objects.
When to use: Converting posts, comments, users, or custom content types into ActivityPub format.
Base class: includes/transformer/class-base.php
Pattern:
namespace Activitypub\Transformer;
class Custom extends Base {
/**
* Transform object to ActivityPub format.
*
* @return array The ActivityPub representation.
*/
public function transform() {
$object = parent::transform();
// Custom transformation logic.
return $object;
}
}
Examples:
includes/transformer/class-post.php- Post transformation.includes/transformer/class-comment.php- Comment transformation.includes/transformer/class-user.php- User/actor transformation.
Handlers
Process incoming ActivityPub activities from remote servers.
When to use: Processing incoming Follow, Like, Create, Delete, Update, etc. activities.
Pattern: Each handler processes one activity type from the inbox.
Examples:
includes/handler/class-follow.php- Process Follow activities.includes/handler/class-create.php- Process Create activities.includes/handler/class-delete.php- Process Delete activities.includes/handler/class-like.php- Process Like activities.
Collections
Implement ActivityPub collections (Followers, Following, etc.).
When to use: Exposing lists of actors, activities, or objects via ActivityPub.
Examples:
includes/collection/class-followers.php- Followers collection.includes/collection/class-following.php- Following co
Установить code-style в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл code-style?
PHP coding standards and WordPress patterns for ActivityPub plugin. Use when writing PHP code, creating classes, implementing WordPress hooks, or structuring plugin files.
Как установить скилл code-style?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл code-style запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic