install
source · Clone the upstream repo
git clone https://github.com/openclaw/skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/brunoscardoso/plan-flow/write-tests" ~/.claude/skills/clawdbot-skills-write-tests && rm -rf "$T"
manifest:
skills/brunoscardoso/plan-flow/write-tests/SKILL.mdsource content
Write Tests
Generate tests for specified code to achieve coverage targets.
What It Does
- Reads the target file(s)
- Analyzes functions and classes to test
- Identifies edge cases and error scenarios
- Generates comprehensive test file(s)
- Follows project testing patterns
Usage
/write-tests <path> [coverage]
Arguments:
(required): File or directory to generate tests forpath
(optional): Target coverage percentage (default: 80)coverage
Output
Creates test files following project conventions:
for TypeScript*.test.ts
for JavaScript*.test.js
for Pythontest_*.py
Test Coverage
| Coverage | Description |
|---|---|
| 80% | Standard target (default) |
| 90% | High coverage for critical code |
| 100% | Complete coverage (edge cases included) |
What Gets Tested
- Exported Functions: All public functions
- Classes: Constructor, public methods
- Edge Cases: Null, undefined, empty, boundary values
- Error Scenarios: Exception handling, validation errors
- Async Code: Promise resolution/rejection
Test Structure (TypeScript/Jest)
describe('FunctionName', () => { beforeEach(() => { // Setup }); it('should handle normal input', () => { // Arrange // Act // Assert }); it('should handle edge case', () => { // Test edge case }); it('should throw error for invalid input', () => { expect(() => fn(invalid)).toThrow(); }); });
Example
/write-tests src/utils/validator.ts 90
Output:
Generating tests for src/utils/validator.ts Target coverage: 90% Analyzing functions: - validateEmail() - 3 test cases - validatePassword() - 5 test cases - validateUsername() - 4 test cases Generated: src/utils/validator.test.ts Test Summary: - 12 test cases generated - Estimated coverage: 92% Run tests with: npm run test src/utils/validator.test.ts
Test Patterns
The skill follows testing patterns from your project:
- Jest for JavaScript/TypeScript
- Pytest for Python
- Uses existing mock factories if available
- Follows AAA pattern (Arrange, Act, Assert)
Next Command
After generating tests, run them with your test runner:
for Jestnpm run test
for Pythonpytest