一键导入
test-coverage-improve
Analyze and improve test coverage for the codebase targeting 80%+. Use when coverage is low or after adding new untested code.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Analyze and improve test coverage for the codebase targeting 80%+. Use when coverage is low or after adding new untested code.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | test-coverage-improve |
| description | Analyze and improve test coverage for the codebase targeting 80%+. Use when coverage is low or after adding new untested code. |
| allowed-tools | Bash(npm test:*), Task, Read, Edit, MultiEdit, Write, Glob, Grep |
Please analyze and improve the test coverage for this codebase following the established testing strategy. Run npm test -- --coverage to get current coverage and target ≥80% coverage.
Use parallel subagents to run tests and improve coverage.
npm test -- --coverage to identify gaps in coveragesrc/lib/utils/, src/lib/services/, app/api/, and src/components/src/lib/repositories/ - these should remain untested@prisma/client directly in test files@prisma/client - if errors occur, mock the specific repository instead// At top of test file:
jest.mock("@/lib/repositories/userRepository", () => ({
getById: jest.fn(),
updateName: jest.fn(),
}));
const mockUserRepository = require("@/lib/repositories/userRepository");
// In test:
mockUserRepository.getById.mockResolvedValue({ id: '1', name: 'Ana García' });
__tests__/unit/ for utility functions and services__tests__/integration/ for components and API handlers*.test.tsx)src/lib/utils/, src/lib/services/)// Mock external libraries at module level
jest.mock("langfuse", () => ({
Langfuse: jest.fn(),
TextPromptClient: jest.fn(),
}));
// Mock console methods and restore in cleanup
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation(() => {});
afterAll(() => consoleLogSpy.mockRestore());
app/api/)src/components/, app/)@testing-library/react for user interactionsUse realistic Spanish business data matching the codebase:
const testData = {
customers: [
{ name: "Ana García", phone: "+34611223344" },
{ name: "José María Fernández-Vázquez", phone: "+34612345678" },
],
businesses: [
{ name: "Salon Bella", address: "Calle Mayor 1, Madrid" },
{ name: "Peluquería Ñoña & Coiffeur", services: ["corte", "peinado"] },
],
specialChars: "¡Hola! ¿Cómo está usted?",
emojis: "💇♀️✂️🎨",
};
Test these scenarios comprehensively:
null and undefined values{} and arrays []process.env.NODE_ENV (TypeScript read-only)expect.any(Boolean) for environment-dependent behavior// ✅ DO: Test actual behavior
expect(mockUtil.inspect).toHaveBeenCalledWith(testObj, {
depth: null,
colors: process.env.NODE_ENV === "development",
});
// ❌ DON'T: Mock NODE_ENV directly
// process.env.NODE_ENV = "development"; // TypeScript error
describe blocks that explain the component/function contextit/test descriptions that read like specificationsafterAll or afterEachFor each file with coverage gaps:
After implementing tests:
npm test -- --coverage to verify improvementStart by analyzing current coverage, then systematically address gaps while strictly following the mocking strategy and using realistic Spanish business data.
Create git commits from current changes using Conventional Commits format. Use when ready to commit staged or unstaged changes.
Generate a branch name from current changes and create it if on main. Use when starting new work and need a properly named feature branch.
Create a pull request from the current branch with quality checks. Use when changes are ready for review, after committing.
Interactive guide for creating new Claude skills with proper structure, frontmatter, and trigger conditions. Use when building a new skill, scaffolding a SKILL.md, or need guidance on skill best practices.
Run Prisma generate, lint (auto-fix), typecheck, and tests; iterate until clean, summarize results. Use when CI is failing or before pushing to verify the repo is clean.
Create a new GitHub issue for a feature, bug, or chore. Use when you have an idea, bug report, or task that needs a GitHub issue with analysis and solution options.