This document provides guidelines for AI agents working on the
use-stored-state project.
use-stored-state is a React hooks library.
useStoredStatesynchronizes state across query params,sessionStorage, andlocalStorage.useKeyStoreprovides lower-level synchronization for a single source.
- Language: TypeScript (CommonJS)
- Runtime: React (peer dependency)
- Testing: Vitest + Testing Library
- Linting: ESLint
- Formatting: Prettier
- Type Checking: TypeScript compiler
- Dependency Analysis: Knip
- Markdown Linting: markdownlint-cli2
- Release Management: semantic-release
- Install dependencies:
npm install - Understand the existing codebase and tests
- Run
npm run checkto ensure the project is in a clean state
-
Follow TDD (Test-Driven Development):
- Write tests before implementing features
- Ensure tests are meaningful and cover edge cases
- Keep tests focused and maintainable
- Place tests alongside source files with
.test.tsextension
-
Run Quality Gates Early and Often:
- Use
npm run checkto validate code meets all quality standards - Fix issues immediately before proceeding
- Use
-
Code Quality Standards:
- Follow TypeScript best practices
- Maintain type safety - avoid
anytypes - Write clear, self-documenting code
- Keep functions small and focused
- Follow existing code patterns and conventions
-
Mutation Testing Standards:
- Mutation testing is required for changed behavior
- Expected result is
100%mutation score - There must be
0surviving mutants - There must be
0timed out mutants - Run mutation tests with:
npm run mutate
- For equivalent mutants:
- First prefer code or test changes that remove ambiguity
- Only then use narrow Stryker disable comments with rationale
npm run test- Run tests with Vitestnpm run lint- Run ESLintnpm run lint:fix- Auto-fix ESLint issuesnpm run prettier- Check code formattingnpm run prettier:fix- Auto-fix formatting issuesnpm run type-check- Run TypeScript type checkingnpm run knip- Check for unused dependencies and exportsnpm run markdownlint- Lint markdown filesnpm run markdownlint:fix- Auto-fix markdown issuesnpm run mutate- Run full mutation testing suitenpm run check- Run all quality checks (recommended)
- Run
npm run check- all checks must pass - Ensure all tests pass
- Run mutation tests and confirm:
100%mutation score0surviving mutants0timed out mutants
- Review your changes carefully
- Follow commit message conventions (see commits.instructions.md)
src/- Source code*.ts- TypeScript source files*.test.ts- Test files (co-located with source)parsers/- Parser implementations
- Configuration files at root:
tsconfig.json,tsconfig.build.json,tsconfig.eslint.jsoneslint.config.mjsprettier.config.cjsknip.config.js
- Make the smallest possible changes to achieve the goal
- Don't refactor unrelated code
- Don't fix unrelated issues
- Preserve existing functionality
- Validate all inputs
- Don't introduce security vulnerabilities
- Run security audits with
npm audit - Fix any security issues in code you change
- Update README.md if user-facing behavior changes
- Do not manually edit CHANGELOG.md (automatically managed by semantic-release)
- Add JSDoc comments for public APIs
- Keep documentation in sync with code
- Ensure all quality checks pass
- Write clear PR description explaining changes
- Reference related issues
- Request review from maintainers
- Address review feedback promptly
- Don't skip running
npm run checkbefore committing - Don't commit code with TypeScript errors
- Don't disable linting rules without good reason
- Don't commit without tests for new functionality
- Don't leave surviving or timed out mutants unresolved
- Check existing tests for examples
- Review similar functionality in the codebase
- Refer to README.md for project overview
- Ask maintainers for clarification on complex issues