3.4 KiB
3.4 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
excel2json — a SvelteKit web application for converting Excel files to JSON with visual mapping configuration. Built with Svelte 5, SvelteKit 2, TypeScript, and Tailwind CSS 4.
Commands
npm run dev— start dev server (typically http://localhost:5173)npm run build— production buildnpm run preview— preview production buildnpm run check— type-check with svelte-checknpm run check:watch— type-check in watch modenpm run test— run all tests oncenpm run test:unit— run tests in watch modenpm run test:unit -- --run --testNamePattern="pattern"— run a single test by name
Architecture
- Framework: SvelteKit 2 with Svelte 5 (runes API:
$state,$props,$derived, etc.) - Styling: Tailwind CSS 4 with
@tailwindcss/formsand@tailwindcss/typographyplugins, configured viasrc/routes/layout.css - Adapter:
@sveltejs/adapter-auto - TypeScript: strict mode enabled
- Dependencies:
xlsx(SheetJS) for Excel parsing,dayjsfor date handling
Testing
Two Vitest project configurations in vitest.config.ts:
client— browser tests using Playwright (headless Chromium). Files matchingsrc/**/*.svelte.{test,spec}.{js,ts}. Usesvitest-browser-sveltefor component rendering.server— Node.js unit tests. Files matchingsrc/**/*.{test,spec}.{js,ts}(excluding.svelte.test files).
All tests require assertions (expect.requireAssertions: true).
Key Conventions
- Svelte components use
lang="ts"in script tags - Shared library code goes in
src/lib/(aliased as$lib) - Use Svelte 5 runes syntax, not legacy Svelte 4 patterns
Core Application Structure
Single-page application with split-pane layout:
src/routes/+page.svelte— Main page containing all application logicsrc/lib/components/ExcelTable.svelte— Left panel showing Excel data with column configurationsrc/lib/components/JsonPreview.svelte— Right panel showing JSON output with syntax highlightingsrc/lib/components/ColumnConfig.svelte— Modal for column mapping configurationsrc/lib/components/ApiConfigModal.svelte— API enrichment rules configurationsrc/lib/components/SubmissionSettings.svelte— Data submission settings
Core libraries:
src/lib/excel.ts— Excel/CSV reading and parsingsrc/lib/converter.ts— Mapping conversion core logicsrc/lib/types.ts— TypeScript type definitions (MappingConfig,RowData, etc.)
Data flow: File upload → Excel parsing → Mapping configuration → JSON conversion → Preview/Export
Key features:
- Nested object support via dot notation (e.g.,
user.address.city) - Date formatting including Excel serial date compatibility
- Empty value handling (exclude field or use default value)
- Template import/export for mapping configurations
- API enrichment for dynamic data fetching
Svelte MCP Server
A Svelte MCP server is available for Svelte 5 / SvelteKit documentation lookup and code validation. When writing Svelte code:
- Use
list-sectionsfirst to discover relevant documentation - Use
get-documentationto fetch needed sections - Use
svelte-autofixerto validate Svelte code before finalizing — keep calling until no issues remain - Offer
playground-linkonly if code was NOT written to project files