mcpbeat Sign in

Code Style Agent Skill

PHP coding standards and WordPress patterns for ActivityPub plugin. Use when writing PHP code, creating classes, implementing WordPress hooks, or structuring plugin files.

2k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
576
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/Automattic/wordpress-activitypub --skill code-style

The instruction itself

22 sections, as written by the author

ActivityPub PHP Conventions

Plugin-specific conventions and architectural patterns for the ActivityPub plugin.

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.

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 collection.

REST API Controllers

Expose ActivityPub endpoints.

Namespace: ACTIVITYPUB_REST_NAMESPACE

Examples:

  • includes/rest/class-actors-controller.php - Actor endpoint.
  • includes/rest/class-inbox-controller.php - Inbox endpoint.
  • includes/rest/class-outbox-controller.php - Outbox endpoint.
  • includes/rest/class-followers-controller.php - Followers collection endpoint.

Plugin-Specific Helper Functions

// Get remote actor metadata.
$metadata = get_remote_metadata_by_actor( $actor_url );

// Convert ActivityPub object to URI string.
$uri = object_to_uri( $object );

// Enrich content with callbacks.
$content = enrich_content_data( $content, $pattern, $callback );

// Resolve WebFinger handle to actor URL.
$resource = Webfinger::resolve( $handle );

// Check whether a post is disabled for ActivityPub (the federation pipeline gate).
$disabled = is_post_disabled( $post );

Real Codebase Examples

Core Classes:

  • includes/class-activitypub.php - Main plugin initialization.
  • includes/class-dispatcher.php - Activity dispatching to followers.
  • includes/class-scheduler.php - WP-Cron integration for async tasks.
  • includes/class-signature.php - HTTP Signatures for federation.

Activity Types:

  • includes/activity/class-activity.php - Activity class (Create, Follow, Undo, etc. are built from this).
  • includes/activity/class-base-object.php - Base object class.
  • includes/activity/extended-object/ - Extended object types (e.g. Event).

Integrations (see Integration Patterns):

  • integration/class-buddypress.php - BuddyPress integration.
  • integration/class-jetpack.php - Jetpack integration.
  • integration/class-opengraph.php - OpenGraph integration.

Common Initialization Patterns

Static Initialization

class Feature {
    /**
     * Initialize the class.
     */
    public static function init() {
        \add_action( 'init', array( self::class, 'register' ) );
        \add_filter( 'activitypub_the_content', array( self::class, 'filter' ) );
    }
}

Singleton Pattern

class Manager {
    private static $instance = null;

    public static function get_instance() {
        if ( null === self::$instance ) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    private function __construct() {
        $this->init();
    }
}

Custom Hook Patterns

Actions:

\do_action( 'activitypub_handled_create', $activity, $user_ids, $success, $result );
\do_action( 'activitypub_followers_pre_remove_follower', $follower, $user_id, $actor );

Filters:

$array   = \apply_filters( 'activitypub_activity_object_array', $array, $class, $id, $object );
$content = \apply_filters( 'activitypub_the_content', $content, $post );
$types   = \apply_filters( 'activitypub_actor_types', $types );

Version Numbers

Always use 'unreleased' for version strings in new code. The release script automatically replaces these with the actual version number during the release process.

PHPDoc tags:

/**
 * New function description.
 *
 * @since unreleased
 */
function new_feature() {}

/**
 * Old function.
 *
 * @deprecated unreleased Use new_feature() instead.
 */
function old_feature() {}

Deprecation functions:

\_deprecated_function( __METHOD__, 'unreleased', 'New_Class::new_method' );
\_deprecated_argument( __METHOD__, 'unreleased', \esc_html__( 'Message', 'activitypub' ) );
\_doing_it_wrong( __METHOD__, \esc_html__( 'Message', 'activitypub' ), 'unreleased' );

Never hardcode version numbers like '5.1.0' — always use 'unreleased'.

Other skills for the same job

different authors, same section of the catalogue
Changelog Generator
by frostant
×9

Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.

774 tokens
Codex
by softaworks
×2

Use when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing. Uses GPT-5.2 by default for state-of-the-art software engineering.

2k tokens
Memory Safety Patterns
by ComeOnOliver
×2

Implement memory-safe programming with RAII, ownership, smart pointers, and resource management across Rust, C++, and C. Use when writing safe systems code, managing resources, or preventing memory bugs.

6k tokens
Pysam
by K-Dense-AI
×1

Python/HTSlib workflows for genomic files. Use when reading, querying, filtering, or writing SAM/BAM/CRAM, VCF/BCF, FASTA/FASTQ, or tabix data with pysam, including pileup, coverage, indexing, and CRAM references.

34k tokens scripts
Scientific Critical Thinking
by K-Dense-AI
×1

Evaluate scientific claims and evidence quality. Use for assessing experimental design validity, identifying biases and confounders, applying evidence grading frameworks (GRADE, Cochrane Risk of Bias), or teaching critical analysis. Best for understanding evidence quality, identifying flaws. For formal peer review writing use peer-review.

26k tokens
Gh Fix CI
by openai
vendor ×1

Use when a user asks to debug or fix failing GitHub PR checks that run in GitHub Actions; use `gh` to inspect checks and logs, summarize failure context, draft a fix plan, and implement only after explicit approval. Treat external providers (for example Buildkite) as out of scope and report only the details URL.

8k tokens scripts
Declarative Agent Developer
by microsoft
vendor ×1

> Create, build, deploy, and localize declarative agents for M365 Copilot and Teams. USE THIS SKILL for ANY task involving a declarative agent — including localization, scaffolding, editing manifests, adding capabilities, and deploying. Localization requires tokenized manifests and language files that only this skill knows how to produce. "scaffold an agent", "new agent project", "add a capability", "add a plugin", "configure my agent", "deploy my agent", "fix my agent manifest", "edit my agent", "localize my agent", "add localization", "translate my agent", "multi-language agent", "add an API plugin", "add an MCP plugin", "add OAuth to my plugin", "review instructions", "improve instructions", "fix my instructions"

66k tokens
Documentation
by lingxling
×1

Documentation generation workflow covering API docs, architecture docs, README files, code comments, and technical writing.

1k tokens

How to use it

Copy the folder

Take automattic/code-style from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.