Black Friday 2025
Meta Box

Write Correct Meta Box Code With AI: New Agent Skill and Coding Guide

Ask ChatGPT or Claude for Meta Box code, and you often get code that looks right but doesn't work. It calls get_field() from ACF, reads a group sub-field with get_post_meta(), or tells you to install a "Meta Box Models" extension that doesn't exist. We see these mistakes in our support tickets.

To fix this, we made two things for AI tools: the Coding with AI guide in the docs and the official Meta Box agent skill for Claude Code, Cursor, and other AI agents. Both tell your AI tool how to write correct Meta Box code and which mistakes to avoid.

Why AI Tools Get Meta Box Code Wrong

AI tools learn from code on the web, and much of that code is for ACF. So they mix the two plugins, guess function names, and invent extension names. Here are real examples from our support tickets:

  • ChatGPT called custom models a "Models extension". Custom models are a feature of MB Custom Table, so the user couldn't find the extension.
  • ChatGPT told a user to switch to ACF because "ACF works with the Query Loop block". MB Views has worked with the Query Loop block since version 1.15.0, but the docs didn't show how.
  • Our docs showed some hooks only as a signature, such as apply_filters( 'rwmb_profile_insert_user_data', ... ), with no example. Users and AI tools had to guess how to use them.

Most of these mistakes come from missing information. So we wrote down the information AI tools need, in a form they can read.

Coding With AI: A Docs Page for AI Tools

The new Coding with AI page has two parts.

How to write Meta Box code. Short rules for the decisions AI tools get wrong:

  • How to create fields: the rwmb_meta_boxes filter, JSON files with the JSON schema, or MB Builder.
  • How to get field values: always with rwmb_meta(), with object_type for terms, users, settings pages, and models.
  • Which extension to use for each task, for example Meta Box Group for repeating fields, MB Relationships to connect posts, and custom models for data that isn't a post.
  • What to do when the AI tool is not sure: read the docs or the plugin source, and never use a function that isn't there.

Common mistakes. The mistakes AI tools make most often, each with the wrong code and the correct code. For example:

// Wrong: a group saves all sub-fields in one meta key
$city = rwmb_meta( 'address_city' );

// Correct: get the group, then the sub-field
$address = rwmb_meta( 'address' ) ?: [];
$city    = $address['address_city'] ?? '';

To make your AI tool read the page, add this to the rules file of your project (AGENTS.md, CLAUDE.md, or .cursor/rules):

This project uses Meta Box (https://metabox.io) for custom fields.
Before you write Meta Box code, read https://docs.metabox.io/coding-with-ai/.

This works with any AI tool that reads rules files. For ChatGPT, paste the same text into the custom instructions.

The Meta Box Agent Skill

An agent skill is a file that AI agents load when a task needs it. With the Meta Box skill, your agent knows the rules and the common mistakes as soon as it sees Meta Box code in your project, without fetching a web page. It also has a list of docs links, so the agent knows where to look for details.

To install it in Claude Code:

/plugin marketplace add wpmetabox/skills
/plugin install meta-box@meta-box

For Cursor, Codex, Copilot, and other agents:

npx skills add wpmetabox/skills

The skill is free and open source on GitHub. It's a short version of the Coding with AI page, and we update both together.

Better Docs for Humans, Too

While we wrote the guide, we found gaps in the docs that confused AI tools and people alike. We fixed them:

  • Query Loop block. A new section in the MB Views docs shows how to use a view inside the Query Loop block. Since MB Views 1.15.0, {{ post }} is the current post of the loop, so each item shows its own fields.
  • View block. The block that adds a view in the block editor now has its own docs.
  • Hook examples. The hooks of MB User Profile and MB Relationships now have working examples with add_filter() and add_action(), not only the signature. We also found and fixed a missing parameter in the docs of the mb_relationships_add and mb_relationships_delete hooks.

Agent Skill or Abilities: Which One Do You Need?

Meta Box also has Abilities, which let AI agents work on your site through MCP. The two features solve different problems:

FeatureWhat the AI doesUse it when
Agent skill and Coding with AIWrites PHP and Twig code for your theme or pluginYou build a site or a plugin with code
AbilitiesCreates and edits post types, field groups, and content on your siteYou want AI to manage your site without code

You can use them together. For example, let AI create the field groups with Abilities, then write the template code with the skill.

Frequently Asked Questions

Does the skill work with ChatGPT?

ChatGPT doesn't load agent skills. Add the rules text from the Coding with AI page to the custom instructions of ChatGPT, or paste the page link in your prompt.

Is the skill free?

Yes. The skill and the docs are free, and they work with the free Meta Box plugin and all extensions.

Does the AI tool still make mistakes?

Sometimes. The guide and the skill cover the mistakes we see most often, not every possible mistake. Test the code on a staging site before you use it on a live site. If you find a new mistake, tell us in the support forum and we'll add it to the guide.

What's the difference between the skill and Abilities?

The skill helps AI write code. Abilities let AI do actions on your site, such as create a post type or update a field value, through MCP. See the comparison table above.

Final Thoughts

AI tools are only as good as the information they get. Add the Coding with AI rules to your project, or install the Meta Box skill, and your AI tool will write Meta Box code that works the first time more often.

If you build sites with code, Meta Box AIO gives you all extensions in one plugin, so your AI tool can use custom tables, relationships, and views without extra setup.

Try it in your next project and tell us which mistakes your AI tool still makes.

Anh Tran
Anh Tran
Anh Tran is the Founder & CEO of eLightUp and creator of Meta Box and Slim SEO. As a WordPress developer since 2006, he builds tools focused on simplicity, performance, and helping professionals work more efficiently.
Leave a Reply

Your email address will not be published. Required fields are marked *