How to Clone Websites with Complex JavaScript Interactions Using the AI Website Cloner Template
The AI Website Cloner Template reverse-engineers live sites with sophisticated JavaScript behaviors—including scroll-driven animations, click-toggles, and hover effects—by capturing computed styles and dynamic states through a browser-automation pipeline before generating production-ready Next.js 16 components.
The JCodesMore/ai-website-cloner-template provides a complete system for cloning websites with complex JavaScript interactions. Unlike static HTML scrapers, this tool uses a multi-phase pipeline to record every interactive state, ensuring the regenerated Next.js application behaves identically to the original source.
How the Multi-Phase Pipeline Captures JavaScript Interactions
The repository implements a five-phase pipeline that treats interaction discovery as a mandatory sweep. This ensures nothing is left to guesswork when rebuilding dynamic behaviors.
Phase 1: Reconnaissance and Interaction Discovery
A browser-automation MCP (using Chrome or Playwright) scrolls through the target page and takes full-page screenshots. It extracts the computed CSS for every element using getComputedStyle and records dynamic states by triggering scroll, click, and hover events.
The extracted data is stored in structured documentation files:
docs/research/BEHAVIORS.mdlogs all interaction patternsdocs/research/PAGE_TOPOLOGY.mdmaps the site structure
Phase 2: Foundation Build
Before any components are generated, the pipeline establishes the global scaffold. This phase updates src/app/layout.tsx with fonts and metadata, and populates src/app/globals.css with Tailwind v4 utility classes, color tokens, and keyframe animations. This guarantees the generated site compiles before any component work begins.
Phase 3: Component Specification
For each visual section, the extractor writes a detailed specification file at docs/research/components/<Component>.spec.md. These specs contain:
- Screenshot references for visual comparison
- Exhaustive lists of computed style values
- Interaction models (e.g., scroll-driven with IntersectionObserver, click-toggles with transition)
- Multi-state content (all tab panels, hover states, scroll thresholds)
- Exact asset paths to be used
Phase 4: Parallel Builder Dispatch
Builder agents receive the full specification inline and generate isolated React components in src/components/<Component>.tsx. The dispatch logic respects the complex-budget rule: if a specification exceeds approximately 150 lines, the section is automatically split into smaller sub-components. This ensures each builder handles a manageable, high-quality chunk of code.
Phase 5: Merge and QA
After each builder finishes, its worktree is merged into main, and npm run build verifies a clean compilation. A visual diff against the original screenshots guarantees that both the static layout and the dynamic behaviors match pixel-perfectly.
The Interaction Sweep: Recording Dynamic States
The .github/skills/clone-website/SKILL.md file defines the "Interaction Sweep" as a mandatory workflow step. During this sweep, the automation systematically triggers every possible user interaction—scrolling past thresholds, clicking toggles, hovering over elements, and activating carousels.
By recording these states into the component specifications, the pipeline captures not just the appearance but the behavioral logic of the original site. This ensures that complex JavaScript interactions like smooth-scroll libraries and custom animations are faithfully reproduced in the cloned output.
Example Component Specification for Complex Behaviors
The specification files serve as the single source of truth for builder agents. Here is an excerpt showing how complex scroll behaviors are documented:
# HeroSection Specification
## Overview
- **Target file:** src/components/HeroSection.tsx
- **Screenshot:** docs/design-references/hero-desktop.png
- **Interaction model:** scroll-driven with IntersectionObserver
## Computed Styles (exact values)
### Container
- display: flex
- padding: 2rem 1rem
- background-color: #f5f5f5
## States & Behaviors
### Nav shrink on scroll
- **Trigger:** scroll-position ≥ 80px
- **State A (before):** height: 120px; box-shadow: none
- **State B (after):** height: 80px; box-shadow: 0 2px 6px rgba(0,0,0,0.15)
- **Transition:** all 0.3s ease
Builder agents consume these specifications to generate components that match the exact timing and easing of the original interactions.
Getting Started with the Clone Website Skill
To clone a website with complex JavaScript interactions, run the /clone-website skill through Claude Code or your preferred AI agent interface:
# 1️⃣ Install dependencies
npm install
# 2️⃣ Start the AI coding agent (Claude Code is recommended)
claude --chrome
# 3️⃣ Run the clone-website skill on one or more targets
/clone-website https://example.com https://another-site.org
The generated output appears in src/components/ as fully typed TypeScript React components. The src/lib/utils.ts file provides the cn() helper utility used by all generated components to compose Tailwind class strings consistently.
Summary
- Multi-phase pipeline: The system uses Reconnaissance, Foundation Build, Component Specification, Parallel Builder Dispatch, and Merge & QA phases to ensure accuracy.
- Mandatory interaction sweep: Every scroll, click, and hover state is recorded in
docs/research/BEHAVIORS.mdbefore code generation begins. - Detailed specifications: Component specs in
docs/research/components/capture both computed styles and behavioral logic. - Complex-budget rule: Specifications exceeding ~150 lines are split into sub-components to maintain code quality.
- Next.js 16 output: The final output is a production-ready Next.js application with all dynamic interactions preserved.
Frequently Asked Questions
Does the AI Website Cloner Template work with single-page applications (SPAs) built with React or Vue?
Yes, the template handles SPAs by using browser automation to capture the computed DOM state and styles after JavaScript execution. The pipeline records the final rendered output and interaction states, then recreates them as static Next.js 16 components with equivalent behavior, regardless of the original framework.
How does the system handle custom JavaScript libraries like smooth-scroll or GSAP?
The system treats these libraries as behavioral targets to replicate. During the reconnaissance phase, it captures the timing functions, easing curves, and transform values produced by libraries like GSAP. These values are written into the component specifications—often as CSS keyframes in src/app/globals.css or React state transitions—ensuring the cloned site reproduces the animations without requiring the original library dependency.
What happens if a component is too complex for one builder agent?
The dispatch logic implements a complex-budget rule that automatically splits any specification exceeding approximately 150 lines into smaller sub-components. This prevents context overflow and allows parallel builders to tackle complex sections—like multi-state carousels or animated dashboards—as isolated, manageable units that merge cleanly into the final codebase.
Can I modify the generated components after cloning?
Absolutely. The generated components in src/components/ are standard React TypeScript files using Tailwind CSS classes. The src/lib/utils.ts helper function assists with class composition, but the output contains no proprietary abstractions. You can extend, refactor, or restyle the components using standard Next.js and React development practices.
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 →