This skill should be used when the user asks to "improve test coverage", "add unit tests", "TDD", "test this module", "write tests for", "increase coverage", "/ut command", or discusses unit testing strategies. Covers the unit test loop workflow, React Testing Library best practices, query priorities, and coverage improvement strategies.
View on GitHubskills/unit-test-loop/SKILL.md
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/SomtoUgeh/somto-dev-toolkit/blob/main/skills/unit-test-loop/SKILL.md -a claude-code --skill unit-test-loopInstallation paths:
.claude/skills/unit-test-loop/# Unit Test Loop - Coverage Improvement **Current branch:** !`git branch --show-current 2>/dev/null || echo "not in git repo"` The unit test loop uses a 2-phase workflow with Dex task tracking for persistent, cross-session test coverage improvement. ## The 2-Phase Approach | Phase | Name | Purpose | |-------|------|---------| | 1 | Coverage Analysis | Identify gaps, prioritize files | | 2 | Dex Handoff | Create epic + tasks from analysis | After Phase 2, use `/complete <task-id>` for each test task. ## Starting the Loop ```bash /ut "Improve coverage for auth module" # Basic /ut "Add tests" --target 80% # With target ``` ## Phase 1: Coverage Analysis 1. Run coverage command to see current state 2. Identify files with low coverage 3. Prioritize 3-7 test tasks for user-facing behavior **Output:** `<phase_complete phase="1"/>` ## Phase 2: Dex Handoff Create Dex epic with target, then tasks for each gap: ```bash # Create epic dex create "Unit Test Coverage" --description "Target: 80% coverage" # For each gap dex create "Test: login validation" --parent <epic-id> --description " File: src/auth/login.ts Current: 45% Test should verify: - [ ] Valid credentials succeed - [ ] Invalid credentials show error " ``` **Output:** `<phase_complete phase="2"/>` or `<promise>UT SETUP COMPLETE</promise>` ## Working on Tasks Use Dex + /complete workflow: ```bash dex list --pending # See what's ready dex start <id> # Start working /complete <id> # Run reviewers and complete ``` ## React Testing Library Patterns > "The more your tests resemble the way your software is used, > the more confidence they can give you." ### Query Priority (Use in Order) | Priority | Query | Use Case | |----------|-------|----------| | 1 | `getByRole` | Default choice, use `name` option | | 2 | `getByLabelText` | Form fields with labels | | 3 | `getByPlaceholderText` | Only if no label available | | 4 | `getByText` | Non-interactive e