GoBuildWP

Developer toolsPro

Code Snippets MCP: write, lint and switch on snippets safely

Letting an AI client add code to a live site is the riskiest thing on this list, so the Code Snippets MCP abilities in GoBuildWP Pro are built around one rule: new snippets default inactive, while immediate activation and active-code edits require API flags and the installed confirmation policy. New snippets are saved switched off, PHP is linted by the parser without being executed, and execution paths require their API confirmation prerequisites. A model-supplied confirm flag does not authenticate a human review; require that review separately and test on synthetic staging before activation.

AI clientyour-site.comVerify site policy

Remove the WordPress version generator tag from the page head.

  1. wppilot/code-snippets-get-types-schemaRead

    Confirms php with scope global is the pair for a filter that runs on every request. Non-read Code Snippets calls are critical and require Developer Full Access, enabled abilities, confirm=true and any configured approval.

  2. wppilot/code-snippets-create-snippetConfirm first

    Saves the body (without an opening PHP tag, which the plugin adds) as inactive and returns its id.

  3. wppilot/code-snippets-validate-snippetRead

    Parses the saved body token by token and reports no syntax errors; nothing is executed.

  4. wppilot/code-snippets-enable-snippetConfirm first

    After the person has read the code, runs with confirm: true; from the next request the filter is live.

Proposed sequence from source declarations; not a recorded task or proof of client compatibility. Inspect saved state and browser or provider results separately.
Edition
Pro
Abilities
11
Requires
WordPress 6.9+, PHP 8.0+, Code Snippets 3.6.0+

Limits

Where confirmation is required, and what cannot be undone

  • Three calls can put code into execution and each needs confirm: true: enabling a snippet, creating one with activate set, and editing code, type, scope or condition on a snippet that is already active.
  • No snippet write can be rolled back from the change log. Read a snippet before editing it so its previous body is on record.
  • Delete is permanent, with no trash. The plugin deactivates an active snippet first, so the code stops at once.
  • CSS, JS and condition snippets exist only on Pro. On an unlicensed Pro install they save and read back, but Code Snippets does not output them on the site.
  • A single-use PHP snippet runs once and switches itself off, so it is wrong for hooks that must register on every request.

Abilities

Code Snippets abilities by effect

Documented source abilities; live registration can be narrower. Edition and effect labels describe the source catalogue. The installed schema, dependency versions, licence, WordPress capability, safety profile and per-ability policy determine availability; labels alone do not prove confirmation or recovery.

Worked example

Adding a PHP filter the careful way

Expected outcome to verify on the installed stack; this sequence has not been recorded as a runtime test.

The generator tag is gone from the head. If it had to come out again, disable-snippet stops it while keeping the body. There is no change-log rollback for any of these steps, so the body shown before enabling is the record.

Use staging. Obtain confirmation on the actual active-code edit or enable step before execution, then inspect the rendered head. Keep disable and safe-mode recovery available; runtime guards do not prove all code effects are recoverable.

  1. code-snippets-get-types-schema

    Confirms php with scope global is the pair for a filter that runs on every request. Non-read Code Snippets calls are critical and require Developer Full Access, enabled abilities, confirm=true and any configured approval.

  2. code-snippets-create-snippet

    Saves the body (without an opening PHP tag, which the plugin adds) as inactive and returns its id.

  3. code-snippets-validate-snippet

    Parses the saved body token by token and reports no syntax errors; nothing is executed.

  4. code-snippets-enable-snippet

    After the person has read the code, runs with confirm: true; from the next request the filter is live.

Data model

One table, and snippets that gate other snippets

Code Snippets keeps every snippet in its own database table, outside the theme, so snippets survive a theme change. Each row carries a name, the code, a type (php or html on the free plugin; css, js and cond added by Pro), a scope saying where it runs, a priority, tags, an active flag and, on Pro, a condition id.

