Skip to content
StaticScope
Overview
Get StaticScope

Using AI on a static build

Prompts for the static jobs that suit a model, and how to check the result before it reaches the build.

Developers Updated 21 November 2026 7 min read

AI can help with parts of a static build: reading unfamiliar plugin code, drafting a block, turning a crawl into redirect rules. It does not reliably know which parts of WordPress stop existing after the build. It may write a nonce that cannot work.

The workflow below treats a model as a fast contractor who has never seen your site. Give it the constraints and the files. Ask for something runnable. Then verify it against the built folder, not the WordPress page.

Give the model the constraints

A prompt that says “make search static” gets generic WordPress. A prompt that names the API, the file layout and the failure states gets code you can test. Every prompt below includes the same five constraints:

  • The boundary: no PHP, no nonce, no admin-ajax at runtime.
  • The exact API and its version, copied from the docs rather than remembered.
  • The input: the current template, plugin file or crawl export.
  • The shape of the answer: files, functions, no new dependencies.
  • The failure states: missing index, empty result, provider error, JavaScript off.

Paste documentation instead of describing it. If you have not read the Pagefind API this week, copy the four lines you need from the docs into the prompt. The model will otherwise fill the gap with something plausible.

Prompts to start with

Convert a search page to Pagefind

Convert this WordPress search template to a static Pagefind page.

Constraints:
- No PHP at runtime. The output is one HTML snippet and one ES module.
- Pagefind lives at the site root: import * as pagefind from "/pagefind/pagefind.js", then await pagefind.init().
- Search with: const search = await pagefind.search(term); const data = await result.data().
- data() gives url, excerpt, meta.title and content.
- Read the term from ?q=.
- Render with DOM methods. textContent for title and URL, innerHTML only for Pagefind's excerpt.
- Separate states: no query, no results, index missing.
- Keep the existing classes and layout.

Template:
[paste the search template]

Return the HTML and the module, nothing else.

Verify: change the import to a relative URL if the site is published under a path, then test it in the preview. Search a word you know is in one post, then a word that is only in the footer. The second should return nothing. If it returns every page, the indexed region is too wide.

Convert CF7 or Gravity markup to a form service

Replace this Contact Form 7 form with plain HTML that posts to Web3Forms.

Rules:
- action="https://api.web3forms.com/submit", method="post".
- Hidden fields: access_key, subject, from_name.
- Keep the visitor-facing fields and labels from the CF7 markup. Do not rename them.
- botcheck honeypot: a text input in a wrapper hidden with CSS, aria-hidden="true", tabindex="-1".
- Hidden redirect field pointing at /thanks/.
- With JavaScript: fetch the same action, read the JSON, check success === true, show the message in a role="status" region, and abort after 15 seconds.
- Without JavaScript: the normal POST must work.
- No nonce, no admin-ajax, no WordPress URL in the action.

CF7 markup:
[paste the form]

Return the markup, the honeypot CSS and the script.

Verify: compare every name against the original form and the fields your inbox expects. Send a real submission with JavaScript on, then with it off. A green message is not proof; check the inbox and the spam folder.

Scaffold a custom block

Write a WordPress block that renders static-safe HTML.

- block.json with apiVersion 3, name example/callout, and "render": "file:./render.php".
- Attributes: heading (string), body (string), tone (enum: note, warning).
- render.php escapes heading with esc_html, body with wp_kses_post, and uses get_block_wrapper_attributes.
- No current_user_can, no nonce, no REST call, no get_posts, no is_user_logged_in.
- No view script unless the block needs interaction. If it does, list the data it needs and say which values are baked at build time.

Return the files and a short list of elements that would break on a static host.

Verify: run php -l, insert the block, build, then view source. The HTML should be complete before JavaScript runs. Search the repository for the functions you banned; a model that ignores one instruction usually ignores two.

Audit plugins for static compatibility

Audit these plugins for a static export. Read only the code I provide.

For each plugin, give a row with:
- feature;
- what it needs at request time;
- what happens on a static page;
- verdict: works, works with a service, or must stay dynamic;
- the function or hook that proves it.

Do not guess from the plugin name. If the code does not show the answer, say what to inspect next.

Files:
[paste the main plugin files, or the output of grep -rn "admin-ajax\|wp-json\|current_user_can\|nonce" on the plugin folder]

Verify: take the three verdicts that matter most and test them in the preview. Grep the built folder for admin-ajax, wp-json and the WordPress host. A plugin can look static-safe and still enqueue a script that calls home.

Generate a redirect map from a crawl

Here is a crawl export with columns: url, status, final_url, content_type.
Produce redirect rules for a static host in Netlify _redirects format:

/old-path /new-path 301

Rules:
- Redirect only URLs that moved or disappeared.
- Leave query strings out unless the old page depended on them.
- Do not invent a destination. If there is no obvious target, write NEEDS-REVIEW and the old URL.
- One rule per line, no comments inside the block.

Data:
[paste the CSV]

Verify: count the old URLs and the rules. Spot-check ten, including every NEEDS-REVIEW. Run curl -I against a few published URLs and confirm the status and the Location header. A redirect map that loops is worse than a 404.

Write a smoke test

Write one Playwright test file for a static site served at https://getstaticscope.com:8080.

Check:
- the home page loads with no console errors and no request to the WordPress host;
- /search/?q=plugin returns at least one result;
- /search/?q=zzzz-no-match shows the empty state;
- the contact form submits with JavaScript and shows the success message;
- with JavaScript disabled, the form does a normal POST and lands on the thank-you page or the provider's page.

Use the built folder, not WordPress. No fixtures, no page objects, no new dependencies beyond Playwright. Print the failing URL and response status when an assertion fails.

Verify: run it against the preview, then break one thing on purpose, such as renaming the results container. The test must fail. A smoke test that passes on a blank page is decoration.

What it gets wrong

  • Invented APIs. Names that look right: a Pagefind search-all helper, a Web3Forms key field called api_key, options passed to pagefind.init() that do not exist. It states them with confidence. Keep the docs in the prompt.
  • No sense of the build boundary. It suggests admin-ajax, a nonce, a PHP endpoint on the static host, a CDN cache purge it cannot trigger, or get_posts() inside a view script. All of those assume PHP at request time, which the static host does not have.
  • Unsafe HTML. innerHTML with a query parameter, an unescaped title, a URL dropped into an attribute without esc_url. It also forgets wp_kses_post on rich text and esc_attr on values.
  • Old versions. It may know an older Pagefind, an older block API or an older form plugin. The code compiles and the method is gone.
  • Tests it did not run. “This should work” is not a result. Ask for the command and the output, then run it yourself.
  • Over-engineering. Three abstractions for one form, a state library for a search box. Static pages reward small scripts.

Review generated code the way you review a patch from someone who has never deployed this site. Read every line. Run it on the preview. Check the console, the network tab and the page source. The build is the only reviewer that cannot be talked around.

Next

The constraints these prompts assume are in building with static in mind. For the supported versions of both features, see search and forms. If you are auditing a site, start with plugin compatibility.