This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Install dependencies
pnpm install --frozen-lockfile --ignore-scripts
# Build all packages (order matters: shared → engine → api/web/mcp)
pnpm build
# Run all tests
pnpm test
# Type-check all packages
pnpm typecheck
# Lint Shopify theme files
pnpm theme:check
# Full verification bar (run before committing)
pnpm build && pnpm test && pnpm typecheck && pnpm theme:check
# Dev mode (starts all watchers and servers in parallel)
pnpm dev
# Run tests for a single package
pnpm --filter @shopify-web-replicator/engine test
pnpm --filter @shopify-web-replicator/api test
pnpm --filter @shopify-web-replicator/mcp test
pnpm --filter @shopify-web-replicator/shared test
# Run a single test file
pnpm --filter @shopify-web-replicator/engine exec vitest run src/orchestrator.test.tsThis is a pnpm monorepo. Build order is strict: shared must be built before engine, and engine before api/mcp.
-
packages/shared— All shared types, Zod schemas, and thecreateReplicationJobfactory. TheReplicationJobtype and all pipeline stage/status enums live here. This is the single source of truth for the data contract. -
packages/engine— The deterministic replication engine. ContainsReplicationOrchestrator(the public API),ReplicationPipeline(step-by-step execution), and concrete service implementations (DeterministicPageAnalyzer,DeterministicThemeMapper,ShopifyThemeGenerator,ShopifyStoreSetupGenerator,ShopifyCommerceWiringGenerator,ShopifyThemeValidator,ShopifyIntegrationReportGenerator). All services depend on interfaces defined insrc/services/types.ts, enabling injection of test doubles. -
apps/mcp— The primary product surface. A stdio MCP server exposing three tools:replicate_site_to_theme,get_replication_job,list_replication_jobs. Entry point isapps/mcp/src/index.ts. The server logic is inserver.ts; runtime preflight checks (Node sqlite support, Shopify CLI presence, writable paths) live inruntime-preflight.ts. -
apps/api— Optional companion HTTP API (Hono on@hono/node-server). Binds to127.0.0.1:8787by default. Routes:POST /api/jobs,GET /api/jobs/:jobId,GET /api/jobs,GET /api/runtime. Note:apps/api/src/contains its own copies of the engine services (not imported frompackages/engine) — this is intentional duplication for the standalone API surface. -
apps/web— Optional companion React/Vite frontend for local job review. Communicates withapps/api. -
packages/theme-workspace— The Shopify theme directory that receives all generated artifacts. Has its own Shopify license.
ReplicationOrchestrator.replicateStorefront() → ReplicationPipeline.process() runs these stages in order:
intake(pre-completed on job creation)analysis—DeterministicPageAnalyzermapping—DeterministicThemeMappertheme_generation—ShopifyThemeGenerator(writes.liquid+.jsonto theme workspace)store_setup—ShopifyStoreSetupGenerator(writesconfig/generated-store-setup.json)commerce_wiring—ShopifyCommerceWiringGenerator(writessnippets/generated-commerce-wiring.liquid)validation—ShopifyThemeValidator(runsshopify theme check)integration_check—ShopifyIntegrationReportGenerator(writesconfig/generated-integration-report.json)review— terminalneeds_reviewstate
Job state is persisted to SQLite (.data/replicator.db) after each stage via SqliteJobRepository.
- The
apps/apiservices are duplicated frompackages/engine— changes to engine service logic may need to be mirrored inapps/api/src/services/. - All generated artifact paths are stable constants defined in
packages/shared/src/job.ts(stableThemeArtifacts,stableStoreSetupArtifact,stableCommerceArtifact,stableIntegrationArtifact). - The MCP server runs preflight checks on every tool call; failures surface as structured
RuntimePreflightErrorwith typedissues. - Page type is auto-derived from URL path when not provided (
/→homepage,/products/*→product_page,/collections/*→collection_page, elselanding_page).
| Variable | Default |
|---|---|
REPLICATOR_DB_PATH |
.data/replicator.db |
THEME_WORKSPACE_PATH |
packages/theme-workspace |
HOST |
127.0.0.1 |
PORT |
8787 |
REPLICATOR_ALLOWED_ORIGINS |
localhost/127.0.0.1 on ports 5173, 4173, 8787 |
VITE_API_BASE_URL |
http://127.0.0.1:8787 |