Platform

AEO Website Research-grade Content Content Factory About Audits Rankings Pricing

Resources

Knowledge Base Research Docs FAQ

Agent Fix Loop

Automate AEO improvements with an autonomous audit-fix-verify loop using the REST API or MCP tools.

Overview

The agent fix loop is a pattern where an AI agent audits a website, identifies weak criteria, applies fixes, and re-audits to verify improvement. This can run autonomously or with human-in-the-loop checkpoints.

The Loop

1
Audit
2
Analyze
3
Fix
4
Re-audit
5
Compare

Repeat if score < target

  1. Audit - Submit domain or fetch existing audit
  2. Analyze - Get fix prompts sorted by score impact
  3. Fix - Apply changes to your website (schema, content, config)
  4. Re-audit - Request fresh audit after changes
  5. Compare - Check new score vs previous, identify remaining gaps

REST API Approach

The full loop can be implemented as a script that runs end-to-end. Here is a complete TypeScript example:

agent-fix-loop.ts
const API = class="code-string">"https:class="code-commentclass="code-string">">//audit.aeocontent.ai/api/v1";
const headers = {
  class="code-string">"Authorization": class="code-string">`Bearer ${process.env.AEO_API_KEY}`,
  class="code-string">"Content-Type": class="code-string">"application/json",
};

class=class="code-string">"code-comment">// Step 1: Get current audit with fix prompts
const audit = await fetch(
  class="code-string">`${API}/audits/your-domain-com?include=fix_prompts`,
  { headers }
).then(r => r.json());

console.log(class="code-string">`Current score: ${audit.data.audit.overall_score}`);
console.log(class="code-string">`Fix prompts: ${audit.data.fix_prompts.length}`);

class=class="code-string">"code-comment">// Step 2: Review top fix prompts (sorted by impact)
for (const fix of audit.data.fix_prompts.slice(0, 3)) {
  console.log(class="code-string">`[${fix.criterion}] Score: ${fix.current_score}/10`);
  console.log(class="code-string">`  Prompt: ${fix.prompt}`);
}

class=class="code-string">"code-comment">// Step 3: Apply fixes to your site...
class=class="code-string">"code-comment">// (implement changes based on fix prompts)

class=class="code-string">"code-comment">// Step 4: Request re-audit
const reaudit = await fetch(
  class="code-string">`${API}/audits/your-domain-com/reaudit`,
  { method: class="code-string">"POST", headers }
).then(r => r.json());

class=class="code-string">"code-comment">// Step 5: Poll until complete
let status = class="code-string">"pending";
while (![class="code-string">"completed", class="code-string">"failed"].includes(status)) {
  await new Promise(r => setTimeout(r, 30000)); class=class="code-string">"code-comment">// 30s intervals
  const check = await fetch(
    class="code-string">`${API}/audits/your-domain-com/status`,
    { headers }
  ).then(r => r.json());
  status = check.data.status;
  console.log(class="code-string">`Status: ${status}`);
}

class=class="code-string">"code-comment">// Step 6: Compare scores
const newAudit = await fetch(
  class="code-string">`${API}/audits/your-domain-com?include=fix_prompts`,
  { headers }
).then(r => r.json());

console.log(class="code-string">`New score: ${newAudit.data.audit.overall_score}`);

MCP Approach

With MCP tools, your AI agent can run the same loop interactively in Claude Code or Cursor. Instead of writing code, you describe what you want in natural language:

1

"Check the AEO audit for my-domain.com with fix prompts"

aeo_get_audit({ slug: "my-domain-com", include_fix_prompts: true })

2

"Apply the top 3 fixes to my codebase"

Agent reads fix prompts, modifies your source files

3

"Re-audit my-domain.com"

aeo_request_reaudit({ slug: "my-domain-com" })

4

"Check the audit status"

aeo_get_audit_status({ slug: "my-domain-com" })

5

"Show me the new score and remaining fixes"

aeo_get_audit({ slug: "my-domain-com", include_fix_prompts: true })

Use aeo_get_opportunities for a focused view of what to fix next - it returns only opportunities and fix items without the full scorecard and findings.

Fix Prompt Format

Fix prompts are returned as part of the audit response when you include the fix_prompts parameter. Each prompt targets a specific criterion and includes actionable instructions:

fix_prompts response
{
  class="code-string">"fix_prompts": [
    {
      class="code-string">"criterion_id": 1,
      class="code-string">"criterion": class="code-string">"llms.txt",
      class="code-string">"current_score": 0,
      class="code-string">"potential_impact": 10,
      class="code-string">"prompt": class="code-string">"Create a /llms.txt file at the root of your domain...",
      class="code-string">"webflow_prompt": class="code-string">"In Webflow, go to Site Settings > Hosting > Custom Code..."
    }
  ],
  class="code-string">"fix_summary": {
    class="code-string">"total_fixable": 8,
    class="code-string">"potential_score_gain": 23,
    class="code-string">"top_3_impact": [class="code-string">"llms.txt", class="code-string">"Schema.org Markup", class="code-string">"FAQ Section"]
  }
}
Fix prompts include both general instructions and Webflow-specific instructions when applicable. The prompts are sorted by potential_impact so you fix the highest-value items first.

Best Practices

  • Start with the top 3 highest-impact fixes
  • Wait for re-audit to complete before making more changes (avoid stacking)
  • Set a target score (e.g., 80) and loop until reached
  • Use version comparison to track progress over time
  • Combine with visibility reports for a complete picture
Re-audits are rate-limited. You can request one re-audit at a time per domain. Wait for the current audit to complete before requesting another.