Phased guide for agents
A five-phase guide that tells the AI agent what to do next on the site, with rules and exit conditions.
On this page
01Overview
The guide divides the work on a site into five phases, numbered from 0 to 4. Phase 0 explains the Nucleo model. Phases 1 to 4 take the site from tokens and sections to the dynamic parts.
On every call the guide reads the state of the site and the saved documents. From these it calculates the current phase and the list of things to do.
The guide is read-only: it saves no state and does not remember previous calls.
You query it with the ability nucleo/guide, with wp nucleo guide (or wp nucleo ability run guide) and with the command nucleo guide of the local CLI.
The instructions of the MCP server ask the agent to call nucleo-guide before writing.
Every rule has a code (R1.2). Some errors and some quality reports show the same code in the guide field.
02Reading the guide
nucleo/guide
What it does: returns the requested phase, or the calculated current phase. The response contains the site state, the rules of the phase, the things to do, the exit conditions and the next command.
How to use it: via MCP with the tool nucleo-guide. Via REST with GET /wp-json/wp-abilities/v1/abilities/nucleo/guide/run. Example input: {"phase": 2, "design": "home.html"}.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
phase | integer | 0 to 4 | absent | Without phase the guide calculates the current phase. Out of range: error nucleo_guide_phase. |
design | string | at most 500 characters | "" | Text only. Replaces the placeholder <design.html> in the rules and in the things to do. The guide does not read the file. |
Response fields:
| Field | Content |
|---|---|
ok | Always true. |
phase | Number of the returned phase. |
title | Title of the phase (see Phases). |
state | Site state: see Site state. |
basics | Phase 0 rules in short form: code and first sentence. Empty when the phase is 0. |
todo | Things to do of the phase, calculated from the state. |
rules | Rules of the phase: code, text, tools. |
exit | Exit conditions of the phase, as text. |
next | "nucleo guide <phase+1>", or null at phase 4. |
Permissions: current_user_can('edit_posts'). OAuth scope nucleo:read.
Edition: Free
Known limits:
- The ability is annotated
readonly,idempotentand notdestructive. The write rate limit does not apply. - The texts of rules, things to do and exit are in English in the code, translatable with the
nucleodomain. - If the Nucleo cache is empty but the data exists, the first entry of
todoasks to runcache-rebuild. - If reading the documents stops at the limit, the last entry of
todosays how many documents it read out of how many.
wp nucleo ability run guide
What it does: runs nucleo/guide from WP-CLI and prints the JSON response.
How to use it: wp nucleo ability run guide --input='{"phase":1}' --user=<id|login>. The nucleo/ prefix of the name is optional.
Parameters: --input, JSON object with the same fields of the ability. Default {}.
Permissions: as nucleo/guide. Edition: Free
Known limits: an --input that is not a JSON object returns invalid_json. The wp nucleo guide command is generated for the ability: see the next section.
wp nucleo guide
What it does: runs nucleo/guide with the command generated for every ability (nucleo/guide becomes wp nucleo guide) and prints the JSON response.
How to use it: wp nucleo guide --input='{"phase":1}' --user=<id|login>.
Parameters: --input, JSON object with the same fields of the ability.
Permissions: as nucleo/guide. Edition: Free
Known limits: the command is generated for the nucleo/* abilities: a dash in the name becomes a space (nucleo/doc-patch becomes wp nucleo doc patch). Commands starting with status, export, import, sync, docs, mcp or ability are not generated, so existing ones are not overwritten.
nucleo guide
What it does: calls nucleo/guide from the local computer and prints the response as text.
How to use it: nucleo guide [0-4] [--design PATH]. Example: nucleo guide 2.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
| phase (positional) | integer | 0 to 4 | absent | Any other value prints Usage: nucleo guide [0-4] [--design PATH]. |
--design | string | text | absent | Passed to design as it is. The CLI does not read the file. |
Lines printed, in order: Phase <n>: <title>, State: …, Checks: … (when present), Distinct: with one line per node (when present), Coverage: <read> of <total> documents read (with (truncated) when reading stopped), Basics:, To do:, Rules: (with tools: under each rule), Exit:, Next: …. Empty sections do not appear. Next does not appear when next is null.
Permissions: as nucleo/guide, with the CLI credentials.
Edition: Free
Known limits: the State line shows only tokens, sections, layouts, menus, types and documents. Checks, Distinct and Coverage have their own lines; Distinct appears only if there are distinct nodes. If the site responds with an error, the CLI shows the server message as an error.
MCP server instructions
What it does: the MCP server sends the agent a fixed text at start-up. The text asks to call nucleo-guide before writing and to follow the phases in order.
How to use it: automatic, INSTRUCTIONS field of the server response.
Parameters: None
Permissions: those of the MCP connection.
Edition: Free
Known limits: it is a hint. All tools remain visible in every phase.
03Phase calculation
Current phase
What it does: without phase, the guide checks phases 1 to 4 in order. It returns the first one not met. If all are met, it returns 4.
How to use it: call nucleo/guide without phase.
Parameters: None
Permissions: as nucleo/guide.
Edition: Free
Known limits:
- Phase 0 is never chosen automatically. It is read only with
phase: 0. - The verified conditions are these. The
exitconditions are only text.
| Phase | Met when |
|---|---|
| 1 | At least one saved token, tokenLiterals = 0, repeated = 0. |
| 2 | A header layout and a footer layout apply to the whole site, at least one menu exists, globalParts = 0. |
| 3 | handLists = 0 and every model type has a single layout and at least one published item. |
| 4 | inertButtons = 0. |
pathLinks,mixedSectionsandformsgenerate things to do but do not block the exit from the phase.- With an empty model, phase 3 checks only
handLists. - A
singlelayout with theentire_sitecondition applies to all types.
Site state
What it does: collects the state on every call, with a few aggregate queries. It writes nothing to the database.
How to use it: state field of the response.
Parameters: state fields:
| Field | Content | Source |
|---|---|---|
tokens | Number of saved keys for each token group. 0 if the group is missing. | option nucleo_tokens |
sections | Sections not in the trash and not automatic drafts. | post type of the sections |
layouts | Layouts per area. header and footer are always present. | documents read, meta.area |
menus | Number of navigation menus. | wp_get_nav_menus() |
postTypes | Slugs of the model types. | content model |
documents | Documents per type, excluding layouts and sections. page and post always present. | meta _nucleo_doc |
checks | Counters of the document checks. | Document checks |
distinct | Nodes marked as deliberately different, in the form <ref>#<id>: <reason>. At most 3. | Distinct block on purpose |
coverage | read, total, truncated: documents read, total documents, reading interrupted. | document queries |
Permissions: as nucleo/guide.
Edition: Free
Known limits:
- Reading stops at 1000 documents. It reads layouts and sections first, then the most recently modified documents.
- The posts
trash,auto-draftandinheritare excluded. Drafts count. - The application of header, footer and
singleto the whole site comes from the layout map in the store. If the cache is empty, the guide sees these conditions as not met. - A draft without a slug appears with its ID in the references (
page:14#r).
Document checks
What it does: goes through the tree of each document read and counts the signals of the rules. For each counter it keeps up to 3 example positions, in the form <ref>#<node id>.
How to use it: state.checks field. The examples appear in the entries of todo.
Parameters: counters:
| Counter | What it counts | Rule |
|---|---|---|
tokenLiterals | Values of style equal to a saved token. | R1.2 |
repeated | Blocks of at least 5 nodes with the same structure, present at least 2 times. Once per structure. | R1.5 |
globalParts | Documents of kind page that contain nc/menu or a node with settings.tag header or footer. | R2.1 |
pathLinks | settings.href that starts with / but not with //. | R2.3 |
handLists | Groups of at least 3 siblings with the same structure and at least 2 nodes, outside nc/query and nc/collection. | R3.1 |
inertButtons | nc/button without a valid href or with href #, and without a bind on settings.href. | R4.5 |
forms | nc/native-form nodes. | R4 |
lists | nc/query and nc/collection nodes. | — |
sectionRefs | nc/section-ref nodes. | — |
mixedSections | nc/section with mixed direct children: sections and other blocks. | R1.7 |
distinct | Nodes with guide.distinct. | R1.5 |
Permissions: as nucleo/guide.
Edition: Free
Known limits:
- Structure of a block for
repeated: type and some settings.levelcounts fornc/heading,sectionfornc/section-ref,postTypefornc/queryandnc/collection,layoutandtagfor the other blocks. A setting that is absent counts as the default of the block manifest. - Binds to a field of the current content also count, with source
post,nucleo,item,acf,metabox,jetengineorwoo. Texts, images, links and style do not count. nc/section-refand lists weigh 0. A container of only references is not a repetition.- The blocks inside
nc/query,nc/collectionand the hand lists do not count inrepeated. - A block is reported if at least one copy is not inside a block already repeated. The group lists all the copies.
- The to-do explains at most 3 groups and shows at most 4 copies per group.
- For
mixedSections, anc/section-refcounts as a section if the root of the section isnc/section. If the section is not among the documents read, the reference does not count.
Distinct block on purpose
What it does: a node with "guide": {"distinct": "<reason>"} does not count as a repetition. The blocks inside it still count. The guide lists the node and the reason in state.distinct.
How to use it: add the guide key to the node in the document. Example: "guide": {"distinct": "home opening, deliberately different"}.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
guide.distinct | string | from 1 to 200 characters, at least one non-space character | absent | The schema rejects other keys in guide. |
Permissions: those of writing the document.
Edition: Free
Known limits: a distinct node makes its containers different too. state.distinct shows at most 3 nodes; state.checks.distinct counts all of them.
04Phases
Phase 0: template structure
What it does: explains the Nucleo model. Title in the code: Template structure.
How to use it: nucleo/guide with phase: 0. In the other phases the same rules appear in short form in basics.
Parameters: rules:
| Code | Content | Tools |
|---|---|---|
| R0.1 | Two worlds: saving validates, compiles and checks the quality; the frontend reads only the result. An error gives node, path and rule. | — |
| R0.2 | Document types: page and post, layout, section, popup. | — |
| R0.3 | A document is a tree of nodes. catalog-get and catalog-list describe format, blocks and styles. | nucleo/catalog-list, nucleo/catalog-get |
| R0.4 | Values that start with $ are tokens. | — |
| R0.5 | Two channels with the same permissions: CLI for many files, MCP for reads and targeted changes. | nucleo pull, nucleo push, nucleo/doc-patch |
| R0.6 | Plugins and theme are not modified. Every customization goes through documents, content and components. | — |
Permissions: as nucleo/guide.
Edition: Free
Known limits: enter this phase only on explicit request. The exit is text only: knowing the two worlds, the document model, the token syntax and the two channels. No verified condition. todo is always empty.
Phase 1: tokens and components
What it does: brings the design into tokens and reusable sections. Title in the code: Tokens and components.
How to use it: current phase when the condition of phase 1 is not met, or phase: 1.
Parameters: rules:
| Code | Content | Tools |
|---|---|---|
| R1.1 | Before the components, extract the tokens from the design: colors, fonts, type scale, spacing, radii, shadows, durations. | nucleo tokens suggest, nucleo/tokens-set |
| R1.2 | A value equal to a token uses $name. The push reports it as an error; push --use-tokens replaces it. | nucleo push --use-tokens |
| R1.3 | A value present at least 3 times in the design without a token is a missing token. | — |
| R1.4 | Before creating, read the existing sections (section-list: parameters and uses), then catalog and kit. The acknowledge of a section is valid only for the section: every page or layout that inserts it needs one with the id of its nc/section-ref. | nucleo/section-list, nucleo/catalog-list, nucleo/kit-list |
| R1.5 | A block present at least 2 times becomes a section with parameters, inserted with nc/section-ref. Criterion: see Document checks. | — |
| R1.6 | The variants are parameters of the same section. | — |
| R1.7 | A section with a section among its direct children is a transparent container: all direct children reach the edges, also containers and headings. Bands with their own background are sibling sections, or the only children of a wrapper. | nucleo/catalog-get |
Things to do generated:
- no saved token: run
nucleo tokens suggest <design.html>, thentokens-set; tokenLiterals> 0: replace the values with the tokens;repeated> 0: create sections, with the explanation of the groups and thedoc-patchoperations (remove, theninsertof anc/section-refwith the same id);mixedSections> 0: move the other blocks into a section of their own.
Permissions: as nucleo/guide.
Edition: Free
Known limits: the exit is text only: every repeated element has a section; no value matches a token. R1.3 has no check in the code. R1.4 cites nucleo/kit-list, which is Pro: without a license the ability is not registered.
Phase 2: global parts
What it does: moves header, footer and navigation into the layouts. Title in the code: Global parts.
How to use it: current phase when phase 1 is met and phase 2 is not, or phase: 2.
Parameters: rules:
| Code | Content | Tools |
|---|---|---|
| R2.1 | Header and footer are layouts with area header/footer and condition entire_site. No page contains them. | doc-create, layout-conditions-set |
| R2.2 | Variants are made with conditions and priorities, not with copies. To hide a part on a breakpoint, use the visibility of the node. | — |
| R2.3 | Navigation uses menu-set and nc/menu. Internal links use references (page:<slug>, <post-type>:<slug>, term:<taxonomy>/<slug>, home). In menus, items use page, post or ref (the same references plus archive:<post-type>); url only for external links. | nucleo/menu-set |
| R2.4 | Bands repeated on several pages are sections with parameters, or layouts of the before-content and after-content areas. | — |
| R2.5 | Before exiting: layout-explain on a page, an article and an archive; screenshots at 390 and 1440 px. | nucleo/layout-explain |
Things to do generated: missing header or footer layout; layout present but without the entire_site condition; no menu; globalParts > 0; pathLinks > 0.
Permissions: as nucleo/guide.
Edition: Free
Known limits: the exit is text only: header, footer and menu apply to the whole site; no page repeats the global parts. pathLinks does not block the exit. R2.5 has no check in the code.
Phase 3: real content
What it does: turns the repeated elements into content with type, fields and a single layout. Title in the code: Real content.
How to use it: current phase when phases 1 and 2 are met and phase 3 is not, or phase: 3.
Parameters: rules:
| Code | Content | Tools |
|---|---|---|
| R3.1 | An element that repeats with the same structure is a content: type, taxonomies and fields with model-set. Tiles that read different fields of the same element are not repetitions. | nucleo/model-set |
| R3.2 | Before creating a type, read model-get: unmodeled lists the types registered by other code. Pages and articles accept fields with location.postType. | nucleo/model-get |
| R3.3 | Every type has a single layout linked to the fields and a list with nc/query or nc/collection. | — |
| R3.4 | The texts of the design go into the content (content/<type>/<slug>.json, terms/<taxonomy>.json, content-upsert, terms-set), not into the card. | nucleo/content-upsert, nucleo/terms-set |
| R3.5 | Unique pages remain page documents built with sections. | — |
| R3.6 | The single layout follows the data: nc/repeater, visibility filled/empty, nc/query with relatedTo, nc/post-meta with tax:<taxonomy>, nc/breadcrumbs. | nucleo/catalog-get |
Things to do generated: handLists > 0; for every type without a single layout; for every type without published items.
Permissions: as nucleo/guide.
Edition: Free
Known limits: the exit is text only: every list of the design reads real content; every item has its own page. The code does not check that a nc/query or nc/collection list exists for every type.
Phase 4: dynamic parts
What it does: replaces the fake controls with native blocks or components. Title in the code: Dynamic parts.
How to use it: current phase when phases 1 to 3 are met, or phase: 4. It is also the phase returned when all phases are met.
Parameters: rules:
| Code | Content | Tools |
|---|---|---|
| R4.1 | First the native blocks: nc/collection, nc/tabs, nc/accordion, nc/slider, nc/native-form, nc/search. Email recipient of the form: admin (default), an address or field:<field>; replyTo is field:<field>. | — |
| R4.2 | Then the PHP components, only when blocks, style keys and options are not enough. They live in the nucleo-components plugin. A component block is drawn at save time and does not see the current post. | nucleo component new, nucleo component check |
| R4.3 | The component code does not go through MCP, REST or push. Locally nucleo component deploy copies the plugin onto the local WordPress disk; in staging and production the component arrives with the site migration or with the deploy (git), and the agent reports it as a step for a person. | nucleo component deploy |
| R4.4 | The actions with external effects ask the user's consent before publishing the form. | — |
| R4.5 | A button without a link or an action is a fake control (rule content.button.inert). | — |
| R4.6 | No mu-plugins, no code in the theme, no snippets or CSS and scripts in wp_head/wp_footer. First style.parts and style keys, then style.custom; every gap must be reported with nucleo-gap-report, even when style.custom covers it. For PHP behavior a component is needed, only with the user's consent. | — |
Things to do generated: inertButtons > 0; a test submission for every form, with the number of forms.
Permissions: as nucleo/guide.
Edition: Free
Known limits: the exit is text only: no fake control; every form tested with a test submission. The code checks only inertButtons. The test submission cannot be verified: the entry stays in todo as long as forms exist. next is null.
05Rule codes in errors
Link to errors and reports
What it does: adds the code of the guide rule in the guide field of some quality reports and some errors. The rule field remains the id of the quality rule.
How to use it: automatic, in the responses of save, validation, quality and import.
Parameters:
| Source | Id | guide code |
|---|---|---|
| quality | style.token.literal | R1.2 |
| quality | content.section.missing | R1.5 |
| quality | content.link.path | R2.3 |
| quality | content.link.missing | R2.3 |
| quality | content.button.inert | R4.5 |
| quality | form.action.consequential | R4.4 |
| error | card_missing | R3.3 |
| error | card_block_not_allowed | R3.3 |
| error | component_code | R4.3 |
Permissions: those of the operation that produces the error.
Edition: Free
Known limits: the other rules have no link. The quality rules are described in the quality engine.
Was this page helpful?