bd-source-adapter

Installation
SKILL.md

better-data: Adding a source adapter

For library maintainers integrating a new WordPress data store with better-data — comments, attachments, transients, custom tables, taxonomy hierarchies. Sources hydrate stored data into typed DataObjects via AttributeDrivenHydrator; the work is wiring up the bridge between WP's storage idioms and the hydrator's closure contract.

Misconception this skill corrects

"I'll call get_post_meta($id, $key, true) directly — empty string means 'not set'."

Wrong. WordPress get_meta($key, true) returns '' (empty string) for both "key does not exist" AND "key exists with empty-string value". The AttributeDrivenHydrator distinguishes these because the default-value fallback at src/Internal/AttributeDrivenHydrator.php:90-95 needs to know "missing → use the parameter's default" vs "present-but-empty → coerce as empty string". Without the distinction, every nullable meta-backed field with a non-null default falls back incorrectly.

The contract: the closure you pass to the hydrator returns:

  • null → key does not exist (hydrator falls back to parameter default / parameter nullable)
  • the stored value (including '') → key exists, hydrator coerces

Verified pattern from src/Source/PostSource.php:91-93:

Installs
1
GitHub Stars
22
First Seen
1 day ago
bd-source-adapter — lonsdale201/wp-agent-skills