Scope is what decides when code runs. A PHP snippet can run everywhere, only in admin, only on the front end, or once on save and then switch itself off. An HTML snippet can be inlined in the head or footer, or saved as content, which gives it a [code_snippet id] shortcode. On Pro, a condition is itself a snippet of type cond whose code is a JSON list of rule groups; other snippets point at it by id and run only when it is true.

Because the table belongs to Code Snippets, the GoBuildWP change log can record a snippet write but has no way to restore one.

Snippets you inherit, edit and retire

Reading an inherited snippet library before trusting it

Agencies often take over sites where years of fixes live in Code Snippets rather than in a child theme. The first job is an inventory, and it is entirely read-only. code-snippets-list-snippets returns id, name, type, scope, tags, priority and active flag without the code, up to five hundred rows a page, and its search matches inside the code body as well as names and descriptions. That makes targeted questions cheap: which active snippets call wp_schedule_event, which ones mention a payment gateway, which ones load a script from an outside domain.

Names are not unique in Code Snippets, so two snippets called Tracking can both exist and both be active. Work by id from the first listing onwards. For each snippet that matters, code-snippets-get-snippet returns the full body with its type, scope, priority and any condition id, and an agent can summarise what it hooks into and flag anything that duplicates a plugin the site already runs. On multisite, network-shared snippets are kept in a separate table these abilities do not read, so an audit of a network site is incomplete until those are checked in the network admin.

Editing a snippet that is already running

Changing an active snippet is the moment a site is most likely to break, which is why editing its code, type, scope or condition needs confirmation. Lint the new body first by passing it as code to code-snippets-validate-snippet, which parses it without saving or running it. Then read the current snippet and keep its body, because the change log records snippet writes but cannot restore them; that saved body is the only undo.

When the edit is saved, Code Snippets re-validates the PHP itself, and if the new code errors it switches the snippet off. The response then carries deactivated_on_save and code_error. Treat that as a signal, not a failure to retry: the old behaviour has stopped along with the new code, so either fix the body and re-enable it, or write the previous body back. Change type and scope together when changing either, since most mismatched pairs are invalid.

Retiring a snippet that left things behind

Deleting a snippet removes its row and stops its code, and that is all. Anything the code created while it ran survives: scheduled WP-Cron events keep firing with nothing listening, tables made with dbDelta stay, and options it wrote stay in wp_options. For a snippet that set any of that up, disable it first, then clean up, then delete.

GoBuildWP Free's cron-list helps with the cron part. It lists every scheduled event with its next run and says whether anything is hooked to it, and an event with no callbacks after the snippet is disabled is usually the snippet's leftover. cron-delete unschedules one occurrence and can be undone from the change log. Leftover options and tables need a person to decide, because the agent cannot always tell whether another plugin also reads them.

  • Search the snippet body for wp_schedule_event, add_option, update_option and dbDelta before deleting it.
  • Keep the deleted body somewhere; there is no trash.
  • On Pro, a condition snippet with currentDate between two dates is a cleaner way to run seasonal code than remembering to disable it.

Questions

Code Snippets questions

Can an AI agent take my site down with a PHP snippet?

It can. Code Snippets tries to catch errors in snippets at run time, and the vendor documents a safe mode for recovery, but neither is a guarantee: a snippet can still break pages, slow the site, change data or misbehave quietly. That is why a snippet is linted and approved by a person before it is switched on, and why a staging copy is the place to try anything new.

Why is a CSS snippet saved by the agent not changing anything?

On Code Snippets Pro, style and script snippets are only output while the licence is active. Activate it under Code Snippets, License; the agent does not do that step.

How do I undo a snippet the agent edited?

There is no automatic rollback. Write the previous body back with edit-snippet, or disable the snippet, which keeps the code but stops it running.

Can the agent attach a snippet to a condition?

On Pro, yes: create a cond snippet from the conditions schema, then set other snippets' condition_id to its id. Setting it to 0 detaches them.

Where these facts come from

GoBuildWP behaviour is taken from the plugin source and the ability reference; third-party details from the vendor documentation below, checked by the GoBuildWP team.

Code Snippets is a separate product; no partnership or endorsement is implied.

Try it on Code Snippets in Read Only first