
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.
- Installs
- 97
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/automattic/wordpress-activitypub --skill code-style- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads code-style automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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 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'.
FAQ
What does the code-style skill do?
PHP coding standards and WordPress patterns for ActivityPub plugin. Use when writing PHP code, creating classes, implementing WordPress hooks, or structuring plugin files.
How do I install code-style?
Run npx skills add https://github.com/automattic/wordpress-activitypub --skill code-style in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/code-style/ (personal) or .claude/skills/code-style/ (project).
Which AI agents can use code-style?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is code-style safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains code-style?
It is published by automattic in automattic/wordpress-activitypub, and it is an official skill from the maker of the technology it covers. It has 97 recorded installs.
More from automattic/wordpress-activitypub
integrations
automattic/wordpress-activitypub
Open the skill to read its SKILL.md instructions.
pr
automattic/wordpress-activitypub
Open the skill to read its SKILL.md instructions.
dev
automattic/wordpress-activitypub
Development workflows for WordPress ActivityPub plugin including wp-env setup, testing commands, linting, and build processes. Use when setting up development environment, running tests, checking code quality, building assets, or working with wp-env.
test
automattic/wordpress-activitypub
Open the skill to read its SKILL.md instructions.
federation
automattic/wordpress-activitypub
Open the skill to read its SKILL.md instructions.
release
automattic/wordpress-activitypub
Open the skill to read its SKILL.md instructions.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.