一键导入
test-generation
Use when the user asks to add tests, improve test coverage, generate a test suite for a module, or write tests for a specific function or class.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when the user asks to add tests, improve test coverage, generate a test suite for a module, or write tests for a specific function or class.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when the user references or attaches Microsoft Office files (.doc, .docx, .xls, .xlsx, .ppt, .pptx), PDFs, images (.png, .jpg, .jpeg), or CSV/JSON/YAML from Teams or SharePoint and asks to extract, summarize, tabulate, or cross-reference their contents. Ships a runnable `extract.py` — invoke that directly rather than re-implementing extraction inline.
Use when the user asks to integrate a third-party REST or GraphQL API — fetching data, authenticating, handling rate limits, retrying on failure, and wiring responses into the application.
Use when the user reports a bug, shows a stack trace, says "something's broken", or asks for help debugging unexpected behavior. Covers reproduction, isolation, root cause, fix, and regression test — the full loop. Applies to any language or stack.
Use when the user asks to add, alter, or drop database tables or columns, create a migration script, or run schema changes safely against a live database.
Use when the user describes a rough feature idea and wants to clarify requirements, resolve open questions, and produce a clean brief before writing a PRD. Activates on phrases like "I want to build", "I have an idea for", "what if we added", "can we make a feature that".
Use when the user asks to produce a PowerPoint deck — presentations, status updates, data read-outs, or structured deliverables. Takes a JSON/YAML spec and writes a .pptx with consistent slide layouts (title, section, bullets, two-column, table). Ships a runnable `generate.py`.
| name | test-generation |
| description | Use when the user asks to add tests, improve test coverage, generate a test suite for a module, or write tests for a specific function or class. |
| allowed-tools | Read, Grep, Glob, Bash, Edit, Write |
Full-loop test writing: read the code under test, identify untested behaviours and edge cases, write tests that assert observable outcomes (not implementation details), and leave the suite green.
TestClient (FastAPI) or httpx.test_<unit>_<scenario>_<expected>.pytest --cov — aim for 80%+ on the changed module.# test_<module>.py
import pytest
from myapp.<module> import <function_or_class>
# --- Happy path ---
def test_<function>_returns_expected_result():
result = <function>(valid_input)
assert result == expected_output
# --- Boundary ---
@pytest.mark.parametrize("value,expected", [
(0, ...),
(-1, ...),
(None, ...),
])
def test_<function>_boundary_values(value, expected):
assert <function>(value) == expected
# --- Error path ---
def test_<function>_raises_on_invalid_input():
with pytest.raises(ValueError, match="descriptive message"):
<function>(invalid_input)
# --- Side effects / state ---
def test_<function>_writes_to_db(db_session):
<function>(db_session, payload)
record = db_session.query(Model).one()
assert record.field == expected_value
# --- Async ---
@pytest.mark.asyncio
async def test_<async_function>_happy_path():
result = await <async_function>(input)
assert result.status == "ok"
import { describe, it, expect, vi } from 'vitest';
import { myFunction } from '../src/myModule';
describe('myFunction', () => {
it('returns expected result for valid input', () => {
expect(myFunction('valid')).toBe('expected');
});
it('throws for invalid input', () => {
expect(() => myFunction(null)).toThrow('descriptive message');
});
it('calls dependency once with correct args', () => {
const spy = vi.spyOn(dependency, 'method');
myFunction('input');
expect(spy).toHaveBeenCalledWith('input');
expect(spy).toHaveBeenCalledOnce();
});
});
import { render, screen, userEvent } from '@testing-library/react';
import { MyComponent } from '../src/MyComponent';
it('shows error message when form submitted empty', async () => {
render(<MyComponent />);
await userEvent.click(screen.getByRole('button', { name: /submit/i }));
expect(screen.getByRole('alert')).toHaveTextContent('Required');
});
../../shared/guidelines/pr-and-review.md:
tests assert observable behaviour, not internal names..skip or xfail without a linked issue.assert mock.called) without
checking what was called with or what was returned.time.sleep in tests — use freeze_time or mock the clock.mutmut run to verify tests actually catch regressions.hypothesis for functions with large input spaces.pact for API consumer/provider boundary validation.--cov-fail-under=80 to CI so coverage can't regress.