How the Multi-Phase Pipeline Works for Website Cloning in the AI Website Cloner Template
The AI Website Cloner Template implements a structured five-phase pipeline that converts public websites into Next.js projects through incremental inspection, specification generation, code synthesis, asset integration, and final validation.
The JCodesMore/ai-website-cloner-template repository provides a sophisticated automation system for replicating websites using AI. At its core, the multi-phase pipeline orchestrates a sequence of discrete steps managed by the /clone-website skill, ensuring each transformation stage is verified before proceeding to the next.
The Five Phases of the Website Cloning Pipeline
The pipeline processes target URLs through five distinct phases, each producing verifiable artifacts before advancing to the next stage.
Phase 1: Inspection and Asset Harvest
This initial phase captures the target site’s visual and structural information using a headless browser.
The system launches Playwright or Chrome to load the target URL, then records screenshots, DOM snapshots, CSS styles, and network assets including images, videos, and fonts. These harvested assets are stored under public/ and docs/research/<hostname>/, while design-token reports extract raw color palettes and typography scales for later use.
Phase 2: Specification Generation
Raw inspection data transforms into a designer-friendly specification that serves as a contract for code generation.
The pipeline parses the DOM tree to identify reusable components such as buttons, cards, and navbars. It extracts color palettes, spacing scales, typography details, and animation specifications, then writes structured Markdown or JSON files into docs/research/…/components.md and docs/research/…/styles.md. These specification files act as the single source of truth for the AI builders in the next phase.
Phase 3: Code Synthesis (Component and Page Builder)
This phase generates the actual Next.js source code from the specification documents.
AI-driven builder agents consume the structured specifications to produce shadcn/ui-based React components and Tailwind v4 utility classes. The system writes page routes under src/app/ and shared components under src/components/ui/. After each component batch, the pipeline runs a quick type-check and lint pass via eslint and tsconfig.json to catch regressions early.
Phase 4: Asset Integration and Optimization
Harvested media from Phase 1 integrates into the generated codebase with proper optimization.
The pipeline copies media files into appropriate public/ sub-folders and generates Next.js <Image/> wrappers for raster assets and <video/> tags for video content. When required, the system optimizes images using sharp or similar tools, ensuring production-ready performance.
Phase 5: Final Validation and Build
The final phase ensures the cloned site runs without errors and matches the original layout.
The system executes npm run check to run linting, type-checking, and production builds. Optional pixel-diff tooling compares rendered pages against original screenshots. Results are committed as a series of incremental commits, each representing a verified phase, producing a ready-to-deploy Next.js application.
Why a Multi-Phase Approach?
The multi-phase pipeline design prevents the “one-big-commit” problem by enforcing incremental guarantees.
- Early Error Detection: By validating after each phase, the pipeline catches issues like missing assets or malformed component props immediately rather than after a monolithic build.
- Parallel Processing: When multiple URLs are supplied, the inspection phase runs in parallel, while specification-to-code flows remain isolated in
docs/research/<hostname>/directories. - Auditability: All inspection data and design decisions persist as plain files, allowing reviewers to trace how specific UI elements became components.
- Extensibility: New phases such as accessibility audits or SEO extraction can be added without breaking existing ones because each phase maintains a clear input-output contract.
Key Implementation Files
According to the repository source code, the multi-phase pipeline is defined and orchestrated through several critical files:
.github/skills/clone-website/SKILL.md– Contains the detailed skill definition, including the phase breakdown and incremental-commit policy..windsurf/workflows/clone-website.md– Implements the workflow script that enforces multi-phase steps during execution.docs/research/INSPECTION_GUIDE.md– Provides the guide for Phase 1, specifying what to capture and how to store assets.scripts/sync-skills.mjsandscripts/sync-agent-rules.sh– Utility scripts that synchronize skill and agent definitions after each phase completes.src/app/andsrc/components/ui/– Destination directories for Phase 3 output, housing generated pages and UI components.
The high-level overview is documented in the repository’s README.md (line 88), which introduces the multi-phase pipeline concept.
Code Examples
Invoke the pipeline using the CLI tool:
npx opencode clone-website https://example.com
After Phase 1 completes, the directory structure contains harvested assets:
/docs/research/example.com/
├─ screenshots/
│ └─ homepage.png
└─ design-tokens.md
/public/images/
└─ logo.png
Following Phase 3 synthesis, generated components appear as:
// src/components/ui/button.tsx
import { cn } from "@/lib/utils";
export function Button({ children, className, ...props }: Props) {
return (
<button
className={cn("rounded-md bg-primary px-4 py-2", className)}
{...props}
>
{children}
</button>
);
}
Run the final validation:
npm run check # runs lint, typecheck, and builds the app
# ✅ All checks passed – the cloned site is ready for deployment
Summary
- The multi-phase pipeline in JCodesMore/ai-website-cloner-template converts websites through five distinct phases: Inspection, Specification, Synthesis, Integration, and Validation.
- Each phase produces verifiable artifacts stored in
docs/research/andpublic/directories before advancing. - The
/clone-websiteskill orchestrates the workflow defined in.github/skills/clone-website/SKILL.mdand.windsurf/workflows/clone-website.md. - Incremental validation prevents cascading errors and maintains an auditable commit history.
- The pipeline outputs production-ready Next.js applications using shadcn/ui components and Tailwind v4 styling.
Frequently Asked Questions
What is the multi-phase pipeline in the AI Website Cloner Template?
The multi-phase pipeline is a structured automation workflow that splits website cloning into five discrete stages: Inspection and Asset Harvest, Specification Generation, Code Synthesis, Asset Integration and Optimization, and Final Validation and Build. This architecture ensures each transformation stage completes successfully before the next begins, preventing errors from compounding across the conversion process.
How does the pipeline handle errors during website cloning?
The pipeline catches errors incrementally by validating artifacts after each phase. For example, Phase 3 runs type-checking and linting via tsconfig.json and eslint immediately after generating components, while Phase 5 executes npm run check to verify the entire build. If validation fails, the process halts at the specific phase, allowing developers to inspect artifacts in docs/research/ or src/components/ before retrying.
Can the pipeline process multiple websites simultaneously?
Yes, the pipeline supports parallel processing during the Inspection phase (Phase 1), where multiple URLs can be harvested concurrently. However, the Specification and Synthesis phases remain isolated per hostname, storing artifacts in separate docs/research/<hostname>/ directories to prevent cross-contamination between sites.
Where are the inspection artifacts stored during the cloning process?
Phase 1 stores harvested assets in three primary locations: screenshots and design tokens reside in docs/research/<hostname>/, media files such as images and videos go into public/images/ and public/videos/, and extracted specifications are written to docs/research/…/components.md and docs/research/…/styles.md for consumption by the code synthesis phase.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →