一键导入
builder-payload-smith
// Maintain Builder classes — outbound payload construction, validation, serialization, component handling, and fromPart symmetry. Use when changing Builders or outbound Discord API payloads.
// Maintain Builder classes — outbound payload construction, validation, serialization, component handling, and fromPart symmetry. Use when changing Builders or outbound Discord API payloads.
Maintain test and documentation alignment — PHPUnit tests, async testing patterns, PHPDoc contracts, guide pages, and documentation workflow. Use when adding tests, updating docs, or changing public behavior.
Maintain gateway event handlers — payload hydration, cache mutation, event return shapes, and handler registration. Use when touching WebSockets/Events, Handlers.php, or Event.php.
Work with DiscordPHP's infrastructure utilities — CacheWrapper, CacheConfig, BigInt, Multipart, Endpoint::bind URL templates, Collection base class, and domain Exceptions. Use when changing cache behavior, REST endpoint routing, file uploads, big-integer ID math, or adding/modifying exceptions.
Maintain interaction flow — Interaction typing, resolved data caching, command routing, autocomplete, modal responses, and interaction builders. Use when touching Interactions or slash command handling.
Maintain the optional prefix-command layer — DiscordCommandClient, Command class, parsing, aliases, cooldowns, and help system. Use when touching message-based command handling.
Maintain Part domain models — fillable attributes, mutators, typed nested data, save/fetch behavior, permission checks, PHPDoc, and repository bindings. Use when adding or modifying any Discord Part class.
| name | builder-payload-smith |
| description | Maintain Builder classes — outbound payload construction, validation, serialization, component handling, and fromPart symmetry. Use when changing Builders or outbound Discord API payloads. |
Use this skill when work touches:
src/Discord/Builders/*src/Discord/Builders/Components/*This is outbound-shape skill. Load it when a change affects how callers build data to send to Discord.
Keep builders as the repo's safe way to author complex outbound payloads:
src/Discord/Builders/Builder.phpsrc/Discord/Helpers/DynamicPropertyMutatorTrait.phpsrc/Discord/Builders/ComponentsTrait.phpsrc/Discord/Builders/MessageBuilder.phpsrc/Discord/Builders/ChannelBuilder.phpsrc/Discord/Builders/CommandBuilder.phpsrc/Discord/Builders/ModalBuilder.phpsrc/Discord/Builders/Components/Component.phpsrc/Discord/Builders/Components/ComponentObject.phpBuilders are not parts. Builders:
BuilderJsonSerializablecreate($repository) helpers for smoother public APIIf a builder starts acting like cached domain object or repository, wrong layer.
Builder::fromPart(Part $part)This is bridge from stored part data into editable payload state. Preserve it when adding new builder properties or part fields. Edit flows depend on this symmetry.
DynamicPropertyMutatorTraitBuilder property access uses property-level mutators like:
setContent()getContent()Not part-style getContentAttribute(). Keep that distinction.
new() factoryMost builders expose new() for userland ergonomics. Preserve pattern when adding new top-level builders.
create($repository) helperNewer builders often let callers hand the builder to a repository directly. Prefer keeping that path because it nudges users away from raw arrays.
Validation should live as close as possible to setter/add method that introduces invalid state.
Good examples already in repo:
Do not rely on far-away repository methods to catch simple builder invariants.
jsonSerialize() is canonical outbound shapeThis is where builder translates fluent internal state into Discord payload array. Keep it:
Many Discord APIs treat missing field differently from explicit null. Builders should usually omit properties that were never set unless API specifically wants null.
If builder accepts nested objects:
Do not move outbound validation rules into parts if there is already a builder abstraction.
Repositories should not become payload authoring zones full of hand-built nested arrays if builder exists.
Component system exists in both builder and part worlds:
src/Discord/Builders/Components/*src/Discord/Parts/Channel/Message/*Keep these worlds aligned conceptually, but do not collapse them into one class family. Outbound builders and inbound parts solve different problems.
ComponentObject::TYPESIf new outbound component subtype appears:
Component usage constraints matter:
Where repo already encodes allowed contexts, keep validation there instead of free-form component insertion.
Add or extend a builder when:
Raw array may be enough when:
But if users will author it directly or repeatedly, bias toward builder.
Best example for:
create() bridgeBest example for:
Best example for:
Best example for:
type + dataStop if you see:
fromPart() path no longer reflects real fieldsjsonSerialize() includes it only when appropriatefromPart() behavior still makes sensecreate($repository) helper remains correctBuilders in this repo exist to keep outbound payload rules from leaking everywhere. If a caller has to memorize Discord payload trivia instead of relying on builder methods, builder design is unfinished.