Back to all recipes
AI AutomationApril 5, 2026

Building an Autonomous 'SEO Agent' with CrewAI to Rewrite Low-Performing Content

Master AI Automation 2026 and Generative Engine Optimization. Build autonomous agents for Generative Engine Optimization using CrewAI, a core skill for AI Automation 2026 and automated content auditing.

The biggest trend in search today isn't just "AI content"—it's the shift from static prompts to autonomous workflows. This is the core of Agentic SEO. While your competitors are still manually pasting text into ChatGPT, the leaders of the 2026 ecosystem are building "Digital Assembly Lines" that monitor, audit, and optimize content 24/7.
In this recipe, we’ll build an Agentic Content Audit system. This workflow links a high-speed crawler (Scrapy) to a multi-agent orchestration framework (CrewAI) to automatically flag and rewrite content that has lost its "Information Gain" score.

The Technical Stack: CrewAI for SEO & Scrapy

To achieve autonomous content optimization, we need three distinct layers:
  1. The Sensory Layer (Scrapy): To crawl your site and extract live content.
  2. The Analysis Layer (LLM + Logic): To calculate the "Information Gain" score against current SERP leaders.
  3. The Action Layer (CrewAI): To coordinate agents that rewrite and optimize the underperforming sections.

Step 1: The Crawler (Scrapy Snippet)

First, we need a scraper that extracts the semantic core of your pages efficiently using Scrapy's native selectors.
python
import scrapy

class SEOAuditSpider(scrapy.Spider):
    name = "seo_audit"
    start_urls = ['https://seodatapulse.com/learn']

    def parse(self, response):
        # Extract main content using CSS selectors for better performance
        main_content = response.css('article, main').get()
        text_content = " ".join(response.css('article p::text, main p::text').getall())

        yield {
            'url': response.url,
            'title': response.css('title::text').get(),
            'content': text_content,
            'word_count': len(text_content.split())
        }

Step 2: Orchestrating Agents with CrewAI

This is where we implement the Agentic SEO workflow. We define two agents: an SEO Auditor and a Content Strategist, along with their specific tasks.
python
from crewai import Agent, Task, Crew, Process

# Agent 1: The SEO Auditor
auditor = Agent(
  role='Senior SEO Auditor',
  goal='Analyze content for Information Gain and GEO alignment',
  backstory=("You are an expert in Generative Engine Optimization (GEO). "
            "You specialize in identifying 'thin' content that lacks unique value."),
  verbose=True
)

# Agent 2: The Content Strategist
rewriter = Agent(
  role='Content Optimization Specialist',
  goal='Rewrite underperforming content to maximize citation share',
  backstory=("You transform dry, low-value text into high-density, "
            "authoritative content that follows the 'Assertion-Evidence' model."),
  verbose=True
)

# Define the Tasks
def create_crew_workflow(page_data):
    audit_task = Task(
      description=f"Audit the following page content: {page_data['content'][:2000]}... Identify gaps in 'Information Gain' compared to current search engine leaders.",
      agent=auditor,
      expected_output="A list of content gaps and an 'Information Gain' score."
    )

    rewrite_task = Task(
      description="Based on the audit, rewrite the content to include unique data "
                  "points and authoritative assertions that increase citation potential.",
      agent=rewriter,
      context=[audit_task],
      expected_output="A fully rewritten, GEO-optimized version of the article."
    )

    return Crew(
      agents=[auditor, rewriter],
      tasks=[audit_task, rewrite_task],
      process=Process.sequential
    )

Step 3: Linking the Workflow (The "Glue" Code)

To make this truly autonomous, you need to link the Scrapy output directly to the CrewAI execution. In a production environment, you would use a pipeline to trigger the agents as the spider finishes each page.
python
# Simple orchestration script
def run_autonomous_audit(scraped_items):
    for item in scraped_items:
        print(f"Processing: {item['url']}")

        # Initialize the Crew for this specific page
        seo_crew = create_crew_workflow(item)

        # Execute the agentic workflow
        result = seo_crew.kickoff()

        # Save the optimized content
        with open(f"optimized_{(item['url'].split('?')[0].strip('/').split('/')[-1] or 'index')}.md", "w") as f:
            f.write(result)

# Example usage:
# run_autonomous_audit(list_of_scraped_items)

Why This Wins in 2026

Traditional SEO is reactive. Agentic SEO workflows are proactive. By automating the audit-and-rewrite cycle, you ensure that your domain is always moving toward the "Expertise" end of the E-E-A-T spectrum.
  • Autonomous content optimization reduces human editorial time by 70%.
  • CrewAI for SEO allows you to scale the "thinking" part of optimization across thousands of pages.
  • Generative Engine Optimization ensures you remain the primary citation in an AI-first search world.

Implementation Pro-Tip:

Integrate this workflow into your CI/CD pipeline. Every time you push a new blog post, the "SEO Agent" should automatically run a mock-audit to ensure the content is ready for the 2026 web before it even goes live.

Advertisement

Ready to automate more?

Explore our directory of over 546 autonomous AI tools and platforms to drastically increase your output.

Browse AI Tools Directory