write-unit-tests

Generate isolated unit tests with mocks, edge cases, and coverage exclusions.

Updated Feb 15, 2026
One-click install
npx skills add https://github.com/abranjith/spec-lite --skill write-unit-tests-abranjith
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-unit-tests
Source: https://github.com/abranjith/spec-lite/tree/main/skills/write-unit-tests
Command: npx skills add https://github.com/abranjith/spec-lite --skill write-unit-tests-abranjith

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It removes the guesswork from unit testing by turning source code or feature specifications into focused, isolated tests that cover real behavior, edge cases, and error paths.

Core Features & Use Cases

  • Standalone file testing: Generate tests directly from one or more source files when no feature spec is available.
  • Feature-context testing: Map tests to FEAT-IDs and TASK-IDs when working from .spec-lite feature plans and implementation files.
  • Coverage strategy: Classify files as testable, partially testable, or excluded, then update coverage settings for boilerplate and non-behavioral code.
  • Real-world use case: A team adds a validation service with branching rules, boundary checks, and fallback logic; this Skill produces a test suite that exercises each meaningful path while skipping DTOs and framework wiring.

Quick Start

Use the write-unit-tests skill to generate a unit test plan and test cases for the target source file or feature spec, including mocks, edge cases, and coverage exclusions.

Frequently Asked Questions about write-unit-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate unit tests for logic-bearing source code?

To generate unit tests, provide your source files or feature specifications to classify testable files and produce isolated tests covering real behavior, edge cases, and error paths.

How do I write unit tests from feature specifications with traceability?

You can write unit tests from feature specs by mapping test cases to FEAT-IDs and TASK-IDs using feature-context workflows, ensuring implementation files align with coverage requirements.

What is the best way to handle coverage configuration for non-behavioral code?

The best way to handle coverage configuration is classifying files as testable, partially testable, or excluded, then updating coverage settings to skip boilerplate and framework wiring.

Can I create isolated unit tests for a standalone file without a feature spec?

Yes, you can create isolated unit tests directly from one or more source files when no feature spec is available, applying dependency mocking and AAA-style test design.

How do you design unit tests that cover branching rules and fallback logic?

To design unit tests for branching rules, apply AAA-style test design and dependency mocking to exercise each meaningful path while validating boundary checks and fallback logic.

When should I exclude files from branch coverage during test design?

You should exclude files from branch coverage when they contain non-behavioral code like DTOs and framework wiring, ensuring the test suite focuses strictly on logic-bearing source files.