test-generator

test-generator is a skill for Claude Code, Codex from laolaoshiren/claude-code-skills-zh. It costs 79 tokens per session (977 once invoked), scanned A, original, MIT.

A test-writing helper that creates unit or integration tests from the code's actual behavior and contracts. Unit tests check small pieces of code, while integration tests check how real components work together.

In plain words
What is it for?
Use it to add tests for functions, classes, interfaces, defects, or missing coverage. It can inspect callers and existing tests, choose a suitable test level, implement focused cases, and run them for verification.
Why use it?
It avoids locking guessed behavior into permanent tests and keeps tests focused on observable results. It also helps isolate external services, use existing project conventions, and create regression tests for confirmed bugs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to add tests for functions, classes, interfaces, defects, or missing coverage. It can inspect callers and existing tests, choose a suitable test level, implement focused cases, and run them for verification.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/laolaoshiren/claude-code-skills-zh/test-generator
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add laolaoshiren/claude-code-skills-zh --skill test-generator
Clone the repo
git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-generator

README.md
[![agentmods](https://agentmods.dev/badge/skills/laolaoshiren/claude-code-skills-zh/test-generator/github.svg)](https://agentmods.dev/skills/laolaoshiren/claude-code-skills-zh/test-generator)
Your own site
<a href="https://agentmods.dev/skills/laolaoshiren/claude-code-skills-zh/test-generator"><img src="https://agentmods.dev/badge/skills/laolaoshiren/claude-code-skills-zh/test-generator/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for test-generator

Your own site · 80×15
<a href="https://agentmods.dev/skills/laolaoshiren/claude-code-skills-zh/test-generator"><img src="https://agentmods.dev/badge/skills/laolaoshiren/claude-code-skills-zh/test-generator.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 79 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 977 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00079 $0.00977
Opus 5 $0.00039 $0.00489
Sonnet 5 $0.00016 $0.00195
Haiku 4.5 $0.00008 $0.00098

Measured 10d ago against content hash 99b8c93fe91b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

test-generator scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/test-generator/SKILL.md · 86 lines

What it actually says

测试生成器

工作流程

1. 读取真实契约

检查目标代码及其:

  • 类型定义、公开文档、调用方和错误处理路径。
  • 现有测试、fixture、测试配置、依赖清单和项目测试命令。
  • 输入输出、副作用、状态变化、并发语义和系统边界。
  • 适用的仓库规则、Git 状态及本轮允许修改的范围。

区分“代码当前行为”和“产品期望行为”。两者冲突或契约不明确且会改变断言时,先列出证据与待确认假设;不要用测试固化猜测。

2. 选择测试层级

  • 纯逻辑优先使用快速、确定的单元测试。
  • 在系统边界隔离时间、随机数、文件系统、网络或第三方服务,避免 mock 被测模块的内部实现。
  • 需要验证真实组件协作时使用集成测试,可采用临时目录、测试数据库或受控服务,并确保资源隔离和清理。
  • 修复缺陷时先写能复现真实问题的最小回归用例,再验证修复。

只覆盖契约或可达路径中真实存在的正常、边界与失败场景。空值、类型错误、超时和数据库异常不是每个函数的固定要求。

3. 设计用例

每个用例应说明:

  • 对应的契约、缺陷或分支。
  • 输入与环境安排。
  • 可观察结果,而非内部实现细节。
  • 必要的清理和跨用例隔离。

优先参数化重复场景,并沿用仓库现有的测试命名、目录、fixture 和断言风格。不要因项目面向中文用户而强制使用中文函数名。

4. 实现最小测试

  • 只修改目标测试文件和确有必要的 fixture。
  • 不为了让测试通过而随意修改生产代码;若发现产品缺陷,单独报告或按用户要求修复。
  • 不复制未经核实的示例期望值,也不把实现细节写成永久契约。
  • Windows 与 Linux 使用路径 API、系统临时目录和显式编码,不硬编码分隔符、/tmp、换行、大小写、时区或 locale 行为。

5. 运行与复验

  1. 先运行新增或目标测试,确认失败信息与预期一致。
  2. 先检查项目脚本是否会下载依赖、访问外部服务或改变共享状态,再按改动风险运行相关测试;必要时运行完整测试、类型检查或覆盖率命令,潜在外部副作用需先获授权。
  3. 检查 Git diff,确认没有快照、缓存、覆盖率产物或无关文件。
  4. 将基线已有失败与本轮新增失败分开记录。

没有实际运行时,只能说明“已生成、未验证”,不能声称测试通过。

安全与授权边界

  • 未经明确授权,不安装或升级测试框架,不修改 lockfile、全局测试配置、CI 或生产代码。
  • 未经明确授权,不访问真实网络、生产数据库、云服务或含真实凭据的环境。
  • 测试数据不得包含真实个人信息、Token、Cookie、密码或客户数据。
  • 测试必须可重复,不依赖执行顺序,并清理创建的临时资源。
  • 目标文件已有用户修改时,先检查是否重叠,避免覆盖。

输出

## 测试补充结果

- 目标与契约依据:
- 测试层级与框架:
- 新增或修改文件:

## 用例

| 场景 | 契约依据 | 预期结果 |
|------|----------|----------|

## 验证

- 实际命令与退出状态:
- 相关测试 / 完整测试:
- 基线已有失败:
- 未验证假设与限制:
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 86 lines · 79 tokens per session scan A 99b8c93fe91b

Subscribe to this mod's changes

test-generator is a skill published in the GitHub repository laolaoshiren/claude-code-skills-zh (828 stars, last pushed today), licensed MIT. It adds 79 tokens to every session and 977 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

test-fixing

Run tests and systematically fix all failing tests using smart error grouping. Use when user asks to fix failing tests, mentions test failures, runs test suite and failures occur, or requests to make tests pass.

mhattingpete/claude-skills-marketplace · 44 tokens

aidex-coverage

Use when writing, placing, or running tests in any project — which layer a behaviour belongs in ("unit or E2E for X", "component test or browser test"), which tests to run for a change instead of the whole suite, when to extract a fixture, setting up an isolated disposable E2E environment, or the per-project testing…

yacb2/aidex · 193 tokens

csharp-testing-standards

Defines the testing standards, patterns, and conventions for all C# unit and integration test projects. Rules cover test framework usage, naming, structure, mocking, assertions, and parameterization. Apply these rules uniformly across all test projects.

linuxchata/ai-playbook · 53 tokens

csharp-testing

C# and .NET testing patterns with xUnit, FluentAssertions, mocking, integration tests, and test organization best practices. Use when writing or reviewing xUnit tests, mocks, or integration tests in a C# / .NET project.

userInner/SKILLS · 52 tokens

fsharp-testing

F# testing patterns with xUnit, FsUnit, Unquote, FsCheck property-based testing, integration tests, and test organization best practices. Use when writing F# tests with xUnit, FsUnit, Unquote, or FsCheck.

userInner/SKILLS · 53 tokens

golang-testing

Go testing best practices including table-driven tests, test helpers, benchmarking, race detection, coverage analysis, and integration testing patterns. Use when writing or improving Go tests.

userInner/SKILLS · 37 tokens