# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Commands

```bash
yarn test                  # run all tests (watch mode)
yarn test:report           # run tests with verbose output
yarn coverage              # run tests with coverage report
yarn dev                   # start Vite dev server for the demo UI
yarn build                 # compile TypeScript + build library to dist/
yarn add:module <name>     # scaffold a new algorithm module in lib/<name>/
```

To run a single test file:
```bash
npx vitest run lib/<name>/<name>.test.ts
```

## Architecture

The repo has two independent layers:

- **`lib/`** — algorithm implementations, built as a publishable npm library. Each algorithm lives in its own subdirectory (`lib/<name>/`) with an implementation file, a test file, and an `index.ts` re-export.
- **`src/`** — Vite demo app (development only, not shipped in the library).

The library entry point is `lib/main.ts`. Build output goes to `dist/` (`counter.js` / `counter.umd.cjs`).

## Adding a New Algorithm

```bash
yarn add:module <algorithmName>
```

This creates `lib/<algorithmName>/` with:
- `<algorithmName>.ts` — implementation stub
- `<algorithmName>.test.ts` — Vitest test with default array `[-12, 1, 4, 6, 22]`
- `index.ts` — re-export
- `readme.md` — template with complexity table and time-tracking table (in Russian)

For competitive-programming / stdin problems, use `lib/__templateForSolution.ts` as a base — it reads lines via `readline` and parses them as numbers.

## Testing

Uses **Vitest** (not Jest). Test files live next to implementations in `lib/`. The `vitest.config.ts` enables `@vitest/coverage-v8` for HTML + JSON coverage reports (output in `coverage/`).

## Learning Structure

Progress is tracked in `docs/`:
- `docs/progress.md` — weekly skill ratings
- `docs/daily-practice.md` — session log
- `docs/learning-plan.md` / `docs/weekly-schedule.md` — roadmap
- `docs/rules.md` — learning philosophy and algorithm phase breakdown (Phase 1–4 over 16 weeks)
