This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
.claude/rules/preact.md— enforceable Preact + signals rules; always follow when editingsrc/**/*.{js,jsx}.claude/skills/tymer-preact/SKILL.md— full rationale and Tymer-specific signals examples; load via the Skill tool when depth is needed
This is a countdown timer web application built with Preact and Vite called "Tymer". It's a Pomodoro-style timer that supports multiple periods with customizable durations and automatic time tracking persistence via localStorage.
pnpm run dev- Start development server (Vite) on port 3000pnpm run build- Build for production todist/folderpnpm run preview- Preview production buildpnpm test- Run tests with Vitestpnpm run test:coverage- Run tests with coverage reportpnpm run format- Format code with Prettierpnpm run format:check- Check code formatting
- Preact: React-like UI library (smaller than React)
- @preact/signals: State management with reactive signals
- Vite: Build tool and development server
- Vitest: Testing framework
- Sass: CSS preprocessing
- Howler: Audio library for sound effects
- date-fns: Date/time utilities
State Management: Uses Preact signals for reactive state management. The main timer state is in src/lib/timer.js with signals like timerState, currentPeriod, timerHasFinished.
Timer Logic: Core timer functionality in src/lib/timer.js includes:
- Multi-period timer configuration with work/break periods
- Auto-extension when periods complete
- Persistence to localStorage
- Sound effects on period transitions
Component Architecture:
src/app/main.jsx- Entry point, renders Timer componentsrc/components/timer/timer.jsx- Main timer component that initializes timer and renders all sub-componentssrc/components/timer/controls/- Timer controls (start/pause/reset) and period controlssrc/components/timer/timeline/- Visual timeline representationsrc/components/timer/stats/- Statistics displaysrc/components/timer/debug/- Debug information components
Styling: SCSS files in src/app/ with component-specific styling using BEM-like naming conventions.
src/lib/timer.js- Core timer logic and state management (580+ lines)src/lib/storage.js- localStorage persistence helperssrc/lib/sounds.js- Audio playback using Howlersrc/lib/format.js- Time formatting utilitiesvite.config.js- Vite configuration with PWA plugin
- Test files use
.test.jsor.test.jsxextensions - Tests located in
src/lib/timer.test.jsandsrc/components/timer/timer.test.jsx - Test setup in
src/test/setup.js - Testing library: Vitest with jsdom environment
The app is configured as a Progressive Web App with:
- Service worker for offline functionality
- Web app manifest for installability
- Icons and assets in
public/directory
Default timer has predefined work/break periods (48min work, 12min break pattern) defined in PERIOD_CONFIG constant in src/lib/timer.js:10-24.
Audio files in public/ directory:
button.wav- Button interactionsperiod-end.wav- Period completiontimer-end.wav- Timer completiontick.wav- Periodic ticks during work periods